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.TokenTypeNested classes/interfaces inherited from interface com.javacc.parser.Node
Node.VisitorNested classes/interfaces inherited from interface freemarker.template.TemplateModel
freemarker.template.TemplateModel.InvalidExpressionModel, freemarker.template.TemplateModel.JavaNull -
Field Summary
FieldsFields inherited from interface com.javacc.parser.JavaCCConstants
BUF_SIZEFields inherited from interface freemarker.template.TemplateModel
INVALID_EXPRESSION, JAVA_NULL, NOTHINGFields inherited from interface freemarker.template.TemplateScalarModel
EMPTY_STRING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidinserts a child Node at a specific index, displacing the nodes after the index by 1.voidappends a child node to this Nodechildren()voidRemove all the child nodesfreemarker.template.TemplateModelintgetChild(int i) intfreemarker.template.TemplateSequenceModelintprotected Stringprotected Stringfreemarker.template.TemplateNodeModelbooleanhasKeyWord(String keyWord) booleanisEmpty()booleanvoidremoveChild(int i) Remove the node at index i.voidsetBeginOffset(int beginOffset) Set the offset where the token begins, expressed in code units.voidReplace 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.voidvoidsetTokenSource(JavaCCLexer tokenSource) voidsetUnparsed(boolean unparsed) Mark whether this Node is unparsed, i.e.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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
-
Field Details
-
parent
the parent node -
children
the child nodes
-
-
Constructor Details
-
BaseNode
public BaseNode()
-
-
Method Details
-
get
public freemarker.template.TemplateModel get(String key) throws freemarker.template.TemplateModelException - Specified by:
getin interfacefreemarker.template.TemplateHashModel- Throws:
freemarker.template.TemplateModelException
-
getGrammar
- Specified by:
getGrammarin interfaceNode
-
setGrammar
- Specified by:
setGrammarin interfaceNode
-
getSimpleName
-
getInnerText
-
prepend
-
getAsString
- Specified by:
getAsStringin interfacefreemarker.template.TemplateScalarModel
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfacefreemarker.template.TemplateHashModel
-
hasKeyWord
-
getLiteralText
-
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
- Specified by:
setTokenSourcein interfaceNode
-
setListClass
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
-
getParent
-
addChild
Description copied from interface:Nodeappends a child node to this Node -
addChild
Description copied from interface:Nodeinserts a child Node at a specific index, displacing the nodes after the index by 1. -
getChild
-
setChild
Description copied from interface:NodeReplace the node at index i -
removeChild
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
-
children
-
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
- Specified by:
getNodeNamein interfacefreemarker.template.TemplateNodeModel
-
getNodeType
- Specified by:
getNodeTypein interfacefreemarker.template.TemplateNodeModel
-
getNodeNamespace
- Specified by:
getNodeNamespacein interfacefreemarker.template.TemplateNodeModel
-
toString
-