lex & yacc get current position
问题 In lex & yacc there is a macro called YY_INPUT which can be redefined, for example in a such way #define YY_INPUT(buf,result,maxlen) do { \ const int n = gzread(gz_yyin, buf, maxlen); \ if (n < 0) { \ int errNumber = 0; \ reportError( gzerror(gz_yyin, &errNumber)); } \ \ result = n > 0 ? n : YY_NULL; \ } while (0) I have some grammar rule which called YYACCEPT macro. If after YYACCEPT I called gztell (or ftell), then I got a wrong number, because parser already read some unnecessary data. So