Infix Language
Basic: 1. Report: Write the specification of Infix Language by using a Context Free Grammar/Extended BackusNaur Form. You should write the specification in your report in a section denoted “Basic 1”. 2. Program: You should write a lexical analyser/scanner by extending/modifying the given Lexer.java source code so that it outputs an error message (described previously) if the input program does not pass lexical analysis. If the program passes lexical analysis, then you should store the sequence of tokens that are created in the array called tokenSequence in Infix.java. You should then print out the sequence of tokens (you will notice that each token already has a print method written). 3. Report: a) Explain what is mean by a left-recursive Context Free Grammar (CFG) and determine if your CFG for Infix Language is left-recursive. If it is, rewrite your CFG so that it avoid left-recursion. b) Describe the difference between an imperative and declarative language and give two examples of each type of language.
Intermediate:
4.
o a) Report: Write a Syntax Directed Translation Scheme for the Infix language. For this task, you should modify the Context Free Grammar that you wrote in Basic I & Basic 3 by adding any required semantic actions. o b) Program: extend/modify the Parser class in order to write a predictive parser (a type of recursive descent parser) for the syntax directed translation scheme that you wrote in 5a, to interpret Infix Language programs. The input will be an array of Tokens called inputTokens of some fixed size n. If the array of tokens denotes a valid program in Infix Language then you should output the result of interpreting the program; otherwise an error message should be produced.
Advanced:
5. Program: Modify your program so that it allows numerical values to also be written directly in expressions and so that as well as outputting the postfix notation form of the expression, it also outputs a colon ‘:’, followed by the expression in prefix form (with variables replaced by their numerical values as before