Class SectionParserGrammar

java.lang.Object
com.ibm.dtfj.javacore.parser.j9.SectionParserGrammar
All Implemented Interfaces:
ISectionParser
Direct Known Subclasses:
SectionParser, SovereignSectionParserPart

public abstract class SectionParserGrammar extends Object implements ISectionParser
Parent section parser that implements most of the grammar based functionality used by the concrete section parsers.
  • Field Details

  • Constructor Details

    • SectionParserGrammar

      public SectionParserGrammar(String sectionName)
  • Method Details

    • setLookAheadBuffer

      protected void setLookAheadBuffer(ILookAheadBuffer lookAheadBuffer, int depth) throws ParserException
      Parameters:
      lookAheadBuffer -
      depth -
      Throws:
      ParserException
    • setLookAheadBuffer

      protected void setLookAheadBuffer(ILookAheadBuffer lookAheadBuffer) throws ParserException
      Parameters:
      lookAheadBuffer -
      Throws:
      ParserException
    • getLookAheadBuffer

      protected ILookAheadBuffer getLookAheadBuffer()
    • setTagManager

      protected void setTagManager(J9TagManager tagManager)
      Parameters:
      tagManager -
      Throws:
      NullPointerException - if tag manager is null
    • handleRequiredMismatch

      protected void handleRequiredMismatch(String expectedType, String actualType, String actualValue) throws ParserException
      Parameters:
      scanner -
      Throws:
      ParserException
    • handleUnknownMismatch

      protected void handleUnknownMismatch(String actualType, String actualValue) throws ParserException
      Throws:
      ParserException
    • lookAhead

      protected IParserToken lookAhead(int depth) throws ParserException
      Parameters:
      depth -
      Throws:
      ParserException
    • getSectionName

      public String getSectionName()
      Specified by:
      getSectionName in interface ISectionParser
    • consume

      protected void consume() throws ParserException
      Parameters:
      lookAheadBuffer -
      Throws:
      ParserException
    • match

      protected boolean match(String type, boolean required) throws ParserException
      The match performs one additional function:
      if the mismatch is due to an unrecognised javacore tag, that erroneous tag can be interpreted as garbage for now, so the latter is consumed without further processing.
      However, beware of considering all mismatches to be garbage. It is possible that the mismatch is due to a VALID javacore tag that pertains to another language rule. In this case, an argument to the method decides whether to handle it as an error (i.e., match was required) or let it fall through to the next grammar rule (match was optional).
      Parameters:
      type - to match
      required - will generate an error, otherwise false ignores the mismatch.
      Returns:
      true if matched, false otherwise.
      Throws:
      ParserException
    • getLineRuleResults

      protected IAttributeValueMap getLineRuleResults(IParserToken token) throws ParserException
      Parameters:
      type -
      Throws:
      ParserException
    • matchRequired

      protected boolean matchRequired(String type) throws ParserException
      Match a type, and generate an error if a mismatch occurs. This is usually used for grammar matches that are required.
      Parameters:
      type -
      Throws:
      ParserException
    • matchOptional

      protected boolean matchOptional(String type) throws ParserException
      Match a type, but do not generate an error if mismatch occurs. This is usually used when a terminal in a grammar rule is optional.
      Parameters:
      type -
      Throws:
      ParserException
    • processTagLineRequired

      protected IAttributeValueMap processTagLineRequired(String tagName) throws ParserException
      Parameters:
      tagName -
      Returns:
      attributevaluemap if tag line found and parsed, or null if not found.
      Throws:
      ParserException
    • processTagLineOptional

      protected IAttributeValueMap processTagLineOptional(String tagName) throws ParserException
      Parameters:
      tagName -
      Returns:
      attributevaluemap if tag line found and parsed, or null if not found.
      Throws:
      ParserException
    • isValidSectionTag

      protected boolean isValidSectionTag(String tag)
      Parameters:
      tag -
    • isValidJavaCoreTag

      protected boolean isValidJavaCoreTag(IParserToken token)
      Parameters:
      token -
    • getCurrentFileLineNumber

      public int getCurrentFileLineNumber() throws ParserException
      Returns the current line number being parsed, or -1 if no parsing is occurring (parsing is finished, etc..).
      Returns:
      current line number of line being parsed, or -1 if there is nothing left to parse.
      Throws:
      ParserException
    • getErrors

      public Iterator getErrors()
      Specified by:
      getErrors in interface ISectionParser
      Returns:
      non null Iterator to a list of errors encountered during parsing.
    • handleError

      protected void handleError(String message, Exception e) throws ParserException
      Parameters:
      message -
      Throws:
      ParserException
    • handleError

      protected void handleError(String message) throws ParserException
      Throws:
      ParserException
    • handleErrorAtLineNumber

      protected void handleErrorAtLineNumber(int fileLineNumber, String message, Exception e) throws ParserException
      Parameters:
      fileLineNumber -
      message -
      e -
      Throws:
      ParserException
    • handleError

      protected void handleError(String message, int offset, int length) throws ParserException
      Parameters:
      message -
      offset -
      length -
      Throws:
      ParserException
    • handleError

      protected void handleError(Exception e) throws ParserException
      Parameters:
      e -
      Throws:
      ParserException
    • handleError

      protected void handleError(Exception e, int behaviour) throws ParserException
      Parameters:
      e -
      behaviour -
      Throws:
      ParserException
    • anyMatched

      public boolean anyMatched()
      Specified by:
      anyMatched in interface ISectionParser