The structures of Flex/Lex are as following:
Definition/Declaration
%%
Statement/Action
- lexical entry/pattern
- space to distinguish the lexical entry and the action
code (what action should be taken)
- Action code (done in C )
%%
Additional code/main
To start with, please read tutorial #1, located in the tutorial section. There are some basic Flex operators. There is also some sample flex code in the following links.
For more information, please type -man flex or go to the link provide on left
hand side.
Flex/Lex
bash$ gcc -o token lex.yy.c -ll
bash$ token (or bash$ token -file)
ç
create an object
called "token"
- compile lex.yy.c, follow by "-ll", which will link to the library.
Therefore, no yywarp( ) problem
ç
token follow by "-file" will tokenize the
code in "-file"