WLPP Intermediate (.wlppi) Format
A .wlppi file (pronounced woolpy) is a text file containing the context-free parse of a WLPP program
combined with scanner output. The format of a .wlppi file is essentially that of the deriviation component
of a .cfg file for the WLPP grammar, with additional lines
representing terminals, and no indentation:
- no lines are indented
- the first line of the file contains S BOF procedure EOF
- following every line containing a production rule, there is one set of lines corresponding to each
symbol (terminal or non-terminal) in its RHS, in order.
- for a non-terminal, the set of lines begins with a rule whose LHS is the non-terminal; the
remaining lines in the set are defined recursively
- for a terminal other than BOF or EOF, the set of lines is a singleton containing the terminal symbol, followed by a space,
followed by the input string recognized by the scanner as that terminal
- for the terminal BOF or EOF, the set of lines is a singleton containing BOF BOF or EOF EOF respectively
Sample .wlppi file
S BOF procedure EOF
BOF BOF
procedure 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 cs241.WLPPICheck on Sample
Derivation Steps:
S -> BOF procedure EOF
procedure -> 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