Compiler Construction Lab Manual / Prepend LEX Program

Program Name

Write a Compiler Construction Program for Prepend LEX Program.
Theory
Prepend LEX Program for .=match anything except new line character *=any number of times. (Pattern =.*\n, Action=Printf)
Program Code


Saving: vi prepend.l

Compiling and Running
lex prepend.l
cc lex.yy.c
./a.out prepend.l
Input

Output
1 %% 2 %% 3 int main(void) 4 { 5 yylex(); 6 return 0; 7 } 8 int yywrap(void) 9 { 10 return 1; 11 }


Home     Back