Consider the following extended BNF grammar for a subset of the Python programming language,
called MicroPython.

program ::= import list f funcdef g
funcdef ::= def func-identier ( [ identier f , identier g ] ) :
suite return add-expr
suite ::= statement f statement g
statement ::= variable-identier = expr
j if or-test : suite [else : suite ]
j while or-test : suite
j print expr
or-test ::= and-test f or and-test g
and-test ::= not-test f and not-test g
not-test ::= comparison j not not-test
comparison ::= add-expr comp-operator add-expr
comp-operator ::= < j > j == j >= j <= j <>
add-expr ::= mult-expr f add-operator mult-expr g
add-operator ::= + j

I take it this is an assignment for an undergrad Compilers class?

What sort of progress have you made so far?

This article has been dead for over six months. Start a new discussion instead.