To make clear, you can do this laboratory to two levels. If you wish to be graded with a maximum possible grade of a B, you should implement this grammar:
<CFWAE1> ::= <num>
| {+ <CFWAE1> <CFWAE1>}
| {- <CFWAE1> <CFWAE1>}
| {* <CFWAE1> <CFWAE1>}
| {/ <CFWAE1> <CFWAE1>}
| <id>
| {if0 <CFWAE1> <CFWAE1> <CFWAE1>}
| {with {<id> <CFWAE1>} <CFWAE1>}
| {fun {<id>} <CFWAE1>}
| {<CFWAE1> <CFWAE1>}
where an id is not +, -, *, /, with, if0 or fun.
Put simply, this is a language of single-binding with statements and single-argument functions. If your interpreter is well-written, well-tested, and adheres to style, then the submission of an interpreter for this language can earn, at maximum, a B. This is an accomplishment.
Once you reach this threshold, I would then extend my interpreter to include multiple bindings in the with, and multiple-argument functions. Implementing this language raises your maximum possible grade to an A.
<CFWAE2> ::= <num>
| {+ <CFWAE2> <CFWAE2>}
| {- <CFWAE2> <CFWAE2>}
| {* <CFWAE2> <CFWAE2>}
| {/ <CFWAE2> <CFWAE2>}
| <id>
| {if0 <CFWAE2> <CFWAE2> <CFWAE2>}
| {with {{<id> <CFWAE2>} ...} <CFWAE2>}
| {fun {<id> ...} <CFWAE2>}
| {<CFWAE2> <CFWAE2> ...}
where an id is not +, -, *, /, with, if0 or fun.
This grammar describes a language with multiple-binding with statements and functions that can handle multiple arguments. In this grammar, the ellipsis (...) means that the previous
non-terminal is present zero or more times.
If a fun or a with expression has duplicate
identifiers, we consider it a syntax error. Therefore, such errors must be
detected in parse. For example, parsing the following
expressions must signal errors:
{with {{x 10} {x 20}} 50}
{fun {x x} 10}