Skip to content

nagendar-pm/lexer_and_parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LAnguage eXample (LAX) is a basic programming language given for the purpose of studying Compilers (here Lexical and Syntax Analysis). It is stated in the Waitegoose book.
Link for the same is given here

Lexical Analysis:

Using regular expressions, we identify the tokens first, then categorise them. This can be seen in lexer.l file. We perform this using Lex language.

Syntax Analysis:

Using LR-parser technique, we perform this part. We take the categorised tokens and build an LR-parser (Bottom-Top tree). If we can build the whole tree, then parsing is successful, else there is an error. This can be observed in parser.y file, using Yacc.

Instructions for compilation & execution:

open the current dir in terminal
follow these instructions then:
1.chmod +x run.sh
2../run.sh
It is to be noted that the lex file tokenises the program in "input.txt" written in LAX(LAnguage eXample) language and the yacc file parses it, if any error is found in the input file, parsing is stopped with an error.
For more information on states, Action and Goto elements of the parser, y.output file is to be get in reference with.

About

Lexical and Syntax analyzer

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages