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:
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- YACC program to implement a Calculator and recognize a valid Arithmetic expression
- C Program for simple interest
- C++ Program to implement Symbol Table
- C program to implement Adjacency Matrix of a given Graph
- Creating a Calculator for Android devices
- Dockerizing a simple Django app
- A simple understanding of Computer
- How to implement Dictionary with Python3?
- Downloading gists from Github made simple
- Simple Multithreaded Download Manager in Python
- C Program for Program to find area of a circle
- C Program for Program for array rotation
- Lex Program to remove comments from C program
- C program to detect tokens in a C program
- Why are there two folders - Program Files and Program Files (x86) in 64-bit Windows OS?
- How does a C program executes?
- Program Execution in the CPU
- C Program for ID3 Tagging
- C Hello World Program
- C Program to Add two Integers
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.