Package com.javacc.parser
Class JavaCCParser
- java.lang.Object
-
- com.javacc.parser.JavaCCParser
-
- All Implemented Interfaces:
JavaCCConstants
public class JavaCCParser extends Object implements JavaCCConstants
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.javacc.parser.JavaCCConstants
JavaCCConstants.LexicalState, JavaCCConstants.TokenType
-
-
Field Summary
Fields Modifier and Type Field Description JavaCCLexertoken_sourceGenerated Lexer.-
Fields inherited from interface com.javacc.parser.JavaCCConstants
BUF_SIZE
-
-
Constructor Summary
Constructors Constructor Description JavaCCParser(Grammar grammar, String inputSource, CharSequence content)JavaCCParser(Grammar grammar, Path path, Map<String,String> definedSymbols)JavaCCParser(JavaCCLexer lexer)Constructor with user supplied Lexer.JavaCCParser(InputStream stream)JavaCCParser(Reader reader)JavaCCParser(CharSequence content)JavaCCParser(String inputSource, CharSequence content)JavaCCParser(String inputSource, Path path)JavaCCParser(Path path)
-
Method Summary
-
-
-
Field Detail
-
token_source
public JavaCCLexer token_source
Generated Lexer.
-
-
Constructor Detail
-
JavaCCParser
public JavaCCParser(Grammar grammar, Path path, Map<String,String> definedSymbols) throws IOException
- Throws:
IOException
-
JavaCCParser
public JavaCCParser(Grammar grammar, String inputSource, CharSequence content)
-
JavaCCParser
public JavaCCParser(String inputSource, CharSequence content)
-
JavaCCParser
public JavaCCParser(CharSequence content)
-
JavaCCParser
public JavaCCParser(String inputSource, Path path) throws IOException
- Parameters:
inputSource- just the name of the input source (typically the filename) that will be used in error messages and so on.path- The location (typically the filename) from which to get the input to parse- Throws:
IOException
-
JavaCCParser
public JavaCCParser(Path path) throws IOException
- Parameters:
path- The location (typically the filename) from which to get the input to parse- Throws:
IOException
-
JavaCCParser
public JavaCCParser(InputStream stream)
-
JavaCCParser
public JavaCCParser(Reader reader)
-
JavaCCParser
public JavaCCParser(JavaCCLexer lexer)
Constructor with user supplied Lexer.
-
-
Method Detail
-
parseJavaFile
public static CompilationUnit parseJavaFile(String inputSource, CharSequence content) throws ParseException
- Throws:
ParseException
-
parseJavaFile
public static CompilationUnit parseJavaFile(Path path) throws ParseException, IOException
- Throws:
ParseExceptionIOException
-
getGrammar
public Grammar getGrammar()
-
openNodeScopeHook
public void openNodeScopeHook(Node n)
-
setEnterIncludes
public void setEnterIncludes(boolean enterIncludes)
-
cancel
public void cancel()
-
isCancelled
public boolean isCancelled()
-
setInputSource
public void setInputSource(String inputSource)
-
getNextToken
public final Token getNextToken()
- Returns:
- the next Token off the stream. This is the same as #getToken(1)
-
getToken
public final Token getToken(int index)
- Parameters:
index- how many tokens to look ahead- Returns:
- the specific regular (i.e. parsed) Token index ahead/behind in the stream. If we are in a lookahead, it looks ahead from the currentLookaheadToken Otherwise, it is the lastConsumedToken. If you pass in a negative number it goes backward.
-
CompilationUnit
public final CompilationUnit CompilationUnit() throws ParseException
- Throws:
ParseException
-
PackageDeclaration
public final void PackageDeclaration() throws ParseException- Throws:
ParseException
-
ImportDeclaration
public final void ImportDeclaration() throws ParseException- Throws:
ParseException
-
Modifiers
public final void Modifiers() throws ParseException- Throws:
ParseException
-
TypeDeclaration
public final void TypeDeclaration() throws ParseException- Throws:
ParseException
-
EmptyDeclaration
public final void EmptyDeclaration() throws ParseException- Throws:
ParseException
-
TypeIdentifier
public final void TypeIdentifier() throws ParseException- Throws:
ParseException
-
ClassDeclaration
public final void ClassDeclaration() throws ParseException- Throws:
ParseException
-
InterfaceDeclaration
public final void InterfaceDeclaration() throws ParseException- Throws:
ParseException
-
PermitsList
public final void PermitsList() throws ParseException- Throws:
ParseException
-
ExtendsList
public final void ExtendsList() throws ParseException- Throws:
ParseException
-
ImplementsList
public final void ImplementsList() throws ParseException- Throws:
ParseException
-
EnumDeclaration
public final void EnumDeclaration() throws ParseException- Throws:
ParseException
-
EnumBody
public final void EnumBody() throws ParseException- Throws:
ParseException
-
RecordDeclaration
public final void RecordDeclaration() throws ParseException- Throws:
ParseException
-
RecordHeader
public final void RecordHeader() throws ParseException- Throws:
ParseException
-
RecordComponent
public final void RecordComponent() throws ParseException- Throws:
ParseException
-
RecordBody
public final void RecordBody() throws ParseException- Throws:
ParseException
-
CompactConstructorDeclaration
public final void CompactConstructorDeclaration() throws ParseException- Throws:
ParseException
-
EnumConstant
public final void EnumConstant() throws ParseException- Throws:
ParseException
-
TypeParameters
public final void TypeParameters() throws ParseException- Throws:
ParseException
-
TypeParameter
public final void TypeParameter() throws ParseException- Throws:
ParseException
-
TypeBound
public final void TypeBound() throws ParseException- Throws:
ParseException
-
ClassOrInterfaceBody
public final void ClassOrInterfaceBody() throws ParseException- Throws:
ParseException
-
ClassOrInterfaceBodyDeclaration
public final void ClassOrInterfaceBodyDeclaration() throws ParseException- Throws:
ParseException
-
FieldDeclaration
public final void FieldDeclaration() throws ParseException- Throws:
ParseException
-
VariableDeclarator
public final void VariableDeclarator() throws ParseException- Throws:
ParseException
-
VariableDeclaratorId
public final void VariableDeclaratorId() throws ParseException- Throws:
ParseException
-
VariableInitializer
public final void VariableInitializer() throws ParseException- Throws:
ParseException
-
ArrayInitializer
public final void ArrayInitializer() throws ParseException- Throws:
ParseException
-
MethodDeclaration
public final MethodDeclaration MethodDeclaration() throws ParseException
- Throws:
ParseException
-
FormalParameters
public final void FormalParameters() throws ParseException- Throws:
ParseException
-
FormalParameter
public final void FormalParameter() throws ParseException- Throws:
ParseException
-
ConstructorDeclaration
public final void ConstructorDeclaration() throws ParseException- Throws:
ParseException
-
ExplicitConstructorInvocation
public final void ExplicitConstructorInvocation() throws ParseException- Throws:
ParseException
-
Initializer
public final void Initializer() throws ParseException- Throws:
ParseException
-
Type
public final void Type() throws ParseException- Throws:
ParseException
-
ReferenceType
public final void ReferenceType() throws ParseException- Throws:
ParseException
-
ObjectType
public final void ObjectType() throws ParseException- Throws:
ParseException
-
DiamondOperator
public final void DiamondOperator() throws ParseException- Throws:
ParseException
-
PossiblyEmptyTypeArguments
public final void PossiblyEmptyTypeArguments() throws ParseException- Throws:
ParseException
-
TypeArguments
public final void TypeArguments() throws ParseException- Throws:
ParseException
-
TypeArgument
public final void TypeArgument() throws ParseException- Throws:
ParseException
-
WildcardBounds
public final void WildcardBounds() throws ParseException- Throws:
ParseException
-
PrimitiveType
public final void PrimitiveType() throws ParseException- Throws:
ParseException
-
PrimitiveArrayType
public final void PrimitiveArrayType() throws ParseException- Throws:
ParseException
-
ReturnType
public final void ReturnType() throws ParseException- Throws:
ParseException
-
Name
public final void Name() throws ParseException- Throws:
ParseException
-
ThrowsList
public final void ThrowsList() throws ParseException- Throws:
ParseException
-
ExceptionType
public final void ExceptionType() throws ParseException- Throws:
ParseException
-
Expression
public final Expression Expression() throws ParseException
- Throws:
ParseException
-
AssignmentExpression
public final void AssignmentExpression() throws ParseException- Throws:
ParseException
-
AssignmentOperator
public final void AssignmentOperator() throws ParseException- Throws:
ParseException
-
TernaryExpression
public final void TernaryExpression() throws ParseException- Throws:
ParseException
-
ConditionalOrExpression
public final void ConditionalOrExpression() throws ParseException- Throws:
ParseException
-
ConditionalAndExpression
public final void ConditionalAndExpression() throws ParseException- Throws:
ParseException
-
InclusiveOrExpression
public final void InclusiveOrExpression() throws ParseException- Throws:
ParseException
-
ExclusiveOrExpression
public final void ExclusiveOrExpression() throws ParseException- Throws:
ParseException
-
AndExpression
public final void AndExpression() throws ParseException- Throws:
ParseException
-
EqualityExpression
public final void EqualityExpression() throws ParseException- Throws:
ParseException
-
InstanceOfExpression
public final void InstanceOfExpression() throws ParseException- Throws:
ParseException
-
RelationalExpression
public final void RelationalExpression() throws ParseException- Throws:
ParseException
-
ShiftExpression
public final void ShiftExpression() throws ParseException- Throws:
ParseException
-
AdditiveExpression
public final void AdditiveExpression() throws ParseException- Throws:
ParseException
-
MultiplicativeExpression
public final void MultiplicativeExpression() throws ParseException- Throws:
ParseException
-
UnaryExpression
public final void UnaryExpression() throws ParseException- Throws:
ParseException
-
PreIncrementExpression
public final void PreIncrementExpression() throws ParseException- Throws:
ParseException
-
PreDecrementExpression
public final void PreDecrementExpression() throws ParseException- Throws:
ParseException
-
UnaryExpressionNotPlusMinus
public final void UnaryExpressionNotPlusMinus() throws ParseException- Throws:
ParseException
-
PostfixExpression
public final void PostfixExpression() throws ParseException- Throws:
ParseException
-
SwitchExpression
public final void SwitchExpression() throws ParseException- Throws:
ParseException
-
PrimitiveCastExpression
public final void PrimitiveCastExpression() throws ParseException- Throws:
ParseException
-
ObjectCastExpression
public final void ObjectCastExpression() throws ParseException- Throws:
ParseException
-
PrimaryExpression
public final void PrimaryExpression() throws ParseException- Throws:
ParseException
-
LiteralExpression
public final void LiteralExpression() throws ParseException- Throws:
ParseException
-
Parentheses
public final void Parentheses() throws ParseException- Throws:
ParseException
-
ClassLiteral
public final void ClassLiteral() throws ParseException- Throws:
ParseException
-
MethodReference
public final void MethodReference() throws ParseException- Throws:
ParseException
-
Literal
public final void Literal() throws ParseException- Throws:
ParseException
-
InvocationArguments
public final void InvocationArguments() throws ParseException- Throws:
ParseException
-
AllocationExpression
public final void AllocationExpression() throws ParseException- Throws:
ParseException
-
ArrayDimsAndInits
public final void ArrayDimsAndInits() throws ParseException- Throws:
ParseException
-
Label
public final void Label() throws ParseException- Throws:
ParseException
-
Statement
public final void Statement() throws ParseException- Throws:
ParseException
-
TryStatement
public final void TryStatement() throws ParseException- Throws:
ParseException
-
AssertStatement
public final void AssertStatement() throws ParseException- Throws:
ParseException
-
Block
public final void Block() throws ParseException- Throws:
ParseException
-
BlockStatement
public final void BlockStatement() throws ParseException- Throws:
ParseException
-
LocalVariableDeclaration
public final void LocalVariableDeclaration() throws ParseException- Throws:
ParseException
-
NoVarDeclaration
public final void NoVarDeclaration() throws ParseException- Throws:
ParseException
-
VarDeclaration
public final void VarDeclaration() throws ParseException- Throws:
ParseException
-
EmptyStatement
public final void EmptyStatement() throws ParseException- Throws:
ParseException
-
StatementExpression
public final void StatementExpression() throws ParseException- Throws:
ParseException
-
ExpressionStatement
public final void ExpressionStatement() throws ParseException- Throws:
ParseException
-
SwitchStatement
public final void SwitchStatement() throws ParseException- Throws:
ParseException
-
ClassicSwitchStatement
public final void ClassicSwitchStatement() throws ParseException- Throws:
ParseException
-
ClassicSwitchLabel
public final void ClassicSwitchLabel() throws ParseException- Throws:
ParseException
-
ClassicCaseStatement
public final void ClassicCaseStatement() throws ParseException- Throws:
ParseException
-
NewSwitchStatement
public final void NewSwitchStatement() throws ParseException- Throws:
ParseException
-
NewSwitchLabel
public final void NewSwitchLabel() throws ParseException- Throws:
ParseException
-
NewCaseStatement
public final void NewCaseStatement() throws ParseException- Throws:
ParseException
-
IfStatement
public final void IfStatement() throws ParseException- Throws:
ParseException
-
WhileStatement
public final void WhileStatement() throws ParseException- Throws:
ParseException
-
DoStatement
public final void DoStatement() throws ParseException- Throws:
ParseException
-
ForStatement
public final void ForStatement() throws ParseException- Throws:
ParseException
-
BasicForStatement
public final void BasicForStatement() throws ParseException- Throws:
ParseException
-
EnhancedForStatement
public final void EnhancedForStatement() throws ParseException- Throws:
ParseException
-
ForInit
public final void ForInit() throws ParseException- Throws:
ParseException
-
StatementExpressionList
public final void StatementExpressionList() throws ParseException- Throws:
ParseException
-
BreakStatement
public final void BreakStatement() throws ParseException- Throws:
ParseException
-
YieldStatement
public final void YieldStatement() throws ParseException- Throws:
ParseException
-
ContinueStatement
public final void ContinueStatement() throws ParseException- Throws:
ParseException
-
ReturnStatement
public final void ReturnStatement() throws ParseException- Throws:
ParseException
-
ThrowStatement
public final void ThrowStatement() throws ParseException- Throws:
ParseException
-
SynchronizedStatement
public final void SynchronizedStatement() throws ParseException- Throws:
ParseException
-
ClassicTryStatement
public final void ClassicTryStatement() throws ParseException- Throws:
ParseException
-
TryWithResources
public final void TryWithResources() throws ParseException- Throws:
ParseException
-
CatchBlock
public final void CatchBlock() throws ParseException- Throws:
ParseException
-
FinallyBlock
public final void FinallyBlock() throws ParseException- Throws:
ParseException
-
Annotation
public final void Annotation() throws ParseException- Throws:
ParseException
-
NormalAnnotation
public final void NormalAnnotation() throws ParseException- Throws:
ParseException
-
MarkerAnnotation
public final void MarkerAnnotation() throws ParseException- Throws:
ParseException
-
SingleMemberAnnotation
public final void SingleMemberAnnotation() throws ParseException- Throws:
ParseException
-
MemberValuePairs
public final void MemberValuePairs() throws ParseException- Throws:
ParseException
-
MemberValuePair
public final void MemberValuePair() throws ParseException- Throws:
ParseException
-
MemberValue
public final void MemberValue() throws ParseException- Throws:
ParseException
-
MemberValueArrayInitializer
public final void MemberValueArrayInitializer() throws ParseException- Throws:
ParseException
-
AnnotationTypeDeclaration
public final void AnnotationTypeDeclaration() throws ParseException- Throws:
ParseException
-
AnnotationTypeBody
public final void AnnotationTypeBody() throws ParseException- Throws:
ParseException
-
AnnotationMethodDeclaration
public final void AnnotationMethodDeclaration() throws ParseException- Throws:
ParseException
-
AnnotationTypeMemberDeclaration
public final void AnnotationTypeMemberDeclaration() throws ParseException- Throws:
ParseException
-
DefaultValue
public final void DefaultValue() throws ParseException- Throws:
ParseException
-
LambdaExpression
public final void LambdaExpression() throws ParseException- Throws:
ParseException
-
LambdaLHS
public final void LambdaLHS() throws ParseException- Throws:
ParseException
-
SimpleLambdaLHS
public final void SimpleLambdaLHS() throws ParseException- Throws:
ParseException
-
LambdaParameters
public final void LambdaParameters() throws ParseException- Throws:
ParseException
-
LambdaParameter
public final void LambdaParameter() throws ParseException- Throws:
ParseException
-
Root
public final GrammarFile Root() throws ParseException, IOException
- Throws:
ParseExceptionIOException
-
ParserCodeDecls
public final void ParserCodeDecls() throws ParseException- Throws:
ParseException
-
GrammarInclusion
public final void GrammarInclusion() throws ParseException, IOException- Throws:
ParseExceptionIOException
-
CodeInjection
public final void CodeInjection() throws ParseException- Throws:
ParseException
-
CodeInjection2
public final void CodeInjection2() throws ParseException- Throws:
ParseException
-
Options
public final void Options() throws ParseException- Throws:
ParseException
-
OptionsBlock
public final void OptionsBlock() throws ParseException- Throws:
ParseException
-
Setting
public final void Setting(Map<String,Object> settings) throws ParseException
- Throws:
ParseException
-
BNFProduction
public final void BNFProduction() throws ParseException- Throws:
ParseException
-
TreeNodeDescriptor
public final void TreeNodeDescriptor() throws ParseException- Throws:
ParseException
-
TokenProduction
public final void TokenProduction() throws ParseException- Throws:
ParseException
-
TokenManagerDecls
public final void TokenManagerDecls() throws ParseException- Throws:
ParseException
-
RegexpSpec
public final void RegexpSpec(TokenProduction p, String tokenClassName) throws ParseException
- Throws:
ParseException
-
ExpansionChoice
public final void ExpansionChoice() throws ParseException- Throws:
ParseException
-
ExpansionWithParentheses
public final void ExpansionWithParentheses() throws ParseException- Throws:
ParseException
-
ExpansionSequence
public final void ExpansionSequence() throws ParseException- Throws:
ParseException
-
Lookahead
public final Lookahead Lookahead() throws ParseException
- Throws:
ParseException
-
Assertion
public final void Assertion() throws ParseException- Throws:
ParseException
-
ScanAhead
public final void ScanAhead() throws ParseException- Throws:
ParseException
-
LookBehind
public final void LookBehind() throws ParseException- Throws:
ParseException
-
LookBehindForward
public final void LookBehindForward() throws ParseException- Throws:
ParseException
-
LookBehindBackward
public final void LookBehindBackward() throws ParseException- Throws:
ParseException
-
LegacyLookahead
public final void LegacyLookahead() throws ParseException- Throws:
ParseException
-
ExpansionUnit
public final Expansion ExpansionUnit() throws ParseException
- Throws:
ParseException
-
NonTerminal
public final NonTerminal NonTerminal() throws ParseException
- Throws:
ParseException
-
UpToHere
public final void UpToHere(Expansion exp) throws ParseException
- Throws:
ParseException
-
ZeroOrMore
public final void ZeroOrMore() throws ParseException- Throws:
ParseException
-
OneOrMore
public final void OneOrMore() throws ParseException- Throws:
ParseException
-
ZeroOrOne
public final void ZeroOrOne() throws ParseException- Throws:
ParseException
-
AttemptBlock
public final void AttemptBlock() throws ParseException- Throws:
ParseException
-
UncacheTokens
public final void UncacheTokens() throws ParseException- Throws:
ParseException
-
Failure
public final void Failure() throws ParseException- Throws:
ParseException
-
LexicalStateSwitch
public final void LexicalStateSwitch() throws ParseException- Throws:
ParseException
-
TokenActivation
public final void TokenActivation() throws ParseException- Throws:
ParseException
-
TryBlock
public final void TryBlock() throws ParseException- Throws:
ParseException
-
RegexpExpansion
public final void RegexpExpansion() throws ParseException- Throws:
ParseException
-
InPlaceRegexp
public final void InPlaceRegexp() throws ParseException- Throws:
ParseException
-
RegexpStringLiteral
public final void RegexpStringLiteral() throws ParseException- Throws:
ParseException
-
RegexpRef
public final RegexpRef RegexpRef() throws ParseException
- Throws:
ParseException
-
EndOfFile
public final void EndOfFile() throws ParseException- Throws:
ParseException
-
RegexpChoice
public final void RegexpChoice() throws ParseException- Throws:
ParseException
-
RegexpChoiceInParen
public final void RegexpChoiceInParen() throws ParseException- Throws:
ParseException
-
RegexpSequence
public final void RegexpSequence() throws ParseException- Throws:
ParseException
-
RepeatedRegexp
public final void RepeatedRegexp() throws ParseException- Throws:
ParseException
-
CharacterList
public final void CharacterList() throws ParseException- Throws:
ParseException
-
CharacterRange
public final void CharacterRange() throws ParseException- Throws:
ParseException
-
isParserTolerant
public boolean isParserTolerant()
-
setParserTolerant
public void setParserTolerant(boolean tolerantParsing)
-
isTreeBuildingEnabled
public boolean isTreeBuildingEnabled()
-
setUnparsedTokensAreNodes
public void setUnparsedTokensAreNodes(boolean unparsedTokensAreNodes)
-
setTokensAreNodes
public void setTokensAreNodes(boolean tokensAreNodes)
-
rootNode
public Node rootNode()
- Returns:
- the root node of the AST. It only makes sense to call this after a successful parse.
-
pushNode
public void pushNode(Node n)
push a node onto the top of the node stack- Parameters:
n- the node to push
-
popNode
public Node popNode()
- Returns:
- the node on the top of the stack, and remove it from the stack.
-
peekNode
public Node peekNode()
- Returns:
- the node currently on the top of the tree-building stack.
-
pokeNode
public void pokeNode(Node n)
Puts the node on the top of the stack. However, unlike pushNode() it replaces the node that is currently on the top of the stack. This is effectively equivalent to popNode() followed by pushNode(n)- Parameters:
n- the node to poke
-
nodeArity
public int nodeArity()
- Returns:
- the number of Nodes on the tree-building stack in the current node scope.
-
getBuildTree
public boolean getBuildTree()
-
setBuildTree
public void setBuildTree(boolean buildTree)
-
-