Compiler Construction Lab Programs / Read Text From User And To Print Lex Program

Program Name

Write a Compiler Construction Program for Read Text From User And To Print Lex Program.
Theory
Read Text From User And To Prints using lex program sections.

yylex() call the rule section of lex program.
(%% section %%)
(%%%%=Default echo)
When we give the input the yywrap(void) will be called.int yywrap(void){return 1;} tells to come back to the first line.

Lex echo.l creates lex.yy.c file
Program Code


Saving: vi ab.l

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

Output
hai


Home     Back