Package com.javacc
Class Grammar
java.lang.Object
com.javacc.parser.BaseNode
com.javacc.Grammar
- All Implemented Interfaces:
JavaCCConstants,Node,freemarker.template.TemplateHashModel,freemarker.template.TemplateModel,freemarker.template.TemplateNodeModel,freemarker.template.TemplateScalarModel,Comparable<Node>
This object is the root Node of the data structure that contains all the
information regarding a JavaCC processing job.
-
Nested Class Summary
Nested ClassesNested 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
Fields 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 TypeMethodDescriptionvoidvoidvoidvoidaddInplaceRegexp(RegularExpression regexp) voidaddLexicalState(String name) Add a new lexical stateaddNamedToken(String name, RegularExpression regexp) voidaddNodeType(String productionName, String nodeName) voidaddTokenName(int index, String name) voidvoidaddWarning(Node location, String warningMessage) voidaddWarning(String warningMessage) classNameFromTokenName(String tokenName) constNameFromClassName(String className) voidvoidvoidgenerateIdentifierPrefix(String basePrefix) voidgenerateUniqueIdentifier(String prefix, Node exp) The list of all TokenProductions from the input file.booleanbooleanintbooleanThe grammar file being processed.booleanintbooleanString[]booleangetNamedToken(String name) This is a symbol table that contains all named tokens (those that are defined with a label).getNodeClassName(String nodeName) booleangetNodePackageName(String nodeName) booleanContains the same entries as "named_tokens_table", but this is an ordered list which is ordered by the order of appearance in the input file.intReturns the parse error count during grammar parsing.booleangetProductionByName(String name) A symbol table of all grammar productions.intReturns the semantic error count during grammar parsing.booleanintgetTokenName(int index) A mapping of ordinal values (represented as objects of type "Integer") to the corresponding labels (of type "String").booleanbooleanbooleanbooleanbooleangetUtils()intReturns the warning count during grammar parsing.booleanhasTokenOfName(String name) booleanbooleanbooleanisQuiet()booleannodeIsAbstract(String nodeName) booleannodeIsInterface(String nodeName) static StringvoidsetDefaultLexicalState(String defaultLexicalState) voidsetFilename(Path filename) voidsetIgnoreCase(boolean ignoreCase) voidsetParserClassName(String parserClassName) voidsetParserCode(CompilationUnit parserCode) voidsetParserPackage(String parserPackage) voidsetSettings(Map<String, Object> settings) Methods inherited from class com.javacc.parser.BaseNode
addChild, addChild, children, clearChildren, get, getAsString, getBeginOffset, getChild, getChildCount, getChildNodes, getEndOffset, getGrammar, getInnerText, getLiteralText, getNodeName, getNodeNamespace, getNodeType, getParent, getParentNode, getSimpleName, getTokenSource, hasKeyWord, isEmpty, isUnparsed, prepend, removeChild, setBeginOffset, setChild, setEndOffset, setGrammar, setListClass, setParent, setTokenSource, setUnparsed, toStringMethods 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
-
Constructor Details
-
Grammar
-
Grammar
public Grammar()
-
-
Method Details
-
isQuiet
public boolean isQuiet() -
getCodeLang
-
getLexicalStates
-
addInplaceRegexp
-
generateIdentifierPrefix
-
generateUniqueIdentifier
-
parse
- Throws:
IOExceptionParseException
-
include
public Node include(List<String> locations, Node includeLocation) throws IOException, ParseException - Throws:
IOExceptionParseException
-
createOutputDir
public void createOutputDir() -
getFilename
The grammar file being processed. -
setFilename
-
generateLexer
public void generateLexer() -
doSanityChecks
public void doSanityChecks() -
generateFiles
public void generateFiles() throws ParseException, IOException, freemarker.template.TemplateException- Throws:
ParseExceptionIOExceptionfreemarker.template.TemplateException
-
getLexerData
-
getConstantsClassName
-
getParserClassName
-
setParserClassName
-
getBaseNodeClassName
-
getLexerClassName
-
getNfaDataClassName
-
getDefaultLexicalState
-
setDefaultLexicalState
-
getInjector
-
getOtherParserCodeDeclarations
-
getParserCodeImports
-
setParserCode
-
setParserPackage
-
getParserProductions
-
getChoicePointExpansions
- Returns:
- a List containing all the expansions that are at a choice point
-
getAssertionExpansions
-
getExpansionsNeedingPredicate
-
getExpansionsNeedingRecoverMethod
-
getLexerTokenHooks
-
getParserTokenHooks
-
getResetTokenHooks
-
getOpenNodeScopeHooks
-
getCloseNodeScopeHooks
-
getCloseNodeHooksByClass
-
getProductionTable
A symbol table of all grammar productions. -
getProductionByName
-
addLexicalState
Add a new lexical state -
getExpansionsForFirstSet
-
getExpansionsForFinalSet
-
getExpansionsForFollowSet
-
getAllTokenProductions
The list of all TokenProductions from the input file. This list includes implicit TokenProductions that are created for uses of regular expressions within BNF productions. -
getAllLookaheads
-
getAllLookBehinds
-
addTokenProduction
-
getNamedToken
This is a symbol table that contains all named tokens (those that are defined with a label). The index to the table is the image of the label and the contents of the table are of type "RegularExpression". -
addNamedToken
-
hasTokenOfName
-
getOrderedNamedTokens
Contains the same entries as "named_tokens_table", but this is an ordered list which is ordered by the order of appearance in the input file. (Actually, the only place where this is used is in generating the XXXConstants.java file) -
getTokenName
A mapping of ordinal values (represented as objects of type "Integer") to the corresponding labels (of type "String"). An entry exists for an ordinal value only if there is a labeled token corresponding to this entry. If there are multiple labels representing the same ordinal value, then only one label is stored. -
classNameFromTokenName
-
constNameFromClassName
-
addTokenName
-
getWarningCount
public int getWarningCount()Returns the warning count during grammar parsing.- Returns:
- the warning count during grammar parsing.
-
getParseErrorCount
public int getParseErrorCount()Returns the parse error count during grammar parsing.- Returns:
- the parse error count during grammar parsing.
-
getSemanticErrorCount
public int getSemanticErrorCount()Returns the semantic error count during grammar parsing.- Returns:
- the semantic error count during grammar parsing.
-
addError
-
addError
-
addWarning
-
addWarning
-
getErrorCount
public int getErrorCount()- Returns:
- the total error count during grammar parsing.
-
getNodeNames
-
getNodePrefix
-
addNodeType
-
nodeIsInterface
-
nodeIsAbstract
-
getNodeClassName
-
getNodePackageName
-
addCodeInjection
-
isInInclude
public boolean isInInclude() -
getParserPackage
-
getParserOutputDirectory
- Throws:
IOException
-
getBaseSourceDirectory
-
getNodeOutputDirectory
- Throws:
IOException
-
getNodePackage
-
getCurrentNodeVariableName
-
removeNonJavaIdentifierPart
-
getTreeBuildingEnabled
public boolean getTreeBuildingEnabled() -
getTreeBuildingDefault
public boolean getTreeBuildingDefault() -
getNodeDefaultVoid
public boolean getNodeDefaultVoid() -
getSmartNodeCreation
public boolean getSmartNodeCreation() -
getTokensAreNodes
public boolean getTokensAreNodes() -
getUnparsedTokensAreNodes
public boolean getUnparsedTokensAreNodes() -
getNodeUsesParser
public boolean getNodeUsesParser() -
getLexerUsesParser
public boolean getLexerUsesParser() -
getFaultTolerant
public boolean getFaultTolerant() -
getEnsureFinalEOL
public boolean getEnsureFinalEOL() -
getMinimalToken
public boolean getMinimalToken() -
getUsePreprocessor
public boolean getUsePreprocessor() -
getPreserveLineEndings
public boolean getPreserveLineEndings() -
getJavaUnicodeEscape
public boolean getJavaUnicodeEscape() -
getCppContinuationLine
public boolean getCppContinuationLine() -
getTabsToSpaces
public int getTabsToSpaces() -
getJdkTarget
public int getJdkTarget() -
getDeactivatedTokens
-
getExtraTokens
-
getExtraTokenNames
-
getExtraTokenClassNames
-
isIgnoreCase
public boolean isIgnoreCase() -
setIgnoreCase
public void setIgnoreCase(boolean ignoreCase) -
setSettings
-
getSettings
-
getUtils
-