logo Use SA10RAM to get 10%* Discount.
Order Now logo

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

expert
Alfredd DoddEngineering
(4/5)

743 Answers

Hire Me
expert
Angel MoralesLaw
(5/5)

716 Answers

Hire Me
expert
William BellBusiness
(5/5)

539 Answers

Hire Me
expert
Irina KossovaNursing
(/5)

648 Answers

Hire Me
Java Programming

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

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. 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

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme

Get Free Quote!

280 Experts Online