xtc.parser
Class CodeGenerator

java.lang.Object
  extended by xtc.tree.Visitor
      extended by xtc.parser.CodeGenerator

public class CodeGenerator
extends Visitor

The code generator.

The code generator makes the following assumptions about the intermediate language:

Version:
$Revision: 1.294 $
Author:
Robert Grimm

Field Summary
protected  Analyzer analyzer
          The analyzer utility.
static java.lang.String ARG_INDEX
          The name of the index argument.
protected  AST ast
          The type operations.
protected  boolean attributeConstant
          The flag for making variable bindings constant.
protected  boolean attributeDump
          The flag for including a method to dump the memoization table.
protected  boolean attributeFlatten
          The flag for flattening lists.
protected  boolean attributeIgnoringCase
          The flag for performing case-insensitive comparisons.
protected  boolean attributeMain
          The flag for creating a main method.
protected  boolean attributeParseTree
          The flag for generating a parse tree.
protected  boolean attributePrinter
          The flag for using a grammar-specified printer in the main method.
protected  boolean attributeProfile
          The flag for including code to produce a memoization profile.
protected  boolean attributeRawTypes
          The flag for using raw types.
protected  boolean attributeStateful
          The flag for using a global state object.
protected  boolean attributeStringSet
          The flag for having a string set attribute.
protected  boolean attributeVerbose
          The flag for generating debugging code.
protected  boolean attributeWithLocation
          The flag for generating code to annotate nodes with location information.
static java.lang.String BASE_INDEX
          The name for the base index variable.
protected  java.lang.String baseIndex
          The expression for the base index.
protected  Element bindingElement
          The element being bound.
protected  java.lang.String bindingName
          The name of the current binding.
protected  Type bindingType
          The type of the element being bound.
static java.lang.String CHAR
          The name of the character variable.
protected  int choiceLevel
          The nesting level for nested choices.
static int CHUNK_SIZE
          The size of chunks.
protected  int chunkCount
          The number of chunks.
protected  boolean chunked
          Flag for whether the memoization fields are organized in chunks.
protected  java.util.Map<NonTerminal,java.lang.Integer> chunkMap
          The map from nonterminals to chunk numbers.
protected  java.lang.String className
          The class name for the current grammar.
static java.lang.String COLUMN
          The name of the memoization column variable.
protected  boolean createsNodeValue
          The flag for whether an alternative creates a node value.
protected  java.util.Iterator<Element> elementIter
          The iterator over the elements of a sequence.
protected  boolean endsWithParseError
          Flag for whether the current choice ends with a parse error.
protected  java.lang.String factoryClassName
          The class name for the generic node factory.
protected  boolean firstElement
          The flag for the first element in a top-level choice.
protected  int indentLevel
          The indentation level for choices.
static java.lang.String INDEX
          The name of the index variable.
protected  java.lang.String indexName
          The name of the index variable.
protected  java.lang.String mainMethodNonterminal
          The nonterminal for the main method.
static java.lang.String NESTED_CHOICE
          The prefix for the index variable for nested choices.
protected  boolean notFollowedBy
          Flag for whether the current predicate is a not-followed-by predicate.
static java.lang.String OP_VALUE
          The prefix for the variable referencing the semantic value of a bound option.
static java.lang.String OPTION
          The prefix for the index variable for options.
protected  boolean optional
          The flag for options.
protected  java.lang.String optionalElement
          The name of the variable referencing the element value for bound options, or null if no such option is currently being processed.
protected  int optionLevel
          The nesting level for options.
protected  java.util.List<Type> optionTypes
          The types of bound options, i.e.
static java.lang.String PARSE_CHAR
          The name of the character parsing method.
static java.lang.String PARSE_ERROR
          The name for the parse error variable.
static java.lang.String PRED_INDEX
          The name of the predicate index variable.
static java.lang.String PRED_MATCHED
          The name for the predicate matched variable.
static java.lang.String PRED_RESULT
          The name for the predicate result variable.
protected  boolean predicate
          Flag for whether we are currently emitting a predicate.
protected  java.util.Iterator<Element> predicateIter
          The predicate iterator.
static java.lang.String PREFIX
          The general prefix for internal parser fields and variables.
static java.lang.String PREFIX_COUNT_FIELD
          The prefix for field names that count accesses to memoized results.
static java.lang.String PREFIX_FIELD
          The prefix for field names that memoize the parsers results.
static java.lang.String PREFIX_METHOD
          The prefix for parsing method names.
protected  Printer printer
          The printer utility.
static java.lang.String PRINTER
          The name for the variable referencing the verbose mode printer.
protected  java.lang.String printerClassName
          The class name for the grammar-specified printer.
static java.lang.String REP_VALUE
          The prefix for the variable referencing the semantic value of a bound repetition.
protected  boolean repeated
          The flag for repetitions.
static java.lang.String REPEATED
          The prefix for the flag indicating that a repetition has been matched at least once.
protected  java.lang.String repeatedElement
          The name of the variable referencing the element value for bound repetitions, or null if no such repetition is currently being processed.
protected  boolean repeatedOnce
          The flag for at-least-once repetitions.
static java.lang.String REPETITION
          The prefix for the index variable for repetitions.
protected  int repetitionLevel
          The nesting level for repetitions.
protected  java.util.List<Type> repetitionTypes
          The types of bound repetitions, i.e.
static java.lang.String RESULT
          The name for the result variable.
protected  java.lang.String resultName
          The name of the result variable.
protected  Runtime runtime
          The runtime.
protected  java.lang.String savedBaseIndex
          The saved base index.
protected  boolean savedFirstElement
          The saved first element.
protected  boolean savedOptional
          The saved option flag for predicates.
protected  boolean savedRepeated
          The saved repetition flag for predicates.
protected  boolean savedRepeatedOnce
          The saved at-least-once flag for predicates.
protected  boolean savedUseBaseIndex
          The saved flag for using the base index.
protected  boolean seenTest
          Flag for whether a test has been emitted.
static java.lang.String STATE
          The name for the variable referencing the global state object.
protected  java.lang.String stateClassName
          The class name for the global state object.
protected  boolean useBaseIndex
          The flag for using the base index.
static java.lang.String VALUE
          The name for the value variable (i.e., yyValue).
 
Constructor Summary
CodeGenerator(Runtime runtime, Analyzer analyzer, AST ast, Printer printer)
          Create a new code generator.
 
Method Summary
protected  void action(Action a)
          Actually emit code for the specified action.
protected  void binding()
          Actually emit the code for the last visited binding.
 java.lang.String booleanT()
          Get the primitive boolean type as a string.
 java.lang.String charT()
          Get the primitive character type as a string.
protected  void charValueTest()
          Emit the code testing whether the character has a value.
protected  void clearBinding()
          Clear binding information after usage.
protected  void dump()
          Emit code for dumping the memoization table.
protected  void emitAction(GenericActionValue v)
          Emit the action creating a new generic node.
protected  void emitChildren(java.lang.String first, java.util.List<Binding> children)
          Emit an expression adding the children to a generic node.
protected  void emitDifference()
          Emit code for determining the textual different.
protected  void emitFactoryName()
          Emit the class name of the class creating generic nodes.
protected  void emitFormatting(java.util.List<Binding> formatting)
          Emit a statement adding formatting to a generic node.
protected  void emitNumberOfChildren(int base, java.util.List<Binding> children)
          Emit an expression calculating a generic node's number of children.
 java.lang.String emptyListExpr()
          Get the empty list expression.
 java.lang.String extern(Type type)
          Extern the specified type.
 java.lang.String fieldName(NonTerminal nt, java.lang.String prefix)
          Generate a field name for the specified nonterminal.
protected  boolean hasBinding()
          Determine whether the current element has a binding.
protected  void index(java.lang.String oldIndex, boolean isLastChar)
          Emit the code for assigning the index variable.
 java.lang.String indexT()
          Get the primitive index type as a string.
 java.lang.String intT()
          Get the primtive integer type as a string.
protected  void mainMethod(java.lang.String nt)
          Emit code for a static main method.
 java.lang.String methodName(NonTerminal nt)
          Generate the method name for the specified nonterminal.
protected  java.lang.String nestedChoice()
          Return the name of the parser variable for the current nested choice level.
protected  void nextElement()
          Emit the code for the next element.
protected  boolean notFollowedBy()
          Determine whether we are processing a not-followed-by predicate.
 java.lang.String nullExpr()
          Get the null expression.
protected  int numberOfChildren(int base, java.util.List<Binding> children)
          Calculate the number of a generic node's children.
protected  void parseError()
          Emit the code for generating a parse error based on the production's name.
protected  void parseError(java.lang.String text)
          Emit the code for generating a parse error based on a fixed text.
protected  void profile()
          Emit code for printing the memoization profile.
 java.lang.String rawT(java.lang.String type)
          Get the raw, non-generic type for the specified type.
protected  void result(java.lang.String methodName, boolean saveIndex, boolean threadError)
          Emit the code for assigning the result variable, threading the parse error, and for testing the result.
protected  void returnValue()
          Emit the code for returning a semantic value.
protected  void saveIndex(java.lang.String savedIndex, java.lang.String spacer, java.lang.String base)
          Emit the code for saving the index variable.
 java.lang.String stringExpr(java.lang.String text)
          Get a string expression.
protected  void stringValueTest(java.lang.String text, boolean ignoreCase)
          Emit the code for testing the result.
protected  void tested()
          Note that a test has been emitted.
protected  void threadParseError(int align)
          Emit code for threading parse error.
protected  void valueTest()
          Emit the code testing whether the result has a value.
protected  java.lang.String var(Binding b)
          Convert a binding into the corresponding variable name.
protected  void verbose()
          Emit code for verbose operation.
 void visit(Action a)
          Generate code for the specified action.
 void visit(ActionBaseValue v)
          Generate code for the specified action base value.
 void visit(AnyChar a)
          Generate code for the any character element.
 void visit(Binding b)
          Generate code for the specified binding.
 void visit(BindingValue v)
          Generate code for the specified binding value.
 void visit(CharClass c)
          Generate code for the specified character class.
 void visit(CharLiteral l)
          Generate code for the specified character literal.
 void visit(CharSwitch s)
          Generate code for the specified character switch.
 void visit(EmptyListValue v)
          Generate code for the specified empty list value.
 void visit(FollowedBy p)
          Generate code for the specified followed-by predicate.
 void visit(FullProduction p)
          Generate code for the specified production.
 void visit(GenericActionValue v)
          Generate code for the specified generic action value.
 void visit(GenericNodeValue v)
          Generate code for the specified generic node value.
 void visit(GenericRecursionValue v)
          Generate code for the specified generic recursion value.
 void visit(Module m)
          Generate code for the specified grammar.
 void visit(NodeMarker m)
          Generate code for the specified node marker.
 void visit(NonTerminal nt)
          Generate code for the specified nonterminal.
 void visit(NotFollowedBy p)
          Generate code for the specified not-followed-by predicate.
 void visit(NullLiteral l)
          Generate code for the specified null literal.
 void visit(NullValue v)
          Generate code for the specified null value.
 void visit(Option o)
          Generate code for the specified option.
 void visit(OrderedChoice c)
          Generate code for the specified ordered choice.
 void visit(ParserAction pa)
          Generate code for the specified parser action.
 void visit(ParseTreeNode n)
          Generate code for the specified parse tree node.
 void visit(ProperListValue v)
          Generate code for the specified proper list value.
 void visit(Repetition r)
          Generate code for the specified repetition.
 void visit(SemanticPredicate p)
          Generate code for the specified semantic predicate.
 void visit(StringLiteral l)
          Generate code for the specified literal.
 void visit(StringMatch m)
          Generate code for the specified string match.
 void visit(StringValue v)
          Generate code for the specified string value.
 void visit(TokenValue v)
          Generate code for the specified token value.
 void visit(VoidedElement v)
          Generate code for the specified voided element.
 
Methods inherited from class xtc.tree.Visitor
dispatch, equals, hashCode, iterate, map, mapInPlace, unableToVisit, visit
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHUNK_SIZE

public static final int CHUNK_SIZE
The size of chunks.

See Also:
Constant Field Values

PREFIX_METHOD

public static final java.lang.String PREFIX_METHOD
The prefix for parsing method names.

See Also:
Constant Field Values

PREFIX_FIELD

public static final java.lang.String PREFIX_FIELD
The prefix for field names that memoize the parsers results.

See Also:
Constant Field Values

PREFIX_COUNT_FIELD

public static final java.lang.String PREFIX_COUNT_FIELD
The prefix for field names that count accesses to memoized results.

See Also:
Constant Field Values

PREFIX

public static final java.lang.String PREFIX
The general prefix for internal parser fields and variables.

See Also:
Constant Field Values

PRINTER

public static final java.lang.String PRINTER
The name for the variable referencing the verbose mode printer.

See Also:
Constant Field Values

STATE

public static final java.lang.String STATE
The name for the variable referencing the global state object.

See Also:
Constant Field Values

PARSE_CHAR

public static final java.lang.String PARSE_CHAR
The name of the character parsing method.

See Also:
Constant Field Values

ARG_INDEX

public static final java.lang.String ARG_INDEX
The name of the index argument.

See Also:
Constant Field Values

COLUMN

public static final java.lang.String COLUMN
The name of the memoization column variable.

See Also:
Constant Field Values

CHAR

public static final java.lang.String CHAR
The name of the character variable.

See Also:
Constant Field Values

INDEX

public static final java.lang.String INDEX
The name of the index variable.

See Also:
Constant Field Values

RESULT

public static final java.lang.String RESULT
The name for the result variable.

See Also:
Constant Field Values

PRED_INDEX

public static final java.lang.String PRED_INDEX
The name of the predicate index variable.

See Also:
Constant Field Values

PRED_RESULT

public static final java.lang.String PRED_RESULT
The name for the predicate result variable.

See Also:
Constant Field Values

PRED_MATCHED

public static final java.lang.String PRED_MATCHED
The name for the predicate matched variable.

See Also:
Constant Field Values

BASE_INDEX

public static final java.lang.String BASE_INDEX
The name for the base index variable.

See Also:
Constant Field Values

NESTED_CHOICE

public static final java.lang.String NESTED_CHOICE
The prefix for the index variable for nested choices.

See Also:
Constant Field Values

REPETITION

public static final java.lang.String REPETITION
The prefix for the index variable for repetitions.

See Also:
Constant Field Values

OPTION

public static final java.lang.String OPTION
The prefix for the index variable for options.

See Also:
Constant Field Values

REPEATED

public static final java.lang.String REPEATED
The prefix for the flag indicating that a repetition has been matched at least once.

See Also:
Constant Field Values

REP_VALUE

public static final java.lang.String REP_VALUE
The prefix for the variable referencing the semantic value of a bound repetition.

See Also:
Constant Field Values

OP_VALUE

public static final java.lang.String OP_VALUE
The prefix for the variable referencing the semantic value of a bound option.

See Also:
Constant Field Values

VALUE

public static final java.lang.String VALUE
The name for the value variable (i.e., yyValue).

See Also:
Constant Field Values

PARSE_ERROR

public static final java.lang.String PARSE_ERROR
The name for the parse error variable.

See Also:
Constant Field Values

runtime

protected final Runtime runtime
The runtime.


analyzer

protected final Analyzer analyzer
The analyzer utility.


ast

protected final AST ast
The type operations.


printer

protected final Printer printer
The printer utility.


attributeVerbose

protected boolean attributeVerbose
The flag for generating debugging code.


attributeWithLocation

protected boolean attributeWithLocation
The flag for generating code to annotate nodes with location information.


attributeConstant

protected boolean attributeConstant
The flag for making variable bindings constant.


attributeFlatten

protected boolean attributeFlatten
The flag for flattening lists.


attributeParseTree

protected boolean attributeParseTree
The flag for generating a parse tree.


attributeRawTypes

protected boolean attributeRawTypes
The flag for using raw types.


attributeIgnoringCase

protected boolean attributeIgnoringCase
The flag for performing case-insensitive comparisons.


attributeStateful

protected boolean attributeStateful
The flag for using a global state object.


attributeStringSet

protected boolean attributeStringSet
The flag for having a string set attribute.


stateClassName

protected java.lang.String stateClassName
The class name for the global state object.


factoryClassName

protected java.lang.String factoryClassName
The class name for the generic node factory.


attributeMain

protected boolean attributeMain
The flag for creating a main method.


mainMethodNonterminal

protected java.lang.String mainMethodNonterminal
The nonterminal for the main method.


attributePrinter

protected boolean attributePrinter
The flag for using a grammar-specified printer in the main method.


printerClassName

protected java.lang.String printerClassName
The class name for the grammar-specified printer.


attributeProfile

protected boolean attributeProfile
The flag for including code to produce a memoization profile.


attributeDump

protected boolean attributeDump
The flag for including a method to dump the memoization table.


className

protected java.lang.String className
The class name for the current grammar.


chunked

protected boolean chunked
Flag for whether the memoization fields are organized in chunks.


chunkMap

protected java.util.Map<NonTerminal,java.lang.Integer> chunkMap
The map from nonterminals to chunk numbers.


chunkCount

protected int chunkCount
The number of chunks.


firstElement

protected boolean firstElement
The flag for the first element in a top-level choice.


savedFirstElement

protected boolean savedFirstElement
The saved first element.


baseIndex

protected java.lang.String baseIndex
The expression for the base index.


useBaseIndex

protected boolean useBaseIndex
The flag for using the base index.


savedBaseIndex

protected java.lang.String savedBaseIndex
The saved base index.


savedUseBaseIndex

protected boolean savedUseBaseIndex
The saved flag for using the base index.


indentLevel

protected int indentLevel
The indentation level for choices.


choiceLevel

protected int choiceLevel
The nesting level for nested choices.


repeated

protected boolean repeated
The flag for repetitions.


savedRepeated

protected boolean savedRepeated
The saved repetition flag for predicates.


repeatedOnce

protected boolean repeatedOnce
The flag for at-least-once repetitions.


savedRepeatedOnce

protected boolean savedRepeatedOnce
The saved at-least-once flag for predicates.


repetitionLevel

protected int repetitionLevel
The nesting level for repetitions.


repeatedElement

protected java.lang.String repeatedElement
The name of the variable referencing the element value for bound repetitions, or null if no such repetition is currently being processed.


repetitionTypes

protected java.util.List<Type> repetitionTypes
The types of bound repetitions, i.e. MetaData.boundRepetitions.


optional

protected boolean optional
The flag for options.


savedOptional

protected boolean savedOptional
The saved option flag for predicates.


optionLevel

protected int optionLevel
The nesting level for options.


optionalElement

protected java.lang.String optionalElement
The name of the variable referencing the element value for bound options, or null if no such option is currently being processed.


optionTypes

protected java.util.List<Type> optionTypes
The types of bound options, i.e. MetaData.options.


createsNodeValue

protected boolean createsNodeValue
The flag for whether an alternative creates a node value.


seenTest

protected boolean seenTest
Flag for whether a test has been emitted.


endsWithParseError

protected boolean endsWithParseError
Flag for whether the current choice ends with a parse error.


elementIter

protected java.util.Iterator<Element> elementIter
The iterator over the elements of a sequence.


indexName

protected java.lang.String indexName
The name of the index variable.


resultName

protected java.lang.String resultName
The name of the result variable.


bindingName

protected java.lang.String bindingName
The name of the current binding.


bindingElement

protected Element bindingElement
The element being bound.


bindingType

protected Type bindingType
The type of the element being bound.


predicate

protected boolean predicate
Flag for whether we are currently emitting a predicate.


notFollowedBy

protected boolean notFollowedBy
Flag for whether the current predicate is a not-followed-by predicate.


predicateIter

protected java.util.Iterator<Element> predicateIter
The predicate iterator.

Constructor Detail

CodeGenerator

public CodeGenerator(Runtime runtime,
                     Analyzer analyzer,
                     AST ast,
                     Printer printer)
Create a new code generator.

Parameters:
runtime - The runtime.
analyzer - The analyzer.
ast - The type operations.
printer - The printer.
Method Detail

booleanT

public java.lang.String booleanT()
Get the primitive boolean type as a string.

Returns:
The boolean type.

charT

public java.lang.String charT()
Get the primitive character type as a string.

Returns:
The character type.

intT

public java.lang.String intT()
Get the primtive integer type as a string.

Returns:
The integer type.

indexT

public java.lang.String indexT()
Get the primitive index type as a string.

Returns:
The index type.

extern

public java.lang.String extern(Type type)
Extern the specified type. If the specified type is not null, this method returns its external representation. Otherwise, it returns null.

Parameters:
type - The type.
Returns:
The type as a string.

rawT

public java.lang.String rawT(java.lang.String type)
Get the raw, non-generic type for the specified type.

Parameters:
type - The type as a string.
Returns:
The raw type as a string.

nullExpr

public java.lang.String nullExpr()
Get the null expression.

Returns:
The null expression.

stringExpr

public java.lang.String stringExpr(java.lang.String text)
Get a string expression.

Parameters:
text - The string's text.
Returns:
The string expression.

emptyListExpr

public java.lang.String emptyListExpr()
Get the empty list expression.

Returns:
The empty list expression.

fieldName

public java.lang.String fieldName(NonTerminal nt,
                                  java.lang.String prefix)
Generate a field name for the specified nonterminal.

Parameters:
nt - The nonterminal.
prefix - The field name's prefix.
Returns:
The corresponding field name.

methodName

public java.lang.String methodName(NonTerminal nt)
Generate the method name for the specified nonterminal.

Parameters:
nt - The nonterminal.
Returns:
The corresponding method name.

verbose

protected void verbose()
Emit code for verbose operation.


profile

protected void profile()
Emit code for printing the memoization profile.


dump

protected void dump()
Emit code for dumping the memoization table.


mainMethod

protected void mainMethod(java.lang.String nt)
Emit code for a static main method.

Parameters:
nt - The name of the top-level nonterminal to parse.

visit

public void visit(Module m)
Generate code for the specified grammar.


visit

public void visit(FullProduction p)
Generate code for the specified production.


result

protected void result(java.lang.String methodName,
                      boolean saveIndex,
                      boolean threadError)
Emit the code for assigning the result variable, threading the parse error, and for testing the result.

Parameters:
methodName - The name of the parser method to use.
saveIndex - The flag for whether to save the index in the base index variable.
threadError - The flag for whether to thread the parse error.

threadParseError

protected void threadParseError(int align)
Emit code for threading parse error.

Parameters:
align - The alignment for the assignment operator.

valueTest

protected void valueTest()
Emit the code testing whether the result has a value.


charValueTest

protected void charValueTest()
Emit the code testing whether the character has a value.


stringValueTest

protected void stringValueTest(java.lang.String text,
                               boolean ignoreCase)
Emit the code for testing the result.

Parameters:
text - The expected text value.
ignoreCase - The flag for whether to ignore the case.

index

protected void index(java.lang.String oldIndex,
                     boolean isLastChar)
Emit the code for assigning the index variable.

Parameters:
oldIndex - The old index.
isLastChar - Flag for whether the just recognized character is the terminal's last character.

saveIndex

protected void saveIndex(java.lang.String savedIndex,
                         java.lang.String spacer,
                         java.lang.String base)
Emit the code for saving the index variable.

Parameters:
savedIndex - The saved index.
spacer - Any extra space.
base - The current base index.

tested

protected void tested()
Note that a test has been emitted. This method should be called at the end of the method that emitted the test.


nextElement

protected void nextElement()
Emit the code for the next element. If the next element is the last element in the main sequence, the code for returning a semantic value is also emitted.

See Also:
returnValue()

returnValue

protected void returnValue()
Emit the code for returning a semantic value.


parseError

protected void parseError()
Emit the code for generating a parse error based on the production's name.


parseError

protected void parseError(java.lang.String text)
Emit the code for generating a parse error based on a fixed text.

Parameters:
text - The expected text.

nestedChoice

protected java.lang.String nestedChoice()
Return the name of the parser variable for the current nested choice level.

Returns:
The nested choice parser variable.

visit

public void visit(OrderedChoice c)
Generate code for the specified ordered choice.


visit

public void visit(Repetition r)
Generate code for the specified repetition.


visit

public void visit(Option o)
Generate code for the specified option.


visit

public void visit(FollowedBy p)
Generate code for the specified followed-by predicate.


notFollowedBy

protected boolean notFollowedBy()
Determine whether we are processing a not-followed-by predicate.

Returns:
true if we are processing a not-followed-by predicate.

visit

public void visit(NotFollowedBy p)
Generate code for the specified not-followed-by predicate.


visit

public void visit(SemanticPredicate p)
Generate code for the specified semantic predicate.


visit

public void visit(VoidedElement v)
Generate code for the specified voided element.


visit

public void visit(Binding b)
Generate code for the specified binding.


hasBinding

protected boolean hasBinding()
Determine whether the current element has a binding.

Returns:
true if the current element has a binding.

binding

protected void binding()
Actually emit the code for the last visited binding.


clearBinding

protected void clearBinding()
Clear binding information after usage.


visit

public void visit(StringMatch m)
Generate code for the specified string match.


visit

public void visit(NonTerminal nt)
Generate code for the specified nonterminal.


visit

public void visit(AnyChar a)
Generate code for the any character element.


visit

public void visit(CharLiteral l)
Generate code for the specified character literal.


visit

public void visit(CharClass c)
Generate code for the specified character class.


visit

public void visit(StringLiteral l)
Generate code for the specified literal.


visit

public void visit(CharSwitch s)
Generate code for the specified character switch.


visit

public void visit(NodeMarker m)
Generate code for the specified node marker.


action

protected void action(Action a)
Actually emit code for the specified action.


visit

public void visit(Action a)
Generate code for the specified action.


visit

public void visit(ParserAction pa)
Generate code for the specified parser action.


visit

public void visit(ParseTreeNode n)
Generate code for the specified parse tree node.


visit

public void visit(NullLiteral l)
Generate code for the specified null literal.


visit

public void visit(NullValue v)
Generate code for the specified null value.


emitDifference

protected void emitDifference()
Emit code for determining the textual different.


visit

public void visit(StringValue v)
Generate code for the specified string value.


visit

public void visit(TokenValue v)
Generate code for the specified token value.


var

protected java.lang.String var(Binding b)
Convert a binding into the corresponding variable name. If the specified binding is for a synthetic variable and the bound element is a null literal, this method returns "null" to inline the null value. Otherwise, it returns the binding's name.

Parameters:
b - The binding.
Returns:
The corresponding variable name.

visit

public void visit(BindingValue v)
Generate code for the specified binding value.


visit

public void visit(EmptyListValue v)
Generate code for the specified empty list value.


visit

public void visit(ProperListValue v)
Generate code for the specified proper list value.


visit

public void visit(ActionBaseValue v)
Generate code for the specified action base value.


numberOfChildren

protected int numberOfChildren(int base,
                               java.util.List<Binding> children)
Calculate the number of a generic node's children. This method returns the fixed number of children if none of the children has a list value, Integer.MAX_VALUE if any of the children has a non-null list value, and Integer.MIN_VALUE if any of the children has a list value that may be null.

Parameters:
base - The number of children not from the specified list.
children - The list of bindings representing the children.
Returns:
The number of children.

emitNumberOfChildren

protected void emitNumberOfChildren(int base,
                                    java.util.List<Binding> children)
Emit an expression calculating a generic node's number of children.

Parameters:
base - The number of children not from the specified list.
children - The list of bindings representing the children.

emitChildren

protected void emitChildren(java.lang.String first,
                            java.util.List<Binding> children)
Emit an expression adding the children to a generic node.

Parameters:
first - The name of the optional first child.
children - The list of children.

emitFactoryName

protected void emitFactoryName()
Emit the class name of the class creating generic nodes.


emitFormatting

protected void emitFormatting(java.util.List<Binding> formatting)
Emit a statement adding formatting to a generic node.

Parameters:
formatting - The list of bindings.

emitAction

protected void emitAction(GenericActionValue v)
Emit the action creating a new generic node.

Parameters:
v - The generic action value.

visit

public void visit(GenericNodeValue v)
Generate code for the specified generic node value.


visit

public void visit(GenericActionValue v)
Generate code for the specified generic action value.


visit

public void visit(GenericRecursionValue v)
Generate code for the specified generic recursion value.



Copyright © 2012. All Rights Reserved.