Question: Apply the basic fundamentals of compilers to develop the Syntax Analyzer in Python, with the objective of understanding that the main area is to find
Apply the basic fundamentals of compilers to develop the "Syntax Analyzer" in Python, with the objective of understanding that the main area is to find the syntactic structure of a sentence or line of co de and that it is represented by a syntax, to check if it is syntactically correct or not.Consider the test code snippet to perform lexical and syntactic analysis, making use of the
grammar that is required, in order to establish whether the order of the tokens corresponding to the expressions of
entry has the correct structure.
Do not attempt an assignment operation to a literal constant value
Follow the reserved word if with an opening parenthesis,
etc.
Add a section showing the construction of at least syntax trees used.
To make the implementation more realistic, consider a module that is responsible for reading a text file
filetxt which will contain the source code. From there, it will run both parsers lexical and syntax
reporting the errors that occurred at each stage, if they occur.
To test the functionality of your proposal for both analysis processes, you will show the windows with the
results achieved from the different possible scenarios a lexical error, b syntactic error and c no errors
Examples:
a Given the line of code: int $a ;
Line : Lexical error found in $a
Process finished with exit code
b Given the line of code with a syntax error
as is the following case: ;
Lexical analysis completed with no errors
Tokens: INTEGER INTEGER ;
Line : Syntax error found in INTEGER
Process finished with exit code
c Given the lexically and syntactically correct code fragment:
if a b
a ;
Lexical analysis completed with no errors
Tokens: if ida idb ida INTEGER ;
Syntax analysis completed with no errors
Process finished with exit code
Don't forget to incorporate the following elements into the written report:
Functional requirements
Example:
The system will indicate when the entry is invalid
Will first verify the lexical analysis
Will allow its use to any user who gives an entry
It will allow the analysis of one data at a time
Nonfunctional requirements
Example:
The system can only be operated with a user in session
The storage will be reflected depending on the input obtained
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
