- 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 Summary
Fields Modifier and Type Field Description protected boolean
anyMatched
protected static int
DEFAULT_DEPTH
protected ILookAheadBuffer
fLookAheadBuffer
protected static int
FORCE_THROW
protected String
fSectionName
protected J9TagManager
fTagManager
protected ITagParser
fTagParser
-
Constructor Summary
Constructors Constructor Description SectionParserGrammar(String sectionName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
consume()
int
getCurrentFileLineNumber()
Returns the current line number being parsed, or -1 if no parsing is occurring (parsing is finished, etc..).Iterator
getErrors()
protected IAttributeValueMap
getLineRuleResults(IParserToken token)
protected ILookAheadBuffer
getLookAheadBuffer()
protected void
handleError(Exception e)
protected void
handleError(Exception e, int behaviour)
protected void
handleError(String message)
protected void
handleError(String message, int offset, int length)
protected void
handleError(String message, Exception e)
protected void
handleErrorAtLineNumber(int fileLineNumber, String message, Exception e)
protected void
handleRequiredMismatch(String expectedType, String actualType, String actualValue)
protected void
handleUnknownMismatch(String actualType, String actualValue)
protected boolean
isValidJavaCoreTag(IParserToken token)
protected boolean
isValidSectionTag(String tag)
protected IParserToken
lookAhead(int depth)
protected boolean
match(String type, boolean required)
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.protected boolean
matchOptional(String type)
Match a type, but do not generate an error if mismatch occurs.protected boolean
matchRequired(String type)
Match a type, and generate an error if a mismatch occurs.protected IAttributeValueMap
processTagLineOptional(String tagName)
protected IAttributeValueMap
processTagLineRequired(String tagName)
protected void
setLookAheadBuffer(ILookAheadBuffer lookAheadBuffer)
protected void
setLookAheadBuffer(ILookAheadBuffer lookAheadBuffer, int depth)
protected void
setTagManager(J9TagManager tagManager)
-
Methods declared in class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods declared in interface com.ibm.dtfj.javacore.parser.framework.parser.ISectionParser
anyMatched, getSectionName, readIntoDTFJ
-
-
-
-
Field Detail
-
FORCE_THROW
protected static final int FORCE_THROW
- See Also:
- Constant Field Values
-
fLookAheadBuffer
protected ILookAheadBuffer fLookAheadBuffer
-
fSectionName
protected String fSectionName
-
fTagManager
protected J9TagManager fTagManager
-
fTagParser
protected ITagParser fTagParser
-
DEFAULT_DEPTH
protected static final int DEFAULT_DEPTH
- See Also:
- Constant Field Values
-
anyMatched
protected boolean anyMatched
-
-
Constructor Detail
-
SectionParserGrammar
public SectionParserGrammar(String sectionName)
-
-
Method Detail
-
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
-
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 matchrequired
- 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 interfaceISectionParser
- 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
-
-