Mail Archives: djgpp/1999/06/08/19:25:40
> What is the difference between Bison And Flex?
A flex-built parser is a lexical analyzer. Basically, it reads a text
file and converts it to "tokens" or words. It sends those tokens to
the bison-built parser, which recognizes the syntax of those tokens
and takes actions based on them.
For example, a flex-built parser would see "if (x) exit" and convert
it into the following token stream:
T_IF
'('
T_IDENTIFIER (name="x")
')'
T_IDENTIFIER (name="exit")
The bison-generated portion, for example, would match it against a
pattern like this (real parsers can be *very* complicated):
statements : IF '(' expression ')' statement { foo($3, $5); }
| WHILE '(' expression ')' statement { bar($3, $5); }
| statement
;
- Raw text -