Package com.javacc

Class 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.
    • Constructor Detail

      • Grammar

        public Grammar​(Path outputDir,
                       String codeLang,
                       int jdkTarget,
                       boolean quiet,
                       Map<String,​String> preprocessorSymbols)
      • Grammar

        public Grammar()
    • Method Detail

      • isQuiet

        public boolean isQuiet()
      • getCodeLang

        public String getCodeLang()
      • getLexicalStates

        public String[] getLexicalStates()
      • generateIdentifierPrefix

        public String generateIdentifierPrefix​(String basePrefix)
      • generateUniqueIdentifier

        public String generateUniqueIdentifier​(String prefix,
                                               Node exp)
      • 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()
      • 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)
      • getOtherParserCodeDeclarations

        public List<Node> getOtherParserCodeDeclarations()
      • setParserCode

        public void setParserCode​(CompilationUnit parserCode)
      • setParserPackage

        public void setParserPackage​(String parserPackage)
      • getChoicePointExpansions

        public List<Expansion> getChoicePointExpansions()
        Returns:
        a List containing all the expansions that are at a choice point
      • getAssertionExpansions

        public List<Expansion> getAssertionExpansions()
      • getExpansionsNeedingPredicate

        public List<Expansion> getExpansionsNeedingPredicate()
      • getExpansionsNeedingRecoverMethod

        public List<Expansion> getExpansionsNeedingRecoverMethod()
      • getLexerTokenHooks

        public List<String> getLexerTokenHooks()
      • getParserTokenHooks

        public List<String> getParserTokenHooks()
      • getResetTokenHooks

        public List<String> getResetTokenHooks()
      • getOpenNodeScopeHooks

        public List<String> getOpenNodeScopeHooks()
      • getCloseNodeScopeHooks

        public List<String> getCloseNodeScopeHooks()
      • getProductionTable

        public Map<String,​BNFProduction> getProductionTable()
        A symbol table of all grammar productions.
      • addLexicalState

        public void addLexicalState​(String name)
        Add a new lexical state
      • getExpansionsForFirstSet

        public List<Expansion> getExpansionsForFirstSet()
      • getExpansionsForFinalSet

        public List<Expansion> getExpansionsForFinalSet()
      • getExpansionsForFollowSet

        public List<Expansion> getExpansionsForFollowSet()
      • 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.
      • 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".
      • 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.
      • classNameFromTokenName

        public String classNameFromTokenName​(String tokenName)
      • constNameFromClassName

        public String constNameFromClassName​(String className)
      • 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)
      • addError

        public void addError​(Node location,
                             String errorMessage)
      • addWarning

        public void addWarning​(String warningMessage)
      • addWarning

        public void addWarning​(Node location,
                               String warningMessage)
      • getErrorCount

        public int getErrorCount()
        Returns:
        the total error count during grammar parsing.
      • getNodeNames

        public Set<String> getNodeNames()
      • getNodePrefix

        public String getNodePrefix()
      • addNodeType

        public void addNodeType​(String productionName,
                                String nodeName)
      • nodeIsInterface

        public boolean nodeIsInterface​(String nodeName)
      • nodeIsAbstract

        public boolean nodeIsAbstract​(String nodeName)
      • getNodeClassName

        public String getNodeClassName​(String nodeName)
      • getNodePackageName

        public String getNodePackageName​(String nodeName)
      • addCodeInjection

        public void addCodeInjection​(Node n)
      • isInInclude

        public boolean isInInclude()
      • getParserPackage

        public String getParserPackage()
      • getBaseSourceDirectory

        public String getBaseSourceDirectory()
      • getNodePackage

        public String getNodePackage()
      • getCurrentNodeVariableName

        public String getCurrentNodeVariableName()
      • removeNonJavaIdentifierPart

        public static String removeNonJavaIdentifierPart​(String s)
      • 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

        public Set<String> getDeactivatedTokens()
      • getExtraTokenNames

        public Set<String> getExtraTokenNames()
      • isIgnoreCase

        public boolean isIgnoreCase()
      • setIgnoreCase

        public void setIgnoreCase​(boolean ignoreCase)
      • setSettings

        public void setSettings​(Map<String,​Object> settings)