bison/flex: Peek at the next letter or token -


when dealing strings (it has own state comments) need find out if next letter " or not. if dont end string state. happens dont end string in string state (i use <string_state>. , process letter letter). happens is, mark if last string " , if current isnt exit state , unput last letter.

this has weird effect. when errors on lines strings see letter (usually ',' or ')') twice. , if happens on end of line side effect counts 2 lines! (even if there isnt error).

how can solve this? option create global var , mark when leave string state , hack yy_user fix itself? kind of want avoid that. cleaner @ next letter or token, possible?

in flex, can "peek ahead" @ future tokens using / lookahead operator. rule like

ab/cd 

will match 'ab' input if , if followed 'cd'. means flex matches 'cd' rule, pushes input buffer before calling action rule, yytext contains 'ab' when see it, , 'cd' read again next token


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -