class ZbnfParser.PrescriptParser.SubParser
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
(package private) boolean |
bDoNotStoreData |
private int |
nRecursion
Recursionscounter
|
(package private) ZbnfParserStore.ParseResultItemImplement |
parentOfParentResultItem
Reference to the parent parse result item of the parent, given on constructor.
|
(package private) ZbnfParser.PrescriptParser.SubParser |
parentParser
Pointer to parent, used for build expected syntax on error:
|
(package private) long |
posStoreSrc
If not 0 then <@?
|
(package private) java.lang.String |
semanticStoreSrc
Associated semantic to store the source. null: nothing to store.
|
private int[] |
srcColumn
last parsed column in an item.
|
private int |
srcLine
last parsed line in an item.
|
(package private) java.lang.String |
sSemanticForError
The semantic for getExpectedSyntaxOnError.
|
(package private) int |
xxxidxAlternative
Counter of tested alternatives.
|
Modifier | Constructor and Description |
---|---|
protected |
SubParser(ZbnfParser.PrescriptParser.SubParser parent,
ZbnfParserStore.ParseResultItemImplement parentResultItem,
boolean bDoNotStoreData,
int nRecursion)
Constructs a new Parser with a given parsed syntaxPrescript and a given input and output buffer.
|
Modifier and Type | Method and Description |
---|---|
private boolean |
addResultOrSubsyntax(java.lang.CharSequence sResult,
long srcBegin,
int srcLine,
int srcColumn,
java.lang.String srcFile,
java.lang.String sSemanticForStoring,
ZbnfParserStore.ParseResultItemImplement parentResultItem,
ZbnfSyntaxPrescript syntaxItem) |
private java.lang.String |
getSemanticTreeForErrorMsg()
gets the tree of semantic while parsing
|
private void |
init()
call if reused.
|
private boolean |
parse_Component(StringPartScan sInputP,
int posInputbase,
ZbnfSyntaxPrescript syntaxCmpn,
java.lang.String sSemanticForStoring,
ZbnfParserStore.ParseResultItemImplement parentResultItem,
boolean bSkipSpaceAndComment,
boolean bDoNotStoreData,
ZbnfSyntaxPrescript parentSyntaxItem,
boolean bResultToAssignIntoNextComponent,
boolean bAddParseResultFromPrevious)
parses a component.
|
private boolean |
parseExpectedVariant(ZbnfSyntaxPrescript syntaxPrescript,
boolean bSkipSpaceAndComment,
int recursion) |
private boolean |
parseFloatNumber(ZbnfSyntaxPrescript syntaxItem,
int maxNrofChars,
ZbnfParserStore.ParseResultItemImplement parentResultItem) |
private boolean |
parseHexNumber(ZbnfSyntaxPrescript syntaxItem,
ZbnfParserStore.ParseResultItemImplement parentResultItem,
int maxNrofChars) |
private boolean |
parseIdentifier(java.lang.String addChars,
java.lang.String sSemanticForStoring,
ZbnfParserStore.ParseResultItemImplement parentResultItem) |
private boolean |
parseInteger(ZbnfSyntaxPrescript syntaxItem,
ZbnfParserStore.ParseResultItemImplement parentResultItem,
int maxNrofChars) |
private boolean |
parseItem(ZbnfSyntaxPrescript syntaxItem,
ZbnfParserStore.ParseResultItemImplement parentResultItem,
boolean bSkipSpaceAndComment,
int recursion)
parses one item.
|
private boolean |
parseNegativVariant(ZbnfSyntaxPrescript syntaxNegativ,
boolean bSkipSpaceAndComment,
int recursion) |
private boolean |
parseNoOrSomeCharsOutsideQuotion(java.lang.String sSyntax,
int maxNrofChars,
java.lang.String sSemanticForStoring,
ZbnfParserStore.ParseResultItemImplement parentResultItem,
ZbnfSyntaxPrescript syntaxItem) |
private boolean |
parseNumberRadix(ZbnfSyntaxPrescript syntaxItem,
ZbnfParserStore.ParseResultItemImplement parentResultItem,
int maxNrofChars)
Any desired radix, 2, 8, 16, 24 etc.
|
private boolean |
parseOptions(ZbnfSyntaxPrescript optionPrescript,
ZbnfParserStore.ParseResultItemImplement parentResultItem,
boolean bSkipSpaceAndComment,
int recursion)
Parses at start of an option.
|
private boolean |
parsePositiveInteger(ZbnfSyntaxPrescript syntaxItem,
ZbnfParserStore.ParseResultItemImplement parentResultItem,
int maxNrofChars) |
(package private) boolean |
parsePrescript(ZbnfSyntaxPrescript prescriptItem,
ZbnfParserStore.ParseResultItemImplement parentResultItem,
boolean bSkipSpaceAndCommentForward,
boolean bDoNotStoreData,
int recursion)
Parse one linear prescript maybe with options to test first after.
|
private boolean |
parseRegularExpression(ZbnfSyntaxPrescript syntaxItem,
java.lang.String sSemanticForStoring,
ZbnfParserStore.ParseResultItemImplement parentResultItem,
boolean bSkipSpaceAndComment) |
private boolean |
parseRepetition(ZbnfSyntaxPrescript forwardSyntax,
ZbnfSyntaxPrescript backwardSyntax,
ZbnfParserStore.ParseResultItemImplement parentResultItem,
boolean bSkipSpaceAndComment,
int recursion) |
private boolean |
parseSimpleStringLiteral(java.lang.String sQuotionMarks,
int maxNrofChars,
java.lang.String sSemanticForStoring,
ZbnfParserStore.ParseResultItemImplement parentResultItem,
ZbnfSyntaxPrescript syntaxItem) |
private boolean |
parseStringUntilRightEndchar(java.lang.String sConstantSyntax,
boolean bInclusive,
int maxNrofChars,
java.lang.String sSemanticForStoring,
ZbnfParserStore.ParseResultItemImplement parentResultItem,
ZbnfSyntaxPrescript syntaxItem)
parses until one of some endchars from right.
|
private boolean |
parseStringUntilTerminateString(java.lang.String sConstantSyntax,
boolean bInclusive,
boolean bTrim,
int maxNrofChars,
java.lang.String sSemanticForStoring,
ZbnfParserStore.ParseResultItemImplement parentResultItem,
ZbnfSyntaxPrescript syntaxItem)
parses until one of some one of the end strings.
|
boolean |
parseSub(ZbnfSyntaxPrescript syntaxPrescript,
java.lang.String sSemanticForErrorDefault,
int resultType,
ZbnfSyntaxPrescript parentSyntaxItem,
java.lang.String sSemanticForStoring,
ZbnfParserStore.ParseResultItemImplement parentResultItem,
boolean bSkipSpaceAndComment,
ZbnfParserStore parseResultsFromOtherComponents,
int recursion)
Parses a syntax-prescript assigned with this class.
|
private boolean |
parseTerminalSymbol(ZbnfSyntaxPrescript syntaxItem,
ZbnfParserStore.ParseResultItemImplement parentResultItem)
checks a terminal symbol.
|
private boolean |
parseUnconditionalVariant(ZbnfSyntaxPrescript syntaxPrescript,
ZbnfParserStore.ParseResultItemImplement parentResultItem,
boolean bSkipSpaceAndComment,
int recursion) |
private boolean |
parseWhiteSpaceAndComment() |
private boolean |
parseWhiteSpaceAndCommentOrTerminalSymbol(java.lang.String sConstantSyntax,
ZbnfParserStore.ParseResultItemImplement parentResultItem)
Skips white spaces and parses a given constant syntax before checking and skipping comments.
|
private void |
saveError(java.lang.String sSyntax)
Sets the rightest position of matched input.
|
java.lang.String |
XXXgetDefinitionIdent() |
ZbnfParserStore |
xxxgetParserStore()
Gets the parser Store
|
private final int nRecursion
int xxxidxAlternative
java.lang.String sSemanticForError
ZbnfParser.getExpectedSyntaxOnError()
long posStoreSrc
java.lang.String semanticStoreSrc
final boolean bDoNotStoreData
final ZbnfParser.PrescriptParser.SubParser parentParser
final ZbnfParserStore.ParseResultItemImplement parentOfParentResultItem
private final int[] srcColumn
private int srcLine
protected SubParser(ZbnfParser.PrescriptParser.SubParser parent, ZbnfParserStore.ParseResultItemImplement parentResultItem, boolean bDoNotStoreData, int nRecursion)
syntax
- The prescript is a child of the parents' prescript.parent
- Parent level of parsing, for debug and transform parseResultToOtherComponent.parserStoreInPrescript
- typically the same result buffer as parent, but an other buffer, typically
identically with parent.parssResultToOtherComponent, if the result shouldn't be stored in main stream,
used to transform semantic results to a followed item (<..?->-Syntax).
It may be null, than create a new temporary parser result buffer.private void init()
public boolean parseSub(ZbnfSyntaxPrescript syntaxPrescript, java.lang.String sSemanticForErrorDefault, int resultType, ZbnfSyntaxPrescript parentSyntaxItem, java.lang.String sSemanticForStoring, ZbnfParserStore.ParseResultItemImplement parentResultItem, boolean bSkipSpaceAndComment, ZbnfParserStore parseResultsFromOtherComponents, int recursion) throws java.text.ParseException
<syntax...>
.
A semantic itself is given if the prescript starts with <?syntax>
at example in
option brackets [<?syntax>...
or repeat brackets {<?syntax>...
or also possible at start of an nested prescript ::=<?syntax>...
input
- The input to parse,it is a reference to the same instance as in parent.sSemanticForErrorP
- The semantic superior semantic. This semantic is used for error report.resultType
- type of the result item of this component. It may one of ParserStore.kOption etc or
a less positiv or negativ number used for repetition and backward repetition.sSemanticForStoring1
- The semantic given at the calling item. It may be
<component?>
by using the component.component::=<?semantic>
. This is the regulary case for mostly calls
of syntax component, especially in ZBNF via the simple <syntax>
.
component::=<?>
.
For transforming ZBNF a SyntaxPrescript see @see SyntaxPrescript.convertSyntaxDefinition(StringPart spInput)
If not own semantic of the component is defined, input
- The input String.sSemanticForErrorDefault
- It is used only if the component has not a semantic.resultType
- The type of Parser Store result, see ZbnfParserStore.kTerminalSymbol
etc.
A positiv number 1... is the count of repetition.sSemanticForStoring
- parentResultItem
- the parent parse result item for a new child.bSkipSpaceAndComment
- if true, than white spaces or comments are possible at actual input positions
and should be skipped before test a non-terminate syntax
and should be skipped after test a terminate syntax if its failed.java.text.ParseException
boolean parsePrescript(ZbnfSyntaxPrescript prescriptItem, ZbnfParserStore.ParseResultItemImplement parentResultItem, boolean bSkipSpaceAndCommentForward, boolean bDoNotStoreData, int recursion) throws java.text.ParseException
listPrescripts
- list of the syntax sub prescriptsbSkipSpaceAndCommentForward
- true then outside a space skip is setjava.text.ParseException
private boolean parseItem(ZbnfSyntaxPrescript syntaxItem, ZbnfParserStore.ParseResultItemImplement parentResultItem, boolean bSkipSpaceAndComment, int recursion) throws java.text.ParseException
parentResultItem
- the parent parse result item for a new child.bSkipSpaceAndComment
- true if the calling level determines that white spaces and comments are to skip.java.text.ParseException
private boolean parseWhiteSpaceAndComment()
private boolean parseWhiteSpaceAndCommentOrTerminalSymbol(java.lang.String sConstantSyntax, ZbnfParserStore.ParseResultItemImplement parentResultItem)
sConstantSyntax
- The string to test as terminal symbol or null.parentResultItem
- the parent parse result item for a new child, can be null if sConstantSyntax is null.private boolean parseTerminalSymbol(ZbnfSyntaxPrescript syntaxItem, ZbnfParserStore.ParseResultItemImplement parentResultItem)
syntaxItem
- The syntaxitem of a terminal symbol, containing the constant syntax.parentResultItem
- the parent parse result item for a new child.private boolean parseRegularExpression(ZbnfSyntaxPrescript syntaxItem, java.lang.String sSemanticForStoring, ZbnfParserStore.ParseResultItemImplement parentResultItem, boolean bSkipSpaceAndComment) throws java.text.ParseException
syntaxItem
- sSemanticForStoring
- parentResultItem
- the parent parse result item for a new child.bSkipSpaceAndComment
- java.text.ParseException
private boolean parseIdentifier(java.lang.String addChars, java.lang.String sSemanticForStoring, ZbnfParserStore.ParseResultItemImplement parentResultItem)
private boolean parsePositiveInteger(ZbnfSyntaxPrescript syntaxItem, ZbnfParserStore.ParseResultItemImplement parentResultItem, int maxNrofChars) throws java.text.ParseException
java.text.ParseException
private boolean parseHexNumber(ZbnfSyntaxPrescript syntaxItem, ZbnfParserStore.ParseResultItemImplement parentResultItem, int maxNrofChars) throws java.text.ParseException
java.text.ParseException
private boolean parseNumberRadix(ZbnfSyntaxPrescript syntaxItem, ZbnfParserStore.ParseResultItemImplement parentResultItem, int maxNrofChars) throws java.text.ParseException
syntaxItem
- parentResultItem
- maxNrofChars
- java.text.ParseException
private boolean parseInteger(ZbnfSyntaxPrescript syntaxItem, ZbnfParserStore.ParseResultItemImplement parentResultItem, int maxNrofChars) throws java.text.ParseException
java.text.ParseException
private boolean parseFloatNumber(ZbnfSyntaxPrescript syntaxItem, int maxNrofChars, ZbnfParserStore.ParseResultItemImplement parentResultItem) throws java.text.ParseException
java.text.ParseException
private boolean parseNoOrSomeCharsOutsideQuotion(java.lang.String sSyntax, int maxNrofChars, java.lang.String sSemanticForStoring, ZbnfParserStore.ParseResultItemImplement parentResultItem, ZbnfSyntaxPrescript syntaxItem) throws java.text.ParseException
java.text.ParseException
private boolean parseStringUntilRightEndchar(java.lang.String sConstantSyntax, boolean bInclusive, int maxNrofChars, java.lang.String sSemanticForStoring, ZbnfParserStore.ParseResultItemImplement parentResultItem, ZbnfSyntaxPrescript syntaxItem) throws java.text.ParseException
sConstantSyntax
- contains the possible end charsbInclusive
- If true, the end char is parsed inclusive, if false, than exclusive.maxNrofChars
- possible given at left position <123....> or Integer.MAX_VALUEsSemanticForStoring
- The semantic, null if no result should be stored.sSubSyntax
- not null, the name of the inner syntax prescript if there is one.parseResult
- Buffer to store the result. It may be a special buffer or the main buffer.java.text.ParseException
private boolean parseStringUntilTerminateString(java.lang.String sConstantSyntax, boolean bInclusive, boolean bTrim, int maxNrofChars, java.lang.String sSemanticForStoring, ZbnfParserStore.ParseResultItemImplement parentResultItem, ZbnfSyntaxPrescript syntaxItem) throws java.text.ParseException
sConstantSyntax
- now unused.bInclusive
- If true, the end char is parsed inclusive, if false, than exclusive.maxNrofChars
- possible given at left position <123....> or Integer.MAX_VALUEsSemanticForStoring
- The semantic, null if no result should be stored.syntaxItem
- The syntax item, contains info for substrings, see ZbnfSyntaxPrescript.getListStrings()
.parseResult
- Buffer to store the result. It may be a special buffer or the main buffer.java.text.ParseException
private boolean parse_Component(StringPartScan sInputP, int posInputbase, ZbnfSyntaxPrescript syntaxCmpn, java.lang.String sSemanticForStoring, ZbnfParserStore.ParseResultItemImplement parentResultItem, boolean bSkipSpaceAndComment, boolean bDoNotStoreData, ZbnfSyntaxPrescript parentSyntaxItem, boolean bResultToAssignIntoNextComponent, boolean bAddParseResultFromPrevious) throws java.text.ParseException
sDefinitionIdent::=.... .
".
It is possible to parse in mainstream input, in this case this.input should be given as
parameter sInputP, or it is possible to parse a detected part of input, escpecially
after parsing "<*...?!sDefinitionIdent>
".sInputP
- input to parse. This may be the main input from this.posInputbase
- The position of the given sInputP in the originally input. Note that this parse routine
does not use the ZbnfParser.PrescriptParser.input
but parses the sInputP. This is the offset information.sDefinitionIdent
- Identifier of the Syntax prescript, written in ZBNF at "sDefinitionIdent::=..."sSemanticForStoring
- If the semantic is specified outside, it is its identifier. Otherwise it is nullbSkipSpaceAndComment
- True if there are spaces in the prescript before this component.bResultToAssignIntoNextComponent
- If true, than the second Buffer ZbnfParser.PrescriptParser.parseResultToOtherComponent
is used to store the parse result. That is, if the calling syntax/semantic syntax contains <...?-...>>
.parentSyntaxItem
- That syntax element which invokes parsing this component. It contains for example
the ZbnfSyntaxPrescript.bDebugParsing
for a manual break while debugging.bAddParseResultFromPrevious
- If true, than this Parseresult containing in
ZbnfParser.PrescriptParser.parseResultToOtherComponent
should be added at start of this components result associated to this component.
It is a result of previous parsing with <...?-...>>
,
stored now because the components prescript has the form <...?+...>>
.java.text.ParseException
private boolean addResultOrSubsyntax(java.lang.CharSequence sResult, long srcBegin, int srcLine, int srcColumn, java.lang.String srcFile, java.lang.String sSemanticForStoring, ZbnfParserStore.ParseResultItemImplement parentResultItem, ZbnfSyntaxPrescript syntaxItem) throws java.text.ParseException
java.text.ParseException
private boolean parseSimpleStringLiteral(java.lang.String sQuotionMarks, int maxNrofChars, java.lang.String sSemanticForStoring, ZbnfParserStore.ParseResultItemImplement parentResultItem, ZbnfSyntaxPrescript syntaxItem) throws java.text.ParseException
sQuotionMarks
- left and right quotion mark char, typical "" or '', also possible <> or ><maxNrofChars
- sSemantic
- java.text.ParseException
private boolean parseOptions(ZbnfSyntaxPrescript optionPrescript, ZbnfParserStore.ParseResultItemImplement parentResultItem, boolean bSkipSpaceAndComment, int recursion) throws java.text.ParseException
options
- The current syntaxprescript item, a option item.java.text.ParseException
private boolean parseNegativVariant(ZbnfSyntaxPrescript syntaxNegativ, boolean bSkipSpaceAndComment, int recursion) throws java.text.ParseException
java.text.ParseException
private boolean parseExpectedVariant(ZbnfSyntaxPrescript syntaxPrescript, boolean bSkipSpaceAndComment, int recursion) throws java.text.ParseException
java.text.ParseException
private boolean parseUnconditionalVariant(ZbnfSyntaxPrescript syntaxPrescript, ZbnfParserStore.ParseResultItemImplement parentResultItem, boolean bSkipSpaceAndComment, int recursion) throws java.text.ParseException
java.text.ParseException
private boolean parseRepetition(ZbnfSyntaxPrescript forwardSyntax, ZbnfSyntaxPrescript backwardSyntax, ZbnfParserStore.ParseResultItemImplement parentResultItem, boolean bSkipSpaceAndComment, int recursion) throws java.text.ParseException
java.text.ParseException
private void saveError(java.lang.String sSyntax)
sSyntax
- The expected syntax.private java.lang.String getSemanticTreeForErrorMsg()
public ZbnfParserStore xxxgetParserStore()
public java.lang.String XXXgetDefinitionIdent()