Interpreter Project
This project will be to write an interpreter for a minimal form of Blue. This minimal form of Blue has only 1 data type, integer, and the only identifiers are single letters. Blue is case sensitive.
The interpreter will parse a Blue 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.
Grammar for the language
Parser
→ feature id do end id
→ |
→ | | | | empty_statement>
→ if then else end if
→ loop exit on end loop
-> id
->
→ print ( )
→
→ le_operator | lt_operator | ge_operator | gt_operator | eq_operator | ne_operator
→ | |
→ add_operator | sub_operator | mul_operator | div_operator
Lexical Analyzer
id → letter
literal_integer → digit literal_integer | digit
assignment_operator→ :=
le_operator → <=
lt_operator → <
ge_operator → >=
gt_operator → >
eq_operator → =
ne_operator → <>
add_operator → +
sub_operator → -
mul_operator → *
div_operator → /