lex - How flex handle ambiguous patterns -
i want use flex handle patterns. in case, both constant , function name alphabetical strings begin uppercase letter. example, in mother(liz, bob)
, how can differentiate mother
, liz
? want (
single token, can not regard mother(
pattern.
normally, unnecessary generate different token types different kinds of identifier. parser shouldn't need distinction if different uses can distinguished syntactically. (if need semantic information differentiate, , sentence ambiguous without information, might need semantic feedback not appear case here.)
if don't have parser, need syntactic analysis. say, example, function names always followed (
-- means language doesn't allow higher order functions. write wrapper around yylex
reads 1 token in advance , emits function_name
or constant_name
, depending on following token.
Comments
Post a Comment