WLP4 Intermediate (.wlp4i) Format

A .wlp4i file (pronounced woolpy) is a text file containing a representation of a parse tree for a WLP4 program. The format can be produced by building a parse tree for the WLP4 program and performing a preorder traversal of the tree. For nodes representing terminals, print the token kind and lexeme (or BOF BOF or EOF EOF for those special cases). For nodes representing nonterminals, print the rule used to expand the nonterminal, and then process each child subtree recursively from left to right.

Example

WLP4 program:
int wain(int foo, int bar) { return 42; }
Result of scanning:
INT int
WAIN wain
LPAREN (
INT int
ID foo
COMMA ,
INT int
ID bar
RPAREN )
LBRACE {
RETURN return
NUM 42
SEMI ;
RBRACE }
Result of parsing (.wlp4i file):
start BOF procedures EOF
BOF BOF
procedures main
main INT WAIN LPAREN dcl COMMA dcl RPAREN LBRACE dcls statements RETURN expr SEMI RBRACE
INT int
WAIN wain
LPAREN (
dcl type ID
type INT
INT int
ID foo
COMMA ,
dcl type ID
type INT
INT int
ID bar
RPAREN )
LBRACE {
dcls .EMPTY
statements .EMPTY
RETURN return
expr term
term factor
factor NUM
NUM 42
SEMI ;
RBRACE }
EOF EOF