CS 241 - WLP4 Intermediate (.wlp4i) Format

A .wlp4i file (pronounced woolpy) is a text file containing the context-free parse of a WLP4 program combined with scanner output. The format of a .wlp4i file is essentially that of the deriviation component of a .cfg file for the WLP4 grammar, with additional lines representing terminals, and no indentation:

Sample .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
statements
RETURN return
expr term
term factor
factor NUM
NUM 42
SEMI ;
RBRACE }
EOF EOF

Output of wlp4icheck on Sample

Derivation Steps:
   start ->  BOF procedures EOF
   procedures -> main
   main ->  INT WAIN LPAREN dcl COMMA dcl RPAREN LBRACE dcls statements RETURN expr SEMI RBRACE
   dcl ->  type ID
   type -> INT
   dcl ->  type ID
   type -> INT
   dcls -> 
   statements -> 
   expr ->  term
   term ->  factor
   factor ->  NUM

Terminal String:
   BOF INT WAIN LPAREN INT ID COMMA INT ID RPAREN LBRACE RETURN NUM SEMI RBRACE EOF