CFG File Format (.cfg) CS 444, Winter 2017

A .cfg file is a text file representing a context-free grammar. The grammar must be augmented in the following sense: there must be exactly one production rule expanding the start symbol, and the right-hand-side of the rule must contain three symbols: a beginning-of-input terminal symbol followed by a non-terminal symbol followed by an end-of-input terminal symbol. The beginning-of-input and end-of-input terminal symbols must not appear in any other rule.

Context-free Grammar Representation

The context-free grammar representation has four components, in order:

Example .cfg file (sample.cfg)

6
BOF
EOF
id
-
(
)
3
S
expr
term
S
5
S BOF expr EOF
expr term
expr expr - term
term id
term ( expr )