Rewrite the grammar to eliminate the ebnf

Assignment Help C/C++ Programming
Reference no: EM132691243

CMSC 430 Introduction to Compilers - University of Maryland

Project
The second 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 |
|

INT_LITERAL | IDENTIFIER

| BOOL_LITERAL |

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.

Attachment:- Introduction to Compilers.rar

Reference no: EM132691243

Questions Cloud

What type of gametes will a ttyy plant produce : What type of gametes will a TtYy plant produce? (Hint: Use the FOIL method with the different alleles- First, Outer, Inner, Last - to get your gametes.
What is mendel law of independent assortment : What is Mendel's Law of Independent Assortment? When does it hold true?
How can decision making and incremental analysis be of value : How can decision making and incremental analysis be of value to someone's future endeavors? Include specific examples such as a company seeking to increase
What phenotypes would be expected : What phenotypes would be expected, and in what ratios, in the F2 generation from the cross of a homozygous wrinkled, yellow plant to a homozygous round, green o
Rewrite the grammar to eliminate the ebnf : Rewrite the grammar to eliminate the EBNF brace and bracket metasymbols and to incorporate the significance of parentheses, operator precedence
How are sales figures estimated : Why is budgeting an important part of the decision making process? Why is the sales budget so important in the budgeting process?
What we have learned about market structure : Imagine you are an analyst for a major car manufacturer. You need to write an email that discusses whether or not the company should attempt to expand its car.
How analysis variances assists in informed decision making : Should employees be allowed to be involved in the budget process? Why? How analysis variances assists in informed decision making
Predict the radioactive state of the daughter chromosomes : Predict the radioactive state of the daughter chromosomes after one, two and three divisions in the normal medium.

Reviews

len2691243

11/9/2020 5:08:34 AM

The assignment requires modifying the syntactic analyzer for the attached compiler by adding to the existing grammar and making report about it. Detail is in Project 2

Write a Review

C/C++ Programming Questions & Answers

  How can you break the main method

What we want to do in this assignment is we want to break our main file into three files: interface, client, and implementation and

  Write a program for ijvm called scramble

Write a program for IJVM called scramble that takes lowercase text from input and prints the next character (i.e. ‘b' is printed as ‘c') and uppercase text and prints the character before (‘B' is printed as ‘A'). Print all other characters as is.

  Create a game prototype using modern

CPT 323 - Object-Oriented Programming Using C++ - implement a basic game that you may (or may not) decide to build upon beyond this course.

  Write a program that asks the user for a profile name

Write a program that asks the user for a profile name and displays the number of characters, words, and lines in that file. Then have the program ask for the name of the next file. When the user enters a file that doesn't exist (such as the empty ..

  Prepare a program to show the fibonacci numbers

Write a C++ program to display first 20 Fibonacci numbers in descending order - Prepare a program to show the Fibonacci numbers

  Branching statements to control the flow of a program

The purpose of this exercise is to give you an opportunity to practice using cin to handle user keyboard inputs, use branching statements to control the flow of a program, and work on your C++ programming style

  Contrast symmetric and asymmetric cryptography

"Cryptography is ‘generally' considered to be the broadest security technique available." Explain what this statement means with respect to the principles of information security.

  Meaning any statement in the program

Technically, it is possible for C++ programmers to declare class data as public, meaning any statement in the program could access and change the data directly.

  Write a program that manages a linked list of records

Write a program that manages a linked list of records stored in "struct"s. An rough example should look like the program

  Write cpp program that will implement a breadth-first search

Write a C++ (or any other .net language) program that will implement a Breadth-First Search, a Depth-First Search, and an A* Search (using the number of misplaced tiles) to solve an 8-piece Slider Puzzle.

  Write a cpp program a two-dimensional array are populated

Write a c++ program a 2-dimensional array of 10x5 that are populated by random numbers between 0 and 49.

  What are c library functions gets and atoi

What are 'C' library functions gets and atoi and scanf used for and submit a flowchart or list of processing steps that can be used as a basis for the program.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd