Posts

lab record

EX.NO.1      STUDY OF LEX TOOL AIM : To study about lexical analyser generator [LEX TOOL]. 1.Introduction: The unix utility lex parses a file of characters. It uses regular expression matching; typically it is used to ‘tokenize’ the contents of the file. In that context, it is often used together with the yacc utility. 2 Structure of a lex file A lex file looks like ...definitions... %% ...rules... %% ...code... Here is a simple example: %{ int charcount=0,linecount=0; %} %% . charcount++; \n {linecount++; charcount++;} %% int main() { yylex(); printf("There were %d characters in %d lines\n", charcount,linecount); return 0; } 2.1 Block Diagram : LEX COMPILER   LEX PGM----- à                                              ----- à LEX .YY.C                                                                         GCC   LEX.YY.C