Posted by: sirivy | March 27, 2009

Lex

STRUCTURE OF LEX FILES :

——————————————————————————————————–

%{

/*DEFINITION SECTION*/

%}

%%

/*RULES SECTION is made of two parts: pattern and action*/

/*Action will be executed if pattern is recognized by Lexer*/

/*Pattern is written in form of Regular Expression*/

%%

/*USER SUB-ROUTINE SECTION*/

/* include main program Here!*/

———————————————————————————————————

INSTRUCTION FOR COMPILE LEX FILE:

1.  lex lexfilename.l

Aflter your compilation succeeded , lex will generate file yy.lex.c for you. Next job is using gcc to compile this C file.

2.  gcc lex.yy.c -o arbitaryOutputName -ll

-ll to link to Lex library

3.  ./arbitaryOutputName

To test your program.

————————————————————————————————

I feel sleepy. Let’s continue tomorrow. -_- zZZZ


Leave a comment

Categories