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:
long wain(long foo, long bar) { return 42; }
Result of scanning:
LONG long
WAIN wain
LPAREN (
LONG long
ID foo
COMMA ,
LONG long
ID bar
RPAREN )
LBRACE {
RETURN return
NUM 42
SEMI ;
RBRACE }
Result of parsing (.wlp4i file):
start BOF procedures EOF
BOF BOF
procedures main
main LONG WAIN LPAREN dcl COMMA dcl RPAREN LBRACE dcls statements RETURN expr SEMI RBRACE
LONG long
WAIN wain
LPAREN (
dcl type ID
type LONG
LONG long
ID foo
COMMA ,
dcl type ID
type LONG
LONG long
ID bar
RPAREN )
LBRACE {
dcls .EMPTY
statements .EMPTY
RETURN return
expr term
term factor
factor NUM
NUM 42
SEMI ;
RBRACE }
EOF EOF