logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

Consider the extended BNF grammar for Clite, extended with function definitions, and function calls as a statement (returning a void type) as an expression (returning a value type).

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

CSCE 4430 ASSIGNMENT #2

Consider the extended BNF grammar for Clite, extended with function definitions, and function calls as a statement (returning a void type) as an expression (returning a value type). We will call this language CliteF.

 

Program                 ::=    { Function } int main ( ) { Declarations Statements }

Function                 ::=    FunctionType Identifier ( [ FormalParameters ] )

{ Declarations Statements return Expression ; }

FunctionType        ::=    ValueType | void

ValueType              ::=    int | bool | float | char

FormalParameters     ::=     ValueType Identifier [ [ ] ] { , ValueType Identifier [ [ ] ] }

                                                             

Declarations           ::=    { Declaration }

Declaration               ::=     ValueType Identifier [ [ Integer ] ] { , Identifier [ [ Integer ] ] }

Statements            ::=    { Statement }

Statement               ::=    ; | Block | Assignment | IfStatement | WhileStatement | ProcedureCall Block                       ::=    { Statements }

Assignment            ::=    Identifier [ [ Expression ] ] = Expression ; IfStatement            ::=    if ( Expression ) Statement [ else Statement ] WhileStatement     ::=    while ( Expression ) Statement ProcedureCall                                 ::=    FunctionCall ;

FunctionCall          ::=    Identifier ( [ ExpressionList ] ) ExpressionList       ::=    Expression { , Expression } Expression             ::=    Conjunction { || Conjunction } Conjunction           ::=    Equality { && Equality } Equality                                 ::=    Relation [ EquOp Relation ]

EquOp                   ::=    == | !=

Relation                    ::=     Addition [ RelOp Addition ]

RelOp                       ::=     < | <= | > | >=

Addition                ::=    Term { AddOp Term }

AddOp                   ::=    + | -

Term                       ::=    Factor { MulOp Factor }

MulOp                     ::=    * | / | %

Factor                       ::=     [ UnaryOp ] Primary

UnaryOp                 ::=    - | !

Primary                     ::=     Identifier [ [ Expression ] ] | Literal | ( Expression ) | FunctionCall

                                                                           

| ValueType ( Expression )

  1. Determine the new tokens added to this grammar and modify the Clite.jflex, java and TokenClass.java files accordingly to create a new lexical analyzer for CliteF.
  2. Modify the ParserAST.java file to parse the new syntax. Note that Program may start with int which could be the beginning of a function or the int main () sequence so your parser will have to make this A similar case will arise in distinguishing the beginning of an assignment statement from a procedure call and an identifier from a function call, as both start with an identifier.
  1. Extend the AbstractSyntaxTree class on the web to include the new features, including func- tionality to print their abstract syntax
  2. Incorporate calls to your AbstractSyntaxTree class functions in java to allow con- struction of syntax trees for the new features.
  3. Test your program on the provided CliteF programs. Your output should be a syntax tree for each
(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Atharva PatilComputer science

605 Answers

Hire Me
expert
Chrisantus MakokhaComputer science

654 Answers

Hire Me
expert
AyooluwaEducation

902 Answers

Hire Me
expert
RIZWANAMathematics

563 Answers

Hire Me

Get Free Quote!

344 Experts Online