public class PrettyPrinter extends Visitor
| Modifier and Type | Field and Description |
|---|---|
protected AST |
ast
The type operations.
|
protected boolean |
isTopLevel
Flag for whether the choice is top-level.
|
protected boolean |
newline
Flag for whether the last element ended in a newline.
|
protected boolean |
parenChoice
Flag for whether the next ordered choice needs to be parenthesized.
|
protected boolean |
parenSequence
Flag for whether the next sequence element needs to be parenthesized.
|
protected Printer |
printer
The printer for this pretty printer.
|
protected boolean |
verbose
The flag for whether this pretty printer is verbose.
|
| Modifier | Constructor and Description |
|---|---|
protected |
PrettyPrinter(AST ast,
boolean verbose)
Create a new pretty printer.
|
|
PrettyPrinter(Printer printer,
AST ast,
boolean verbose)
Create a new pretty printer.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
enter(Production p)
Enter the specified production.
|
protected void |
exit(Production p)
Exit the specified production.
|
void |
flush()
Flush the underlying printer.
|
protected void |
format(boolean isToken,
java.lang.String text)
Format the specified statically known text value.
|
protected boolean |
isPrefix(Element e)
Determine whether the specified element represents a prefix
operator.
|
protected void |
print(Action a,
boolean caret)
Print the specified action.
|
protected void |
print(java.util.List<Sequence> alternatives,
java.lang.String mark)
Print the specified alternatives.
|
protected void |
print(ModuleDependency dep,
java.lang.String name)
Print the specified module dependency.
|
protected void |
print(java.lang.String s)
Print the specified action string.
|
protected void |
printActions(Module m)
Print the specified module's header, body, and footer actions.
|
protected void |
printDocumentation(Module m)
Print the specified module documentation comment.
|
protected void |
printModule(Module m)
Print the specified module's declaration.
|
protected void |
printOption(Module m)
Print the specified module's options.
|
protected int |
regexEscapes()
Get the flags for escaping regex strings.
|
protected int |
stringEscapes()
Get the flags for escaping regular strings.
|
void |
visit(Action a)
Print the specified action.
|
void |
visit(ActionBaseValue v)
Print the specified action base value.
|
void |
visit(AlternativeAddition p)
Print the specified alternative addition.
|
void |
visit(AlternativeRemoval p)
Print the specified alternative removal.
|
void |
visit(AnyChar a)
Print the specified any character element.
|
void |
visit(Attribute a)
Print the specified attribute.
|
void |
visit(Binding b)
Print the specified binding.
|
void |
visit(BindingValue v)
Print the specified binding value.
|
void |
visit(CharCase c)
Print the specified character case.
|
void |
visit(CharClass c)
Print the specified character class.
|
void |
visit(CharLiteral l)
Print the specified character literal.
|
void |
visit(CharRange r)
Print the specified character range.
|
void |
visit(CharSwitch s)
Print the specified character switch.
|
void |
visit(EmptyListValue v)
Print the specified empty list value.
|
void |
visit(FollowedBy p)
Print the specified followed-by element.
|
void |
visit(FullProduction p)
Print the specified full production.
|
void |
visit(GenericActionValue v)
Print the specified generic action value.
|
void |
visit(GenericNodeValue v)
Print the specified generic node value.
|
void |
visit(GenericRecursionValue v)
Print the specified generic recursion value.
|
void |
visit(Grammar g)
Print the specified grammar.
|
void |
visit(Module m)
Print the specified module.
|
void |
visit(ModuleImport imp)
Print the specified module import.
|
void |
visit(ModuleInstantiation ins)
Print the specified module instantiation.
|
void |
visit(ModuleList list)
Print the specified module list.
|
void |
visit(ModuleModification mod)
Print the specified module modification.
|
void |
visit(ModuleName name)
Print the specified module name.
|
void |
visit(NodeMarker m)
Print the specified node marker.
|
void |
visit(NonTerminal nt)
Print the specified nonterminal.
|
void |
visit(NotFollowedBy p)
Print the specified not-followed-by element.
|
void |
visit(NullLiteral l)
Print the specified null literal.
|
void |
visit(NullValue v)
Print the specified null value.
|
void |
visit(Option o)
Print the specified option.
|
void |
visit(OrderedChoice c)
Print the specified ordered choice.
|
void |
visit(ParserAction pa)
Print the specified parser action.
|
void |
visit(ParseTreeNode n)
Print the specified parse tree node.
|
void |
visit(ProductionOverride p)
Print the specified production override.
|
void |
visit(ProperListValue v)
Print the specified proper list value.
|
void |
visit(Repetition r)
Print the specified repetition.
|
void |
visit(SemanticPredicate p)
Print the specified semantic predicate.
|
void |
visit(Sequence s)
Print the specified sequence.
|
void |
visit(SequenceName n)
Print the specified sequence name.
|
void |
visit(StringLiteral l)
Print the specified string literal.
|
void |
visit(StringMatch m)
Print the specified string match.
|
void |
visit(StringValue v)
Print the specified string value.
|
void |
visit(TokenValue v)
Print the specified token value.
|
void |
visit(VoidedElement v)
Print the specified voided element.
|
dispatch, equals, hashCode, iterate, map, mapInPlace, unableToVisit, visitprotected Printer printer
protected final AST ast
protected final boolean verbose
protected boolean newline
protected boolean parenChoice
protected boolean parenSequence
protected boolean isTopLevel
protected PrettyPrinter(AST ast, boolean verbose)
printer field and register this
visitor with the set printer.ast - The type operations.verbose - The verbose flag.protected int stringEscapes()
protected int regexEscapes()
protected boolean isPrefix(Element e)
e - The element.true if the specified element represents a
prefix operator.public void flush()
public void visit(Attribute a)
public void visit(Grammar g)
protected void printDocumentation(Module m)
m - The module.protected void printModule(Module m)
m - The module.protected void printActions(Module m)
m - The module.protected void printOption(Module m)
m - The module.public void visit(Module m)
protected void print(ModuleDependency dep, java.lang.String name)
dep - The dependency.name - The corresponding name.public void visit(ModuleImport imp)
public void visit(ModuleInstantiation ins)
public void visit(ModuleModification mod)
public void visit(ModuleList list)
public void visit(ModuleName name)
protected void enter(Production p)
parenChoice and parenSequence to false.p - The production.protected void exit(Production p)
p - The production.public void visit(AlternativeAddition p)
public void visit(AlternativeRemoval p)
public void visit(ProductionOverride p)
public void visit(FullProduction p)
protected void print(java.util.List<Sequence> alternatives, java.lang.String mark)
alternatives - The ordered list of alternatives.mark - The mark.public void visit(OrderedChoice c)
public void visit(Repetition r)
public void visit(Option o)
public void visit(SequenceName n)
public void visit(Sequence s)
public void visit(FollowedBy p)
public void visit(NotFollowedBy p)
public void visit(SemanticPredicate p)
public void visit(VoidedElement v)
public void visit(Binding b)
public void visit(StringMatch m)
public void visit(NonTerminal nt)
public void visit(StringLiteral l)
public void visit(AnyChar a)
public void visit(CharLiteral l)
public void visit(CharRange r)
public void visit(CharClass c)
public void visit(CharCase c)
public void visit(CharSwitch s)
protected void print(java.lang.String s)
s - The string.protected void print(Action a, boolean caret)
a - The action to print.caret - Flag for whether to prefix the action with a caret.public void visit(NodeMarker m)
public void visit(Action a)
public void visit(ParserAction pa)
public void visit(ParseTreeNode n)
public void visit(NullLiteral l)
public void visit(NullValue v)
protected void format(boolean isToken,
java.lang.String text)
isToken - Flag for whether the value is a token.text - The text.public void visit(StringValue v)
public void visit(TokenValue v)
public void visit(BindingValue v)
public void visit(EmptyListValue v)
public void visit(ProperListValue v)
public void visit(ActionBaseValue v)
public void visit(GenericNodeValue v)
public void visit(GenericActionValue v)
public void visit(GenericRecursionValue v)
Copyright © 2014. All Rights Reserved.