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.
2. Add a section showing the construction of at least 3 syntax trees used.
3. To make the implementation more realistic, consider a module that is responsible for reading a text file
(file.txt), 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.
4. 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 =10;
Line 1: Lexical error found in $a
Process finished with exit code 0
b) Given the line of code with a syntax error
as is the following case: 10=10;
Lexical analysis completed with no errors
Tokens: INTEGER (10)= INTEGER (10);
Line 1: Syntax error found in INTEGER
Process finished with exit code 0
c) Given the lexically and syntactically correct code fragment:
if (a == b){
a =20;
}
Lexical analysis completed with no errors
Tokens: if ( id(a)= id(b)){ id(a)= INTEGER(20) ; }
Syntax analysis completed with no errors
Process finished with exit code 0
5. 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
Non-functional 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!