Consider the extended BNF grammar for Clite, extended with function definitions, and function calls as a statement

computer science

Description

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. 

Determine the new tokens added to this grammar and modify the Clite.jflex, Token.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 distinction. 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. 3. Extend the AbstractSyntaxTree class on the web to include the new features, including functionality to print their abstract syntax trees. 4. Incorporate calls to your AbstractSyntaxTree class functions in ParserAST.java to allow construction of syntax trees for the new features. 5. Test your program on the provided CliteF programs. Your output should be a syntax tree for each program.


Related Questions in computer science category