This site uses cookies only for the purpose of identifying user sessions.
This is required to properly register actions.
Exercise
‹20›:
Expressions over binary + and field access with .
The set of tokens of the language is
{+,.,IDENT}. The token IDENT represents
identifiers. Such tokens are non-empty sequences of alphanumeric characters and
underscore, not starting by a digit. Examples of correct expressions are
“s.m + x.a”, “x + a.f.m”, “i”, and examples of
incorrect expressions are “x.”, “.y.z+w”, “_a+”,
“x..y”, etc. The generated AST must correspond to an interpretation of
the operator + as left-associative. Field access must be represented by
a subtree with the symbol “.” as root, the struct being accessed as
first child and the field as second child. Note that the implicit
parenthesization of “st.fi.z” is “(st.fi).z”. For instance,
the following input
x.y.z + i
produces the following AST
+(.(.(x,y),z),i)
Authors: Pau Fernández, Nil Mamano
/
Documentation: