Group 11 homework 3 #View in RAW for proper formatting
EBNF of PL/0 program ::= "." block ::= const-declaration ::= [ “const” “=” {“,” “=" } “;”] var-declaration ::= [ “var” { “,” } “;” ] proc-declaration ::= { "procedure" ";" } statement ::= [ “:=" | “begin” { “;” } “end” | "call" ";" | “if” “then” [ "else" ] | “while” “do” | “read” | “write” ] condition ::= “odd” | rel-op ::= "=" | "<>" | "<" | "<=" | ">" | ">=" expression ::= [ “+” | “-” ] { (“+” | “-”) } term ::= { ( “*” | “/” ) } factor ::= | | “(” “)” number and ident are tokens with semantic values. number ::= {} ident ::= { | } digit ::= “0” | “1” | “2” | “3” | “4” | “5” | “6” | “7” | “8” | “9” letter ::= “a” | “b” | ... | “y” | “z” | “A” | “B” | ... | “Y” | “Z”
Changes: Line 7 : Block includes non-terminal symbol now Line 10 : proc-declaration nonterminal symbol grammar. Calles block. Every time you enter this increase lex level by 1, before you leave decrease lex level by 1. Completely optional, but can have many procedures in one block. line 13 : call procedure option added. line 14 : else added to if statements. Actual grammar here is speculated and the professor may alter it. Understand that he's still working on removing "ambiguity" of nested else statements.