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>
public class Grammar extends BaseNode
This object is the root Node of the data structure that contains all the information regarding a JavaCC processing job.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classGrammar.Utils-
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 inherited from interface com.javacc.parser.JavaCCConstants
BUF_SIZE
-
-
Method Summary
-
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, toString
-
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
-
isQuiet
public boolean isQuiet()
-
getCodeLang
public String getCodeLang()
-
getLexicalStates
public String[] getLexicalStates()
-
addInplaceRegexp
public void addInplaceRegexp(RegularExpression regexp)
-
parse
public Node parse(Path file, boolean enterIncludes) throws IOException, ParseException
- Throws:
IOExceptionParseException
-
include
public Node include(List<String> locations, Node includeLocation) throws IOException, ParseException
- Throws:
IOExceptionParseException
-
createOutputDir
public void createOutputDir()
-
getFilename
public Path getFilename()
The grammar file being processed.
-
setFilename
public void setFilename(Path filename)
-
generateLexer
public void generateLexer()
-
doSanityChecks
public void doSanityChecks()
-
generateFiles
public void generateFiles() throws ParseException, IOException, freemarker.template.TemplateException- Throws:
ParseExceptionIOExceptionfreemarker.template.TemplateException
-
getLexerData
public LexerData getLexerData()
-
getConstantsClassName
public String getConstantsClassName()
-
getParserClassName
public String getParserClassName()
-
setParserClassName
public void setParserClassName(String parserClassName)
-
getBaseNodeClassName
public String getBaseNodeClassName()
-
getLexerClassName
public String getLexerClassName()
-
getNfaDataClassName
public String getNfaDataClassName()
-
getDefaultLexicalState
public String getDefaultLexicalState()
-
setDefaultLexicalState
public void setDefaultLexicalState(String defaultLexicalState)
-
getInjector
public CodeInjector getInjector()
-
getParserCodeImports
public List<ImportDeclaration> getParserCodeImports()
-
setParserCode
public void setParserCode(CompilationUnit parserCode)
-
setParserPackage
public void setParserPackage(String parserPackage)
-
getParserProductions
public Collection<BNFProduction> getParserProductions()
-
getChoicePointExpansions
public List<Expansion> getChoicePointExpansions()
- Returns:
- a List containing all the expansions that are at a choice point
-
getProductionTable
public Map<String,BNFProduction> getProductionTable()
A symbol table of all grammar productions.
-
getProductionByName
public BNFProduction getProductionByName(String name)
-
addLexicalState
public void addLexicalState(String name)
Add a new lexical state
-
getAllTokenProductions
public List<TokenProduction> 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.
-
getAllLookBehinds
public List<LookBehind> getAllLookBehinds()
-
addTokenProduction
public void addTokenProduction(TokenProduction tp)
-
getNamedToken
public RegularExpression getNamedToken(String name)
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
public RegularExpression addNamedToken(String name, RegularExpression regexp)
-
hasTokenOfName
public boolean hasTokenOfName(String name)
-
getOrderedNamedTokens
public List<RegularExpression> 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
public String getTokenName(int index)
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.
-
addTokenName
public void addTokenName(int index, String name)
-
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
public void addError(String errorMessage)
-
addWarning
public void addWarning(String warningMessage)
-
getErrorCount
public int getErrorCount()
- Returns:
- the total error count during grammar parsing.
-
getNodePrefix
public String getNodePrefix()
-
nodeIsInterface
public boolean nodeIsInterface(String nodeName)
-
nodeIsAbstract
public boolean nodeIsAbstract(String nodeName)
-
addCodeInjection
public void addCodeInjection(Node n)
-
isInInclude
public boolean isInInclude()
-
getParserPackage
public String getParserPackage()
-
getParserOutputDirectory
public Path getParserOutputDirectory() throws IOException
- Throws:
IOException
-
getBaseSourceDirectory
public String getBaseSourceDirectory()
-
getNodeOutputDirectory
public Path getNodeOutputDirectory() throws IOException
- Throws:
IOException
-
getNodePackage
public String getNodePackage()
-
getCurrentNodeVariableName
public String getCurrentNodeVariableName()
-
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()
-
getExtraTokenClassNames
public Collection<String> getExtraTokenClassNames()
-
isIgnoreCase
public boolean isIgnoreCase()
-
setIgnoreCase
public void setIgnoreCase(boolean ignoreCase)
-
getUtils
public Grammar.Utils getUtils()
-
-