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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: