SIMPL Syntactic Analysis
The following is the LL(1) grammar for the SIMPL language. Note: the \ indicates a meta-character is being used as a literal
<prog> ::= <id><idtype> \( <varlist> \) \| <varlist> \| <statlist> !
<varlist> ::= <id> <idtype> <varlist> | e
<idtype> ::= ‘bool | e
<statlist> ::= <stat> <statlist> | e
<stat> ::= <assign> | <ifstat> | <whilestat>
<assign> ::= <id> <- <expr> !
<ifstat> ::= if <expr> ? <statlist> : <statlist> !
<whilestat> ::= while <expr> ? <statlist> !
<expr> ::= <aexp> <exprtail>
<exprtail ::= = <aexp> <exprtail> | > <aexp> <exprtail> | e
<aexp> ::= <mexp> <aexptail>
<aexptail> ::= + <mexp> <aexptail> | - <mexp> <aexptail> | e
<mexp> ::= <atom> <mexptail>
<mexptail> ::= * <atom> <mexptail> | / <atom> <mexptail> | e
<atom> ::= <id> | <num> | <boolean> | - <atom> | \( <expr> \)