gramxrefis a shell script which reads a Wirth BNF grammar from standard input and writes a grammar cross reference to standard output. Comment lines and blank lines are ignored; all production lines are numbered. The input itself may not contain line numbers.
gramxref < example.grm > example.xref
gramtermis a shell script which reads a Wirth BNF grammar from standard input and writes a list of terminal symbols to standard output. Terminal symbols are sorted into Pargen standard order, namely: reserved words (alphabetically), punctuation, other terminal symbols. The input may contain comment lines and blank lines.
gramterm provides post-processing to
which is an awk script.
gramterm < example.grm > terminalList
linenois an awk script which reads a Wirth BNF grammar from standard input and writes a copy of the input to standard output with the grammar productions numbered.
linenouses the same basic line numbering scheme as
lineno < example.grm > example.lnum
tokenint. Each is an awk script that takes from standard input a dictionary (except tokenstring) followed by a list of tokens (one per line) as generated by
gramtermand outputs C++ code to standard output:
tokenstringgenerates a list of the tokens enclosed in string quotes and separated by commas; this list is suitable for including in a string array initialization.
tokenenumgenerates a list of enumeration literals, separated by commas; the dictionary provides names for the special characters which are used in naming special symbols.
tokenintis basically the same as
tokenenum, except that it generates
const intdefinitions instead of an enumeration literal.
tokenstring < terminalList > tokenstrings.cc
bnf2wirthis an awk script for converting Pargen BNF grammars to Wirth BNF grammar grammars. Only the most basic conversion is done. Nonterminals have their angle brackets removed. Comments are converted from beginning
#. The output is defined to be symbol is an
Many Pargen conventions are not currently handled and may not be present in the input:
bnf2wirth < example.bnf > example.grm
deriveis a Perl program for deriving strings from a grammar, which is read from standard input. Output is to standard output.
The grammar should be in standard BNF without comments or blank lines. Each line should contain a single production. Lines may not contain tabs or trailing spaces. Each grammar symbol must be separated from every other symbol by at least one space. Nonterminals need not be enclosed in angle brackets (<...>).
derive generates strings in order of length, basically using
a leftmost derivation (but generating all substitutions of the leftmost
nonterminal). If the same output string appears more than once, then
the grammar is ambiguous. By default,
derive produces all strings which
are of length 5 or less.
derive still needs work!
derive < example.grm > stringList
-len=no -- changes the maximum derived string length to no.
-debug-- turns on some debugging output.