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 Details

    • Grammar

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

      public Grammar()
  • Method Details

    • isQuiet

      public boolean isQuiet()
    • getCodeLang

      public String getCodeLang()
    • getLexicalStates

      public String[] getLexicalStates()
    • addInplaceRegexp

      public void addInplaceRegexp(RegularExpression regexp)
    • generateIdentifierPrefix

      public String generateIdentifierPrefix(String basePrefix)
    • generateUniqueIdentifier

      public String generateUniqueIdentifier(String prefix, Node exp)
    • parse

      public Node parse(Path file, boolean enterIncludes) throws IOException, ParseException
      Throws:
      IOException
      ParseException
    • include

      public Node include(List<String> locations, Node includeLocation) throws IOException, ParseException
      Throws:
      IOException
      ParseException
    • 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:
      ParseException
      IOException
      freemarker.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()
    • getOtherParserCodeDeclarations

      public List<Node> getOtherParserCodeDeclarations()
    • 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
    • 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()
    • getCloseNodeHooksByClass

      public Map<String,List<String>> getCloseNodeHooksByClass()
    • 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
    • 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.
    • getAllLookaheads

      public List<Lookahead> getAllLookaheads()
    • 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.
    • 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()
    • 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()
    • 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()
    • getExtraTokens

      public Map<String,String> getExtraTokens()
    • getExtraTokenNames

      public Set<String> getExtraTokenNames()
    • getExtraTokenClassNames

      public Collection<String> getExtraTokenClassNames()
    • isIgnoreCase

      public boolean isIgnoreCase()
    • setIgnoreCase

      public void setIgnoreCase(boolean ignoreCase)
    • setSettings

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

      public Map<String,Object> getSettings()
    • getUtils

      public Grammar.Utils getUtils()