CS 3150 Project
The project for this term is the implement the following project in three different languages: Java, Ada, and Python.
Interpreter Project
This project will be to write an interpreter for a minimal form of Visual Basic. This minimal form of BASIC has only 1 data type, integer, and the only identifiers are single letters (i.e. there are only 26 possible identifiers since visual basic is not case sensitive).
The expressions will be either a variable, a constant, or an arithmetic expression. The boolean expressions are of the form: relative_operator operand operand where the 6 relative operators are equal to, less than, greater than, not equal to, less than or equal to, and greater than or equal to. The interpreter will parse the visual basic program and build some intermediate data structures. These data structures will then be interpreted to execute the program. All tokens in this language are separated by white space. The parsing algorithm should detect any syntactical or semantic error. The first such error discovered should cause an appropriate error message to be printed, and then the interpreter should terminate. Run-time errors should also be detected with appropriate error messages being printed.
The Java version of the project is due at 8:00 am on Monday, June 17th. The Python version of the project is due at 8:00 am on Wednesday, July 3rd. The Ada version is due at 8:00 am on Monday, July 22nd.
Grammar for the language
<program> → sub main ( ) <statement_list> end sub
<statement_list> → <statement> | <statement> <statement_list>
<statement> → <if_statement> | <do_while_statement> | <assignment_statement> | <print_statement>
<assignment_statement> → <id> = <expression>
<if_statement> → if <boolean_expression> then <statement_list> else <statement_list> end if
<print_statement> → print <id>
<do_while_statement> → do while <boolean_expression> <statement_list> loop
<boolean_expression> → <relop> <expression> <expression>
<expression> → <binary_expression> | <unary_expression>
<binary_expression> → <arith_op> <expression> <expression>
<unary_expression> → <id> | <literal_integer>
<relop> → < | <= | > | >= | == | <>
<arithop> → + | - | * | /
<id> → 'a' .. 'z'
<digit> → '0' .. '9'
<literal_integer> → <digit> | <digit> <literal_integer>