How to make unlex using Flex (fast lexical analyzer)?

Is there a way to return a token to an input stream using Flex? I imagine some type function yyunlex().

+3
source share
2 answers

There is a macro REJECTthat will return the token into the stream and continue to comply with other rules, as if the first matching did not. If you just want to put some char back in the @Kizaru stream, the answer will suffice.

Fragment example:

%%
a     |
ab    |
abc   |
abcd  ECHO; REJECT;
.|\n  printf("xx%c", *yytext);
%%
+3
source

You have several options.

, unput(ch), ch - . ch ( , ). , , .

, yyless(0), . , , , - . n hwich , n .

, /, lex . , bison yacc, yyparse().

+2

All Articles