Lex is a computer program that generates lexical analyzers and was written by Mike Lesk and Eric Schmidt. Lex reads an input stream specifying the lexical analyzer and outputs source code implementing the lex in the C programming language.
Tokens: A token is a group of characters forming a basic atomic chunk of syntax i.e. token is a class of lexemes that matches a pattern. Eg – Keywords, identifier, operator, separator.
Input: int p=0, d=1, c=2; Output: total no. of tokens = 13
Below is the implementation of the above explanation:
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.
- DFA in LEX code which accepts even number of zeros and even number of ones
- DFA in LEX code which accepts Odd number of 0’s and even number of 1’s
- C program to detect tokens in a C program
- Need for Intermediate Code and Code Optimization
- Lex Program to count number of words
- Lex program to count the number of lines, spaces and tabs
- LEX program to count the number of vowels and consonants in a given string
- Three address code in Compiler
- Lex Program to print the total characters, white spaces, tabs in the given input file
- Issues in the design of a code generator
- Code Optimization in Compiler Design
- DFA in LEX code which accepts strings ending with 11
- Frequency Reduction in Code Optimization
- Intermediate Code Generation in Compiler Design
- LEX code to extract HTML tags from a file
- Introduction of Object Code in Compiler Design
- Compiler Design | Detection of a Loop in Three Address Code
- Lex code to replace a word with another word in a file
- Lex program to check whether given number is armstrong number or not
- Lex program to count words that are less than 10 and greater than 5
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.
Improved By : Ravimaurya2