Exercise 24:

Parenthesized expressions over binary +, function calls, indexed access, field access and dereferences
The set of tokens of the language is {+,IDENT,NUMBER,[,],(,),.,^,,} (mind the last token, which is a comma). The token NUMBER represents unsigned integers, i.e., non-empty sequences of digits. The token IDENT represents function identifiers, variables, and field identifiers. Such tokens are non-empty sequences of alphanumeric characters and underscore, not starting by a digit. A function receives 0 or more arguments, enclosed in parentheses and separated by commas. A variable can be a numeric value, an array indexable with [], a struct with fields accessible with ., or a pointer dereferenceable with ^. An expression (such as a number, the value returned by a function call or a struct field) can be anything a variable can. Thus, apparently semantically nonsensical expressions such as 0^ or (1+2)[3] must be accepted. Function arguments and array indices can be arbitrary expressions, whereas a struct field is always an IDENT.

Examples of correct expressions are and examples of incorrect expressions are The generated AST must correspond to an interpretation of the operator + as left-associative, and all of the following: For example, for input
f().m^[2]
the resulting AST must be
[(^(.(((f,params()) ,m)),2)
Authors: Nil Mamano / Documentation:
To be able to submit you need to either log in, register, or become a guest.