The program language Flex will help you in the Scanner project.  Flex is quite similar to Prolog.  It will find patterns and unify the results and decide what action should be taken.

     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

Objective:
Sample Code:
Compile Instruction:
bash$ flex token.lex

 

bash$ gcc -o token lex.yy.c -ll

 

 

bash$ token  (or bash$ token -file)

ç compile flex
- use "flex" instead of "lex" will fix   yylex( ) so that it has no type problems

ç 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"