CIT 594 Grammar corrections
Spring 2004, David Matuszek

This page just collects in one place the changes to the BNF grammar between assignment 3 (Recognizer) and assignment 4 (Parser).

<variable> ::= <name>     // was: <variable> ::= ":" <name>

<name> ::= <letter> { <letter> | <digit> }

<integer> ::= <digit> { <digit> }

<program> ::= <command> { <command> } { <procedure> }     // new nonterminal

<command> ::= <move> <expression> <eol>
            | "penup" <eol>
            | "pendown" <eol>
            | "color" <colorname> <eol>
            | "home" <eol>
            | "set" <variable> <expression> <eol>
            | "repeat" <expression> <block>
            | "while" <condition> <block>
            | "if" <condition> <block>
            | "do" <name> { <expression> } <eol>     // new alternative

<move> ::= "forward"    // no longer allows "backward"
         | "right"
         | "left"

<colorname> ::= "red" | "orange" | "yellow" | "green" | "blue"
              | "purple" | "violet" | "brown" | "black" | "white"
              | "gray" | "pink"

<block> ::= "[" <eol> { <command> } "]" <eol>

<condition> ::= <expression> <comparator> <expression>

<comparator> ::= "<" | "=" | ">"

<procedure> ::= "to" <name> { <variable> } <eol> { <command> } "end" <eol>

<eol> ::= "\n" { "