Linux : Compiler theory

project involves modifying the syntactic analyzer for the attached compiler by adding to the existing grammar. The full grammar of the language is shown below. The highlighted portions of the grammar show what you must either modify or add to the existing grammar. function: function_header {variable} body function_header: FUNCTION IDENTIFIER [parameters] RETURNS type ; variable: IDENTIFIER : type IS statement parameters: parameter {, parameter} parameter: IDENTIFIER : type type: INTEGER | REAL | BOOLEAN body: BEGIN statement END ; statement: expression ; | REDUCE operator {statement} ENDREDUCE ; | IF expression THEN statement ELSE statement ENDIF ; | CASE expression IS {case} OTHERS ARROW statement ; ENDCASE ; operator: ADDOP | MULOP case: WHEN INT_LITERAL ARROW statement expression: ( expression ) | expression binary_operator expression | NOT expression | INT_LITERAL | REAL_LITERAL | BOOL_LITERAL | IDENTIFIER binary_operator: ADDOP | MULOP | REMOP | EXPOP | RELOP | ANDOP | OROP In the above grammar, the red symbols are nonterminals, the blue symbols are terminals and the black punctuation are EBNF metasymbols. The braces denote repetition 0 or more times and the brackets denote optional. You must rewrite the grammar to eliminate the EBNF brace and bracket metasymbols and to incorporate the significance of parentheses, operator precedence and associativity for all operators. Among arithmetic operators the exponentiation operator has highest precedence following by the multiplying operators and then the adding operators. All relational operators have the same precedence. Among the binary logical operators, and has higher precedence than or. Of the categories of operators, the unary logical operator has highest precedence, the arithmetic operators have next highest precedence, followed by the relational operators and finally the binary logical operators. All operators except the exponentiation operator are left associative. The directives to specify precedence and associativity, such as %prec and %left, may not be used Your parser should be able to correctly parse any syntactically correct program without any problem. You must modify the syntactic analyzer to detect and recover from additional syntax errors using the semicolon as the synchronization token. To accomplish detecting additional errors an error production must be added to the function header and another to the variable declaration. Your bison input file should not produce any shift/reduce or reduce/reduce errors. Eliminating them can be difficult so the best strategy is not introduce any. That is best achieved by making small incremental additions to the grammar and ensuring that no addition introduces any such errors. An example of compilation listing output containing syntax errors is shown below: 1 -- Multiple errors 2 3 function main a integer returns real; Syntax Error, Unexpected INTEGER, expecting ':' 4 b: integer is * 2; Syntax Error, Unexpected MULOP 5 c: real is 6.0; 6 begin 7 if a > c then 8 b 3.0; Syntax Error, Unexpected REAL_LITERAL, expecting ';' 9 else 10 b = 4.; 11 endif; 12 ; Syntax Error, Unexpected ';', expecting END Lexical Errors 0 Syntax Errors 4 Semantic Errors 0 You are to submit two files.  The first is a .zip file that contains all the source code for the project. The .zip file should contain the flex input file, which should be a .l file, the bison file, which should be a .y file, all .cc and .h files and a makefile that builds the project.  The second is a Word document (PDF or RTF is also acceptable) that contains the documentation for the project, which should include the following: a. A discussion of how you approached the project b. A test plan that includes test cases that you have created indicating what aspects of the program each one is testing and a screen shot of your compiler run on that test case c. A discussion of lessons learned from the project and any improvements that could be made

Answers

Related Questions

Humanities : A3- Conditioning Theories, analyze a...

Write a 4–5 page paper in which you analyze a personal learning experience based on theories of learning and cognition and formulate strategies to i...

Business Finance : training session There are sev...

Part oneThere are several instructional methods and activities that can be used to deliver training. As a trainer, you should have a broad awareness o...

Science : particular clinical area and identifies...

Details:Review the Topic Materials and the work completed in NRS-433V to formulate a PICOT statement for your capstone project.A PICOT starts with a d...

Humanities : A2- Learning Theories...

Write a 4–5-page summary of what you learned on learning theories.PreparationThe focus of this assessment is on learning theories. Consider an exper...

Humanities : aper #1 - Crisis Intervention Proble...

aper #1 - Crisis Intervention Problem 70Length: 2-3 pages (not including cover pager or reference page).Format: Standard APA format (1" margins, 12-po...

Humanities : Article Assignment for psychology ca...

1. What is the study about? 2. Who conducted the study? 3. What gaps were missing in the available research that led to this study being conducted? 4....

Programming : Network Architecture paper...

Compare and contrast cat. 6 unshielded twisted pair (UTP), coaxial, and single mode fiber optic cabling types. Describe one or two of the advantages a...

Business Finance : Weighted Average Cost of Capit...

Weighted Average Cost of Capital Purpose of Assignment Students should understand the mechanics in calculating a company's weighted average cost o...

Business Finance : Digital Crime Theory Help...

Digital Crime Theories Write a three to four (3-4) page paper in which you: Select two (2) of the theories, suggested in Chapter 3 of the text, that a...

Humanities : Response: Ethics, legalities, and po...

Ethics, legalities, and policies Response: Critically evaluate the elements of your post and compare them to those in your classmate’s. In what way...

Business Finance : Final Paper : Case Study...

Final PaperThe final assignment for the course is a Final Paper on two cases. The Final Paper should demonstrate understanding of the reading as well...

Programming : dddataba_9...

Hi, Please Follow these Guidelines Carefully.1. I Am expecting Great Work from you without any Plagiarism. All Work will be checked using Safe assign...

Science : physics assignment...

Suppose that a waffle recipe designed to feed three people calls for 600 mL of flour. How many milliliters of flour would you use if you wanted to ext...

Business Finance : Groups and Teams at Work...

Suggest at least one (1) scenario in which understanding the Five Stages of Group Development could help you to work more effectively in groups in the...

Humanities : Research Paper - case management and...

Research Paper - Case Management as a Victims Advocate. See attachment for grading rubic.The final paper must be submitted in APA format, including a...

Business Finance : Business Law Question...

Jim and Laura Buyer visit the local car dealership because they are interested in buying a new car. The car they currently have is aging and is starti...

Programming : write 2 reflections essays...

Write 2 reflection essays based on the BLS Occupations Projects data. Make sure the 2 essays are different and do not upload them in one file. All dat...

Humanities : Technology and Young Children, Engli...

What is the appropriate use of technology and interactive media in early childhood education? An annotated bibliography begins the preliminary resear...

Writing : Letter to US Politician, writing homewo...

you will also be writing a letter to a U.S. politician about current U.S. foreign policy issue (Human-trafficking will be your topic) including your s...

Business Finance : Internal Environmental Analysi...

Strategic Plan Part 2: Internal Environmental AnalysisWrite a 1,400-word minimum internal environmental analysis in which you include the following: A...

Humanities : Behavioral and Social-Cognitive App...

Create a 12- to 15-slide presentation analyzing the formation of habits using behavioral and social-cognitive approaches. Your presentation should cov...

Humanities : How they conducted business, history...

The Industrial Revolution changed life in every society it touched. It affected individuals as well as groups, the rich as well as the poor, the citie...

Programming : Requesting 2 page Project Managemen...

You have been asked to be the project manager for the development of an information technology (IT) project. The system to be developed will allow a l...

Science : Health Law, law homework help...

Examine the Federal Health Insurance Portability and Accountability Act (HIPAA). Discuss the history and purpose of HIPAA. Identify the concepts of pr...

If you didn't find the right answer

Ask Your Questions, We'll notify you once someone answers it