Exercise 6:

Grammar for Pascal statements
The set of tokens of the language is {IDENT, expr, :, :=, ,, ;, (, ), goto, begin, end, if, then, else, case, of, repeat, until, while, do, for, to, downto, with}. The token IDENT recognizes valid identifiers, i.e., a non-empty sequence of lowercase alphanumeric characters and underscore, not starting by a digit. We do not consider uppercase letters, since Pascal is case-insensitive. Token expr represents an arbitrary expression, and thus, we de not need to parse expressions, as we already dispose of this ‘token’. This token includes variable access, which are expressions such as “index”, “v[6]”, and “node.child”.

There are two types of statements: simple statements, and structured statements. Any statement may be prefixed by a label (an identifier), as in “L: ...”. In that case, the token : must appear as root of the AST.

Simple statements are statements that do not contain other statements. There are 4 kinds: There are 4 kinds of structured statements:
Authors: Nil Mamano / Documentation:
To be able to submit you need to either log in, register, or become a guest.