Grammar for this Project

The following is the grammar implemented in this project:

<assign> ::= <var> <- <const> <assign> ::= <var> <- <var> <assign> ::= <var> <- <var> + 1 <assign> ::= <var> <- <var> - 1 <stmt> ::= <assign> <program> ::= <stmtList> .

The terminals (tokens) are:

assignSym <-
colonSym :
constSym 1
eofSym end-of-file indicator
errorSym oops!
minusSym -
periodSym .
plusSym +
varSym An identifier ( [A-Za-z][A-Za-z0-9]*)

The code is in these files:

CharSets.cc Data abstraction for storing sets of characters
CharSets.h Header declarations for the set abstraction
Tokens.cc Data abstraction for reading and indentifying tokens
Tokens.h Header declarations for the token abstraction
parse.cc Main program -- recursive descent parser
pgm.dat Sample "program" in this trivial language

This program uses Morell's data abstractions. On boole compile these files with the following command:

~morell/bin/gb CharSets.cc Tokens.cc parse.cc -o parse

This will run the gb script and produce an executable called parse. This program can then be run by typing: parse < pgm.dat '


Sat Oct 22 20:02:20 CDT 2005