Skip to main content

yyerror

Function yyerror 

Source
pub fn yyerror(noerr: i32)
Expand description

Emit a parser-level error. Direct port of zsh/Src/parse.c 2733-2766 yyerror. C version fills a per-event error buffer and sets errflag. zshrs pushes onto errors which the caller drains via parse()’s Result return. WARNING: param-name divergence — Rust takes &str message, C takes Port of static void yyerror(int noerr) from Src/parse.c:2733.

Faithful C body (verbatim):

int t0; char *t;
if ((t = dupstring(zshlextext))) untokenize(t);
for (t0 = 0; t0 != 20; t0++)
    if (!t || !t[t0] || t[t0] == '\n') break;
if (!(histdone & HISTFLAG_NOEXEC) && !(errflag & ERRFLAG_INT)) {
    if (t0) {
        t = metafy(t, t0, META_STATIC);
        zwarn("parse error near `%s%s'", t, t0 == 20 ? "..." : "");
    } else
        zwarn("parse error");
}
if (!noerr && noerrs != 2)
    errflag |= ERRFLAG_ERROR;

zshlextext is the C lexer’s current-token text (Src/lex.c:170 char *tokstr); zshrs’s equivalent is lex::tokstr(). The “20” is C’s tail-truncation length for the error message.