Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Syntax analysis Total Points: 20 Implement a compiler for a language defined in project Phase lexical analysis. The programming language you need to use is

image text in transcribed
image text in transcribed
Syntax analysis Total Points: 20 Implement a compiler for a language defined in project Phase lexical analysis. The programming language you need to use is C or C++ (and the language defined by the corresponding tools). This file describes the second phase of the project, i.e. syntax analysis. Second Phase -Syntax Analysis Using yacc For the second phase, you need to define the FP-language in yacc definitions and feed it to yacc to generate a parser Your definitions should follow the BNF given earlier, but exclude the token definitions which have already been processed by lex and instead use the token names you defined for the first project You also need to generate a parse tree for the input FP program. For parse tree generation, you need to write code in the definition file for tree node generation. Also, you need to use a stack to keep track of the tree nodes so that you can link them properly into the correct parse tree. You can either use yacc stack or your own stack for this purpose. Each node in your parse tree should include the actual symbol of the node, including all those defined in the BNF for the FP language (e.g., +, "Program", argument, return-arg, statement, statements, if-stmt, etc.) For each identifier, instead of giving the actual identifier name, it should simply be a pointer to the symbol table (the index of the symbol table). You have created a symbol table in the first project. Now you need to make sure you can access it and add more information into it. In this phase, you need to assign identifier type to each identifier. Identifier types include: program-name function-name argument retum-arg assignment-id: the identifier in the assignment statement and is to be assigned a value expression-id: appear after comparison operators or Boolean operators parameter: all other parameters besides those listed above At the end (best is in the main program), you need to print out two things: the symbol table and the parse tree

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Explain the issues of safety unique to small businesses.

Answered: 1 week ago

Question

1. How do most insects respire ?

Answered: 1 week ago

Question

Who is known as the father of the indian constitution?

Answered: 1 week ago

Question

1.explain evaporation ?

Answered: 1 week ago

Question

Who was the first woman prime minister of india?

Answered: 1 week ago

Question

Explain the concept of going concern value in detail.

Answered: 1 week ago