public class GrammarPrettyPrinter extends AbstractPrettyPrinter<NonTerminal>
Grammar
in a readable way (similar to how grammars
are normally written in CS articles). ε terminals are printed as "#" to make then visible in the output and
terminals only containing a space character are printed as "_" for the same reason. NonTerminals are names from A through Z
and when this naming scheme runs out the convention is to start over from A1 through Z1, A2 trough Z2 and so on an so forth.
Nothing is done to separate the case where a Terminal prints a capital character C from the case where a NonTerminal is called C.
If the same Pretty printer is reused, a nonterminal will have the same name when printed multiple times.marked
Constructor and Description |
---|
GrammarPrettyPrinter(Grammar g) |
Modifier and Type | Method and Description |
---|---|
protected String |
getEasyName(NonTerminal nonTerminal) |
String |
getName(AlphabetSymbol a) |
String |
getTerminalName(Terminal t) |
String |
print()
Prints the grammar to a string.
|
protected String |
productionHook(Production p) |
copyEasyNames, escapeSymbol, getNextName
public GrammarPrettyPrinter(Grammar g)
protected String getEasyName(NonTerminal nonTerminal)
getEasyName
in class AbstractPrettyPrinter<NonTerminal>
public String getName(AlphabetSymbol a)
public String print()
protected String productionHook(Production p)
Copyright © 2008-2013 Mathias Schwarz.