Lex program to implement a simple Calculator
Lex is a computer program that generates lexical analyzers. Lex reads an input stream specifying the lexical analyzer and outputs source code implementing the lexer in the C programming language.
The commands for executing the LEX program are:
lex abc.l (abc is the file name) cc lex.yy.c -efl ./a.out
Let’s see LEX program to implement a simple calculator.
Input : 3+3 Output : 6.0 Input : 5*4 Output : 20.0
Below is the implementation: