Package com.javacc.parser
Class BaseNode
- java.lang.Object
-
- com.javacc.parser.BaseNode
-
- All Implemented Interfaces:
JavaCCConstants,Node,freemarker.template.TemplateHashModel,freemarker.template.TemplateModel,freemarker.template.TemplateNodeModel,freemarker.template.TemplateScalarModel,Comparable<Node>
- Direct Known Subclasses:
AdditiveExpression,AllocationExpression,AndExpression,AnnotationMethodDeclaration,AnnotationTypeBody,AnnotationTypeDeclaration,AnnotationTypeMemberDeclaration,ArrayAccess,ArrayDimsAndInits,ArrayInitializer,AssignmentExpression,BlockStatement,BNFProduction,CharacterRange,ClassDeclaration,ClassicCaseStatement,ClassicSwitchLabel,ClassicSwitchStatement,ClassLiteral,ClassOrInterfaceBody,CodeInjection,CodeInjection2,CompilationUnit,ConditionalAndExpression,ConditionalOrExpression,ConstructorDeclaration,DefaultValue,DiamondOperator,DotName,DotSuper,DotThis,EmptyDeclaration,EnumBody,EnumConstant,EnumDeclaration,EqualityExpression,ExceptionType,ExclusiveOrExpression,Expansion,ExpansionUnit,ExplicitConstructorInvocation,ExtendsList,FieldDeclaration,FinallyBlock,ForInit,FormalParameter,FormalParameters,Grammar,GrammarFile,GrammarInclusion,ImplementsList,ImportDeclaration,InclusiveOrExpression,Initializer,InstanceOfExpression,InterfaceDeclaration,InvocationArguments,Label,LambdaExpression,LambdaLHS,LambdaParameter,LambdaParameters,LexicalStateSwitch,LiteralExpression,LocalVariableDeclaration,Lookahead,LookBehind,MarkerAnnotation,MemberValue,MemberValueArrayInitializer,MemberValuePair,MemberValuePairs,MethodCall,MethodDeclaration,MethodReference,MultiplicativeExpression,Name,NewCaseStatement,NewSwitchLabel,NewSwitchStatement,NormalAnnotation,ObjectCastExpression,ObjectType,Options,PackageDeclaration,Parentheses,ParserCodeDecls,PermitsList,PostfixExpression,PreDecrementExpression,PreIncrementExpression,PrimitiveArrayType,PrimitiveCastExpression,PrimitiveType,RecordBody,RecordComponent,RecordDeclaration,RecordHeader,ReferenceType,RegexpSpec,RelationalExpression,ReturnType,scan,Setting,ShiftExpression,SingleMemberAnnotation,Statement,StatementExpression,StatementExpressionList,SwitchExpression,TernaryExpression,ThrowsList,TokenActivation,TokenManagerDecls,TokenProduction,TreeBuildingAnnotation,TypeArgument,TypeArguments,TypeBound,TypeParameter,TypeParameters,UnaryExpression,UnaryExpressionNotPlusMinus,VariableDeclarator,VariableDeclaratorId,VariableInitializer,WildcardBounds
public class BaseNode extends Object implements Node, freemarker.template.TemplateHashModel, JavaCCConstants
The base concrete class for non-terminal Nodes
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.javacc.parser.JavaCCConstants
JavaCCConstants.LexicalState, JavaCCConstants.TokenType
-
Nested classes/interfaces inherited from interface com.javacc.parser.Node
Node.Visitor
-
-
Field Summary
Fields Modifier and Type Field Description protected List<Node>childrenthe child nodesprotected Nodeparentthe parent node-
Fields inherited from interface com.javacc.parser.JavaCCConstants
BUF_SIZE
-
-
Constructor Summary
Constructors Constructor Description BaseNode()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(int i, Node n)inserts a child Node at a specific index, displacing the nodes after the index by 1.voidaddChild(Node n)appends a child node to this NodeList<Node>children()voidclearChildren()Remove all the child nodesfreemarker.template.TemplateModelget(String key)StringgetAsString()intgetBeginOffset()NodegetChild(int i)intgetChildCount()freemarker.template.TemplateSequenceModelgetChildNodes()intgetEndOffset()GrammargetGrammar()protected StringgetInnerText()protected StringgetLiteralText()StringgetNodeName()StringgetNodeNamespace()StringgetNodeType()NodegetParent()freemarker.template.TemplateNodeModelgetParentNode()StringgetSimpleName()JavaCCLexergetTokenSource()booleanhasKeyWord(String keyWord)booleanisEmpty()booleanisUnparsed()voidprepend(Node n)NoderemoveChild(int i)Remove the node at index i.voidsetBeginOffset(int beginOffset)Set the offset where the token begins, expressed in code units.voidsetChild(int i, Node n)Replace the node at index ivoidsetEndOffset(int endOffset)Set the offset where the token ends, actually the location where the very next token should begin.voidsetGrammar(Grammar grammar)static voidsetListClass(Class<? extends List> listClass)Sets the List class that is used to store child nodes.voidsetParent(Node n)voidsetTokenSource(JavaCCLexer tokenSource)voidsetUnparsed(boolean unparsed)Mark whether this Node is unparsed, i.e.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.javacc.parser.Node
appendChild, children, childrenOfType, close, compareTo, copyLocationInfo, copyLocationInfo, descendants, descendants, descendants, descendants, descendantsOfType, dump, dump, firstAncestorOfType, firstChildOfType, firstChildOfType, firstChildOfType, firstDescendantOfType, firstDescendantOfType, getAllTokens, getBeginColumn, getBeginLine, getEndColumn, getEndLine, getFirstChild, getFirstToken, getInputSource, getLastChild, getLastToken, getLocation, getRealTokens, getRoot, getSource, getTokenType, hasChildNodes, indexOf, iterator, nextSibling, open, prependChild, previousSibling, removeChild, replace, replaceChild
-
-
-
-
Method Detail
-
get
public freemarker.template.TemplateModel get(String key) throws freemarker.template.TemplateModelException
- Specified by:
getin interfacefreemarker.template.TemplateHashModel- Throws:
freemarker.template.TemplateModelException
-
getGrammar
public Grammar getGrammar()
- Specified by:
getGrammarin interfaceNode
-
setGrammar
public void setGrammar(Grammar grammar)
- Specified by:
setGrammarin interfaceNode
-
getSimpleName
public String getSimpleName()
-
getInnerText
protected String getInnerText()
-
prepend
public void prepend(Node n)
-
getAsString
public String getAsString()
- Specified by:
getAsStringin interfacefreemarker.template.TemplateScalarModel
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfacefreemarker.template.TemplateHashModel
-
hasKeyWord
public boolean hasKeyWord(String keyWord)
-
getLiteralText
protected String getLiteralText()
-
getTokenSource
public JavaCCLexer getTokenSource()
- Specified by:
getTokenSourcein interfaceNode- Returns:
- the #JavaCCLexer from which this Node object originated. There is no guarantee that this doesn't return null. Most likely that would simply be because you constructed the Node yourself, i.e. it didn't really come about via the parsing/tokenizing machinery.
-
setTokenSource
public void setTokenSource(JavaCCLexer tokenSource)
- Specified by:
setTokenSourcein interfaceNode
-
setListClass
public static void setListClass(Class<? extends List> listClass)
Sets the List class that is used to store child nodes. By default, this is java.util.ArrayList. There is probably very little reason to ever use anything else, though you could use this method to replace this with LinkedList or your own java.util.List implementation even.- Parameters:
listClass- the #java.util.List implementation to use internally for the child nodes. By default #java.util.ArrayList is used.
-
isUnparsed
public boolean isUnparsed()
- Specified by:
isUnparsedin interfaceNode- Returns:
- whether this Node was created by regular operations of the parsing machinery.
-
setUnparsed
public void setUnparsed(boolean unparsed)
Description copied from interface:NodeMark whether this Node is unparsed, i.e. not the result of normal parsing- Specified by:
setUnparsedin interfaceNode- Parameters:
unparsed- whether to set the Node as unparsed or parsed.
-
setParent
public void setParent(Node n)
-
getParent
public Node getParent()
-
addChild
public void addChild(Node n)
Description copied from interface:Nodeappends a child node to this Node
-
addChild
public void addChild(int i, Node n)Description copied from interface:Nodeinserts a child Node at a specific index, displacing the nodes after the index by 1.
-
getChild
public Node getChild(int i)
-
setChild
public void setChild(int i, Node n)Description copied from interface:NodeReplace the node at index i
-
removeChild
public Node removeChild(int i)
Description copied from interface:NodeRemove the node at index i. Any Nodes after i are shifted to the left.- Specified by:
removeChildin interfaceNode- Parameters:
i- the index at which to remove- Returns:
- the removed Node
-
clearChildren
public void clearChildren()
Description copied from interface:NodeRemove all the child nodes- Specified by:
clearChildrenin interfaceNode
-
getChildCount
public int getChildCount()
- Specified by:
getChildCountin interfaceNode- Returns:
- the number of child nodes
-
getBeginOffset
public int getBeginOffset()
- Specified by:
getBeginOffsetin interfaceNode- Returns:
- the offset in the input source where the token begins, expressed in code units.
-
setBeginOffset
public void setBeginOffset(int beginOffset)
Description copied from interface:NodeSet the offset where the token begins, expressed in code units.- Specified by:
setBeginOffsetin interfaceNode
-
getEndOffset
public int getEndOffset()
- Specified by:
getEndOffsetin interfaceNode- Returns:
- the offset in the input source where the token ends, expressed in code units. This is actually the offset where the very next token would begin.
-
setEndOffset
public void setEndOffset(int endOffset)
Description copied from interface:NodeSet the offset where the token ends, actually the location where the very next token should begin.- Specified by:
setEndOffsetin interfaceNode
-
getChildNodes
public freemarker.template.TemplateSequenceModel getChildNodes()
- Specified by:
getChildNodesin interfacefreemarker.template.TemplateNodeModel
-
getParentNode
public freemarker.template.TemplateNodeModel getParentNode()
- Specified by:
getParentNodein interfacefreemarker.template.TemplateNodeModel
-
getNodeName
public String getNodeName()
- Specified by:
getNodeNamein interfacefreemarker.template.TemplateNodeModel
-
getNodeType
public String getNodeType()
- Specified by:
getNodeTypein interfacefreemarker.template.TemplateNodeModel
-
getNodeNamespace
public String getNodeNamespace()
- Specified by:
getNodeNamespacein interfacefreemarker.template.TemplateNodeModel
-
-