public interface ZbnfParseResultItem extends SortedTree<ZbnfParseResultItem>
ParseResultItem item = parser.getFirstParseResult(); //after successfull parsing. while(item != null) { String semantic = item.getSemantic(); if(semantic.equals("myExpectedSemantic")) { //do something } else if(semantic.equals("myOtherExpectedSemantic")) { //do something: getOtherExpectedComponentResult(); } item = item.next(null); //get the next. }The
doSomehing
means, calling of getParsedText(), getParsedInteger()
and so on from this item and write the values according the users requests. In the
example above a mehtod getOtherExpectedComponentResult()
is be written.
It is a example to get results from parsing of a metamorphem, it is typically.
In this case the followed pattern may be used:
void getOtherExpectedComponentResult(ParseResultItem parent) { //do something with info in parent // ... ParseResultItem item = parent.nextSkipIntoComponent(parent); //start with the second item of the component 'parent'. //It may be null if the parent is only composed of one item. while(item != null) { String semantic = item.getSemantic(); if(semantic.equals("mySecondSemantic")) { //do something } else if(semantic.equals("myThirdExpectedSemantic")) { //do something getUsersInnerComponentResult(); } item = item.next(parent); //get the next, null on end of the component 'parent' } }The inner structure is the same, if a component with the expected semantic is detect, the component is examined by calling nextSkipIntoComponent(parent) at first, but, to step throw its components next(parent) is calling inside the while-loop to skip over inner components. Note: The documentation above uses the older deprecated methods, using the methods from interface are more simple.
Modifier and Type | Method and Description |
---|---|
ZbnfParseResultItem |
firstChild()
Gets the first child of a component.
|
java.lang.String |
getChildString(java.lang.String child)
Returns the String content of the given child or null, if no such child is found.
|
ZbnfSyntaxPrescript |
getComponentSyntax() |
java.lang.String |
getDescription()
Returns a short description for report, error report, from the current item.
|
int |
getInputColumn()
returns the column of the input line while parsing.
|
java.lang.String |
getInputFile()
returns the file of the input line while parsing.
|
int |
getInputLine()
returns the line of the input line while parsing.
|
int |
getNrofAlternative()
Returns the number of the alternative, -1 if there is not a alternative choice,
0 if there is an empty option.
|
double |
getParsedFloat()
Returns the parsed float value if isFloat() returns true.
|
long |
getParsedInteger()
Returns the parsed integer value if isInteger() returns true.
|
java.lang.String |
getParsedString()
Returns the parsed string if isString() returns true.
|
java.lang.String |
getParsedText()
Returns the input text at the parsed area of this result.
|
java.lang.String |
getSemantic()
Gets the semantic of the item.
|
boolean |
isComponent()
Tests if the actual item is a start item of a component.
|
boolean |
isFloat()
Tests if the actual item represents a parsed float number.
|
boolean |
isIdentifier()
Tests if the actual item represents an identifier.
|
boolean |
isInteger()
Tests if the actual item represents a parsed integer number.
|
boolean |
isOnlySemantic()
Tests if the actual item represents a entry describes only semantic.
|
boolean |
isOption()
Tests if the actual item represents an entry describes a option construct of something.
|
int |
isRepeat()
Tests if the actual item represents an entry describes a repetition of something.
|
int |
isRepetition()
Tests if the actual item represents an entry describes a repetition of something.
|
boolean |
isString()
Tests if the actual item represents a parsed string.
|
boolean |
isTerminalSymbol()
Tests if the actual item represents a parsed terminal symbol.
|
java.util.Iterator<ZbnfParseResultItem> |
iteratorChildren()
Creates an iterator and returns it reference for the actual item to iterate to its childs.
|
ZbnfParseResultItem |
next()
Deprecated.
use instead
iteratorChildren() or getChildren() from the parent item. |
ZbnfParseResultItem |
next(ZbnfParseResultItem parent)
Deprecated.
use instead
iteratorChildren() or getChildren() from the parent item. |
ZbnfParseResultItem |
nextSkipIntoComponent(ZbnfParseResultItem parent)
Deprecated.
use instead
iteratorChildren() or getChildren() from the current item. |
ZbnfSyntaxPrescript |
syntaxItem()
Returns the syntax item to this element.
|
getChild, getParent, iterChildren, iterChildren, listChildren, listChildren
java.lang.String getSemantic()
java.lang.String getParsedText()
double getParsedFloat()
long getParsedInteger()
java.lang.String getParsedString()
java.lang.String getChildString(java.lang.String child)
child
- int getNrofAlternative()
java.lang.String getDescription()
int getInputLine()
int getInputColumn()
java.lang.String getInputFile()
boolean isComponent()
ZbnfSyntaxPrescript getComponentSyntax()
boolean isInteger()
boolean isFloat()
boolean isString()
boolean isTerminalSymbol()
boolean isIdentifier()
boolean isOnlySemantic()
int isRepetition()
int isRepeat()
boolean isOption()
@Deprecated ZbnfParseResultItem next()
iteratorChildren()
or getChildren()
from the parent item.@Deprecated ZbnfParseResultItem next(ZbnfParseResultItem parent)
iteratorChildren()
or getChildren()
from the parent item.parent
- The item that is the first item of a component.
If null, than no test of parent occurs.@Deprecated ZbnfParseResultItem nextSkipIntoComponent(ZbnfParseResultItem parent)
iteratorChildren()
or getChildren()
from the current item.parent
- The item that is the first item of a component.
If null, than no test of parent occurs.ZbnfParseResultItem firstChild()
java.util.Iterator<ZbnfParseResultItem> iteratorChildren()
ZbnfSyntaxPrescript syntaxItem()