public class ZbnfSyntaxPrescript
extends java.lang.Object
sSemantic
: The semantic of the node. It may be identical with the sDefinitionIdent
.sDefinitionIdent
: The name of the syntax component if it is any,
or a formal name for documentation. <+>--->
is a composition,
<>--->
is a aggregation, <|----
is a inherition.
+-----------------------------+ outer +-----------------------+ from | SyntaxPrescript |<---------<>| SyntaxPrescipt.Syntax | Parser |-----------------------------|* childs |-----------------------| -------->| sSemantic:String |<-----------| t | | sDefinitionIdent:String | syntaxList | | | |<+>-------->| | | | +-----------------------+ | | | | (super) +------------------+ | |<|-----------+---| ComplexSyntax | +-----------------------------+ | +------------------+ | | +------------------+ +---| RepetitionSyntax | +------------------+A SyntaxPrescript instance is either a simple instance without childs, than it doesn't contain an instance of its inner class Syntax. This is a terminating node. Or the SyntaxPrescript instance is a componentwise instance with childs, than a composite instance of Syntax is created and final referenced with
syntaxList
. A Child may be also one of the inherited classes ComplexSyntax or
RepititionSyntax, both based either on a simple or a componentwise instance of SyntaxPrescript.
In this manner all of the variants of syntax nodes are implementable.
setSyntax(StringPart)
syntaxident[:[superType]::=
syntaxprescript.
syntaxident
is a identifier,
like in java or C, written here in italic monospaced font, but the syntaxprescript is a complex expression, written here
in italic standard font.Terminalsymbol | Fix text is written directly, without quotions. The backslash
character \ is used to transcript control chars \r \n \t \f
like java/C and to transcript the special chars of syntax
definition: \[ \] \| \{ \} \. \? \# \< \> .
\a \e means the start and end of text, \s is a space char. |
syntax1| syntax2 | They are alternatives. |
[ syntax] | It is a single option. |
[ syntax1| syntax2] | It is a choiceable option, either syntax1 or syntax2 (or more choice possibilities |
[ syntax1| syntax2|] | It is a choiceable option, but also the empty choice is possible |
[| syntax1| syntax2] | First it is tested the syntax behind the option, only if it is not matched, the options are tested. |
[> syntax1| syntax2] | Ones of the alternatives should match, otherwise the parsing process fails. |
[? syntax1| syntax2] | Test whether it is not matched. This is usefull to abort repetitions. |
{ syntax} | Repetition of the syntax, at least one time. |
{ syntax1| syntax2} | Alternatives in repetition. |
{| syntax1| syntax2} | Alternatives in repetition but each alternative only one time. This is not tested while parsing. It creates only a scalar, not a list, for each result item in GenZbnfJavaData |
{ syntax? syntaxBackward} | A requested repeat syntax. It is a novum BNF-likely, but a require of praxis.
If the syntaxBackward is found, the repetition is required.
If the syntaxBackward failed, no repetition is required.
syntaxBackward is the separate-syntax between some repeated morphems. |
<syntaxident> | It is a complex syntax element (morphem). It is defined in an extra definition. |
<syntaxident?semantic> | The semantic ident is defined here, it is possible to define various semantics by using the same syntax components. |
< special? semantic> | Some syntax elements are standard definitions and don't need defined at users level. At example numbers, float numbers, identifier, quotion strings or strings till terminated chars, but not this chars in a quotion. Here are some special symbols, see downside. In generally the semanticident can be absent, than only the syntax ist tested, no output is produced. |
< maxnrof special?semantic> | The maximal number of chars of a special syntax morphem is limited,
at example <32$?NameOfVariable> for an identifier with maximal 32 chars. |
<$? | It is a identifier. Its semantic is given with the semanticident. |
<$ AddChars? | It is a identifier with additional chars. At example in XML, an identifier
may have also the char '- ' inside. If the '? ' is a additional char, it must be written as '\? '.
The transcription with '\ ' is also active here. |
<# ? | It is a positiv number only with the digits 0..9. |
<#- ? | It is a number with a negative sign or not. |
<#x ? | It is a hexadecimal number |
<#f ? | It is a float number |
<"" endchars? | A string in quotion marks. Like in Java or C,
inside the string a sequence \" isn't interpreted as end of quotion. |
<'' endchars? | A string in single-quotion marks.
Inside the string a sequence \' isn't interpreted as end of quotion. |
<* endchars? | It is a string of any chars, but not containing the endchars.
Regarding the endchars the same rule for transcriptions with '\ ' is valid.
At example the newline char is '\n ' and the char '? '
must be written as '\? ' because the '? ' has an extra meaning in this
syntax definition, also the '> ', written as '\> '. |
<*| endstring?| endstring | between | to ? there are some strings as end strings. All chars are matching until one of the endstring. |
<* | endstring| endstring? | between | to ? there are some strings as end strings. All chars are matching until one of the endstring. The parse result is trimmed without leading and trailing white spaces. |
<*"" endchars? | Any chars exclusively endchars, but if any of the endchars is inside a quution, it is claimed as a valid char, not an endchar. |
<*{ indent}| endstring? | It is a special construct to parse text with indentation.
All indentation chars until the column position of the first line are overreaded.
See StringPart.lentoAnyStringWithIndent(CharSequence[], CharSequence, int, StringBuilder) |
<!regex? | Regular expression using java.util.regex.Matcher.lookingAt(). |
<@? | Store the source from this position to the end of the syntax branch as String due to semantic. |
<...?-...> |
Store the result in a temporary buffer to assing to a followed component. |
<...?+!...> |
Position of the parsed before item, into the component. It is not used for parsing itself.
It is especially for the GenZbnfJavaData because a data element in the destination class is necessary to store the parsed result. |
<...?+...> |
Assign a stored result, parsed before, into the component. |
<...?*...> |
Transport to deeper levels, but not assign a stored result into the component. |
<...?&> |
In a repetition: onlyOneEach: for data storing only one element (Similar {| on start of repetition). |
<...?> |
Do not produce a parse result to this components level. |
<...??> |
The semantic is used from the components definition. It is the same as <...> |
<...?@semantic> |
Its the same like normal semantic, but in XML it is stored in an attribute. |
<...?""semantic> |
Store the parsed source text, in an extra ParseResultItem with the same semantic name (older version)
but also in the generated parse result item in the element ZbnfParserStore.ParseResultItemImplement.sInput ,
able to get with ZbnfParseResultItem.getParsedText() .
Sets bStoreAsString |
<...?"!"semantic> |
Store only the parsed source text in the ParseResultItem with the given name.
able to get with ZbnfParseResultItem.getParsedText() .
Does not store the deeper content of the parse result, though the syntax is used to test.
Sets bDonotStoreData |
::=<?semantic> [<?semantic> {<?semantic> |
If ::=<? is written immediately at start of a syntax term, also inside options and so on,
the given semantic and control possibilities is assigned to this term part. So a shorter form is writeable, at ex:
[<?ident> option] is the same as [<ident>] were ident::= option.
is defined in an extra syntax term. |
syntaxident::=<?semantic>
syntaxprescript.
, also possible on parts of the prescript like
[<?semantic[:superType]>...
.syntaxident::=<?>
syntaxprescript
means that the syntax component don't create a parse result item, if no special semantic is given at using by <syntax>
.
enumExpression::=enum \{ { <$name> [ = [<#-?value>|0x<#x?value|<$symbolnr>] ] | , }. typedefinition::=typedef [<enumExpression>|<structuredefinition>|int|float] <$typeident>;.It is the definition of a enum expression in C. The name of the syntax component is "
enumExpression
".
The string "enum
" is a constant text (terminal symbol), also the "{
" written as "\{
".
The followed {
is the beginning of a repetition. Inside the repetition there is an identifier
with the semantic 'name
', behind them it may be followed (optional) by a value specification,
beginning with the terminate symbol '=
', behind them either a number, may be negativ, or the
terminate symbols '0x
', followed by a hexadecimal number, or an identifier with the semantic
'symbolnr
'. One of the choice should be given. If behind them a char ,
is found, the
repetition is necessary, on the other hand it is not. The point '.
' means, that is it.typedefinition
', it isn't entire.
The <enumExpression>
is used here.
adress::= [<title>\s ] [<$firstname>] \s <$lastname>\n {<$street_or_house>\s} \s [<#numberOfApartment>] \n <5#postalCode> \s <$townOrVillage>\n.It is a sample of a adress specification. At this no whitespaces are tolerated, otherwise the newline detection is necessary to separate the parts of the adress. Some space charactes, in the syntax definition written as '
\s
' are possible between the parts of names. But the '\n
' is tested to separate the lines
of the adress. '<title>
' and '<word>
' are defined in extra definitions.
<$NoWhiteSpaces>
at start of a syntactical expression supressed the recognizing of
whitespaces in the syntax term. So no whitespaces are accepted in input text. But in this case spaces may be tested
with some special constructs especially regular expressions.
##
as start chars. The double ##
let it able to request a single
#
as normal terminate char. If in special two ## immediate followed are necessearry as terminal char,
the user can write a char sequence of \#\# to prevent that it is interpreted as comment start.Modifier and Type | Class and Description |
---|---|
private static class |
ZbnfSyntaxPrescript.ComplexSyntax
The class contains the execution method
|
(package private) static class |
ZbnfSyntaxPrescript.EType |
static class |
ZbnfSyntaxPrescript.RepetitionSyntax |
Modifier and Type | Field and Description |
---|---|
private boolean |
alsoEmptyOption
If it is true, it is also matching if no prescript matches to the parsed input.
|
(package private) java.util.Map<java.lang.String,java.lang.String> |
attributes
If not null, than attributes of this item.
|
protected boolean |
bAddOuterResults
see quest method.
|
protected boolean |
bAssignIntoNextComponent
if it is set, the semantic of this component should be assigned into the next component
of the outer prescript.
|
(package private) boolean |
bChildSyntaxAreAlternatives
If it is set, the childSyntaxPrescripts contains some alternative syntax prescripts,
otherwise childSyntaxPrescripts contain the items one after another of this syntax prescript.
|
boolean |
bDebugParsing
Set to stop parsing on this item.
|
(package private) boolean |
bDonotStoreData
If set the parse result and all sub results are not stored as data.
|
protected boolean |
bEntryComponentContainer
If it is set this result is stored in a container (List).
|
(package private) boolean |
bOnlyOneEach
Used in a repetition: The sub syntax is expected only one time though it is possible in the repetition.
|
(package private) boolean |
bStoreAsString
If set the parse result for this item is stored as String from the source immediately.
|
(package private) java.util.List<ZbnfSyntaxPrescript> |
childSyntaxPrescripts
Either List of all syntax items one after another of this node
or List of all alternatives if this is an alternative syntax node.
|
protected ZbnfSyntaxPrescript |
componentSyntax
This element is only set for component syntax call and also on {<?
|
(package private) ZbnfSyntaxPrescript.EType |
eType
Kind of syntay type of the item
|
(package private) int |
lineFile
For debugging and error report: The line in the syntax file.
|
protected java.util.List<java.lang.String> |
listStrings
List of strings used by kStringUntilEndString or null if not used.
|
(package private) double |
nFloatFactor
Float-Factor see attribute kFloatToInt
|
protected int |
nodeIdent
Identification number, auto generated, to store in the founded users syntax tree.
|
(package private) int |
objid |
(package private) static int |
objId_ |
(package private) ZbnfSyntaxPrescript |
parent
To go back for syntax path on error.
|
(package private) LogMessage |
report
LogMessage something
|
private java.lang.String |
sCommentStart1
Comment start to check whether parse terminal syntax as comment.
|
private java.lang.String |
sCommentStart2
Comment start to check whether parse terminal syntax as comment.
|
protected java.lang.String |
sConstantSyntax
A string accordingly to the syntax.
|
protected java.lang.String |
sDefinitionIdent
Identificator of the sub-syntax.
|
protected java.lang.String |
sIndentChars
Indent chars if it is a <*{...}?...
|
protected java.lang.String |
sSemantic
The semantic of this syntax item or null.
|
protected java.lang.String |
sSubSyntax
Required sub-syntax of a syntax component with string result.
|
protected java.lang.String |
sSuperItemType
A string accordingly to the syntax.
|
static java.lang.String |
version
Version, history and license.
|
Modifier | Constructor and Description |
---|---|
private |
ZbnfSyntaxPrescript(LogMessage report,
boolean bWithSyntaxList,
java.lang.String sCommentStart1,
java.lang.String sCommentStart2,
int linefile)
Constructor only fills the data.
|
private |
ZbnfSyntaxPrescript(ZbnfSyntaxPrescript parent,
LogMessage report,
boolean bWithSyntaxList,
int linefile)
Constructor only fills the data.
|
(package private) |
ZbnfSyntaxPrescript(ZbnfSyntaxPrescript parent,
ZbnfSyntaxPrescript.EType type,
int linefile)
Constructor only fills the data.
|
Modifier and Type | Method and Description |
---|---|
private void |
childsAdd(ZbnfSyntaxPrescript child) |
boolean |
childsHasSemantic()
Checks whether any child produces data.
|
(package private) boolean |
convertAssociatedSemantic(StringPartScan spInput)
Converts a associated semantic to the current syntax component.
|
private ZbnfSyntaxPrescript |
convertOptionSyntax(StringPartScan spInput,
boolean bWhiteSpaces,
java.lang.CharSequence sSyntaxOnStartForErrorNothingFoundChild) |
private ZbnfSyntaxPrescript.RepetitionSyntax |
convertRepetitionSyntax(StringPartScan spInput,
boolean bWhiteSpaces,
java.lang.CharSequence sSyntaxOnStartForErrorNothingFoundChild) |
private ZbnfSyntaxPrescript.ComplexSyntax |
convertSyntaxComponent(StringPartScan spInput)
Reads the syntax of an <action>.
|
private void |
convertSyntaxDefinition(StringPartScan spInput)
Converts the whole syntax definition from identifier to the end point.
|
(package private) char |
convertTheStringGivenSyntax(StringPartScan spInput,
java.lang.String charsEnd,
boolean bWhiteSpaces,
java.lang.CharSequence sSyntaxOnStartForErrorNothingFound)
Converts a part of a ZBNF string to given and chars.
|
(package private) static ZbnfSyntaxPrescript |
createWithSyntax(StringPartScan spInput,
java.lang.String sCommentStart1,
java.lang.String sCommentStart2,
LogMessage report)
Creates an tree of instance with the given syntax.
|
java.lang.String |
getAttribute(java.lang.String name)
Reads an attribute of this syntax item.
|
(package private) void |
getAttribute(StringPartScan spInput) |
(package private) java.lang.String |
getConstantSyntax() |
(package private) java.lang.String |
getDefinitionIdent() |
(package private) double |
getFloatFactor()
Returns the factor to multiply for syntax <#f*factor?...
|
(package private) java.lang.String |
getIndentChars()
Returns the possible indent chars if the type is k..WithIndent
or null.
|
java.util.List<ZbnfSyntaxPrescript> |
getListPrescripts()
Gets the list of one alternative prescript inside this instance.
|
(package private) java.util.List<java.lang.String> |
getListStrings() |
(package private) int |
getMaxNrofCharsFromComplexItem()
Gets the really max number of chars.
|
(package private) java.util.regex.Pattern |
getRegexPatternFromComplexItem()
Gets the really max number of chars.
|
(package private) ZbnfSyntaxPrescript |
getRepetitionBackwardPrescript() |
(package private) java.lang.String |
getSemantic()
Returns the semantic of the item.
|
(package private) void |
getSemantic(StringPartScan spInput)
Converts the semantic behind a ?
|
(package private) java.lang.String |
getSubSyntax() |
(package private) ZbnfSyntaxPrescript.EType |
getType() |
(package private) boolean |
hasAlternatives()
Returns true if there are more as one alternative.
|
(package private) boolean |
isAlternative()
Returns true if the Syntax item contains some alternatives getted by getListPrescripts.
|
(package private) boolean |
isPossibleEmptyOption()
Returns true if it is also valid if no input matches to this prescript,
defined by [option1|option2|] or [option]
|
(package private) boolean |
isResultToAssignIntoNextComponent()
Returns true, if the result of the parsing with this Syntaxprescript
is to assigned into the next component of the outer prescript
|
(package private) boolean |
isToAddOuterResults()
Returns true, if outer result of parsing with the outer prescript
are to assigned into this component.
|
(package private) void |
reportContent(LogMessage report,
int nLevel) |
private void |
reportItem(int nLevel,
java.lang.String sIndent,
boolean bHasNext,
LogMessage report) |
(package private) void |
stop()
It's a debug helper.
|
protected void |
throwParseException(StringPartScan spInput,
java.lang.String sMsg)
Central method to invoke excpetion, usefull to set a breakpoint in debug
or to add some standard informations.
|
java.lang.String |
toString()
Shows the content in a readable format for debugging.
|
void |
writeSyntaxStruct(java.lang.Appendable out,
int recursion)
Writes the syntax (
#setSyntax(StringPartScan, String)
in a simple text file using toString()
in a recursively iteration. |
(package private) java.lang.Object |
xxxgetItem(int idx)
Gets an item from list.
|
(package private) ZbnfSyntaxPrescript |
xxxgetRepetitionForwardPrescript()
static boolean isPossibleEmptyOption(Object item)
{ if(item instanceof SyntaxPrescript.OptionSyntax)
{ return ((SyntaxPrescript.OptionSyntax)item).alsoEmptyOption;
}
else return false; //the user may be check if it is an OptionSyntax.
}
static SyntaxPrescript getOptionNextItem(Iterator iter)
{ if(iter.hasNext())
{ return (SyntaxPrescript)(iter.next());
}
else return null; //the user may be check if it is an OptionSyntax.
}
|
(package private) ZbnfSyntaxPrescript |
xxxgetSyntaxPrescript() |
public static final java.lang.String version
bOnlyOneEach
with designation ?& not relevant for parser, only for GenZbnfJavaData
ZbnfSyntaxPrescript.EType.kStoreSrc
as new feature writing <@?semantic>
.
This seems to be the really good variant to store the source to a part of syntax.
#writeSyntaxStruct(Appendable)
as a new feature, should be existing from beginning...
componentSyntax
here existing and set for all syntax rules which uses another syntax component.
It is set in the parser instead searching the syntax component every time again, saves time.
Secondly it contains some important information, especially the implementation type of a result item.
It is used in ZbnfJavaOutput
.
{
writes in sDefinitionIdent
,
because it is the implementation type of this part of repetition. Used for ZbnfJavaOutput
.
sSuperItemType
as a generalizing of a type if items.
This is set either for a component:superType::=definition or for {....
In the next version TODO: if only one item with the same type is stored in the outer level, it is replaced.
GenZbnfJavaData
ZbnfSyntaxPrescript.EType.kOnlyMarker
and not regarded for parsing.
objid
for debugging only. No functional changes.
childsHasSemantic()
for evaluation in GenZbnfJavaData
bEntryComponentContainer
bStoreAsString
and bDonotStoreData
written with <...?"!"semantic>
lineFile
element in all Prescripts, using for ZbnfParser.setDebugPosition(int, int, int)
.
ZbnfSyntaxPrescript.EType
as enum. It is not a functional change
but the EType can contain some more information. It are used for generating a Java Output.java from the syntax proper for ZbnfJavaOutput
.
getAttribute(String)
.
Another approach, indent for text, is processed in jzTc. It may be possible to do that in the parser already?
<...?%...> in Syntax, then bDebugParsing
is set for this item.
It can be tested here to set a specific debug breakpoint for parsing this element. Only for special debugging problems.
2013-09-07 Hartmut new: Now it distinguishs between terminal symbols which are searched in the comment
and normal terminal symbols. All terminal symbols which are to search in comment starts with one of the comment chars
because elsewhere there won't be found because the comment is skipped. Therefore a terminal symbols is checked
whether it starts with a comment string. The comment string is given by the parser script in the first lines.
There are two types now: #kTerminalSymbolInComment
and #kTerminalSymbol
.
2013-09-07 Hartmut chg: usage of StringPartScan#scanTranscriptionToAnyChar(CharSequence[], String, char, char, char)
for constant syntax. There was a bug if a non-end character was transcript, especially "\\<\\:"
2012-10-23 Supports <* |endstring: The parse result is trimmed without leading and trailing white spaces.
New_1.10.005 Hartmut 2011-0118: The ZBNF-syntax supports now a semantic ident
in the construct with inner syntax, in the form ,,<""?!innerSyntax?semantic>,,.
See the ZBNF-description.
In the past there should be a own pseudo syntax-component-definition to give a semantic
in form ,,<""?!pseudoComp>... pseudoComp::=.,, Now it is more easy to apply.
2009-08-20: Hartmut bugfix: "toLastCharIncl:" were skipped over 1 char additionally. fixed.
2009-08-02: Hartmut new: parseExpectedVariant writing [!...] now available. It tests but doesn't processed the content.
2009-03-16: Hartmut new: kFloatWithFactor: noted as <#f*Factor?...> now works.
2009-03-16: Hartmut new: is an alternative notation of 2009-03-16: Hartmut new: is an alternative notation of 2009-03-16: Hartmut chg: <...?*... is not supported anymore, it isn't admissible in syntax scripts up to now.
It was the functionality isToTransportOuterResults(). But this functionality is too complex, difficult to understand and able to handle.
2006-05-00: Hartmut creation
- See Also:
- Constant Field Values
-
objId_
static int objId_
-
objid
final int objid
-
lineFile
final int lineFile
For debugging and error report: The line in the syntax file.
-
eType
ZbnfSyntaxPrescript.EType eType
Kind of syntay type of the item
-
parent
final ZbnfSyntaxPrescript parent
To go back for syntax path on error.
-
sDefinitionIdent
protected java.lang.String sDefinitionIdent
Identificator of the sub-syntax. It is the part before ::=
- If this is a top-level syntax item,
it is the identification disposed at
sDefinitionIdent:==...
.
- If this is a superclass of ComplexSyntax, and the eType == kComplexItem,
it is the name of the required syntax definition,
disposed at
<syntax?...>
.
- If this is a special ComplexSyntax, it is set to a reportable string,
not used for process.
-
sSemantic
protected java.lang.String sSemantic
The semantic of this syntax item or null. It is usually the String after: <...?semantic>
.
- If the item has not a special semantic but the name of the syntax should be used
(written
<cmpn>
), this field contains "@".
- If the item has a special semantic
<cmpn?semantic>
it is contained here.
- If the item is written
<cmpn?>
this field contains null.
In this case an own data container for this component should not be produced,
the data of the component is written in the calling component's data. .
- for an option or repetition it may be the semantic of the parsed string of this whole item (with children):
[<?semantic> ... ]
or {<?semantic> ... }
- If this is an syntax definition for a component
cmpn::=...
either the semantic
is equal the components name
- or it is a given semantic with
cmpn::=<?semantic>...
Then this semantic should be used instead the semantic in the calling item if it contains only "@"
- or it is null if
cmpn::=<?>...
is given for the component.
In this case an own data container for this component should not be produced,
the data of the component is written in the calling component's data.
-
componentSyntax
protected ZbnfSyntaxPrescript componentSyntax
This element is only set for component syntax call and also on {<?semantic:component>
Only if the element is used, then one time searched.
It means for all used ZbnfParserStore.ParseResultItemImplement#parentSyntaxElement
it is referenced it it is a component. (since 2022-02)
-
bDonotStoreData
boolean bDonotStoreData
If set the parse result and all sub results are not stored as data.
They may be usually stored as bStoreAsString
-
bOnlyOneEach
boolean bOnlyOneEach
Used in a repetition: The sub syntax is expected only one time though it is possible in the repetition.
This can be checked while parsing with effort (look if it was parsing before), but this is not done yet in 2022-05.
This option is used especially for GenZbnfJavaData
to create not a List container, only a single instance.
Often it is clarified by another parser that this elements are only contained one time, for example for Java language.
-
bStoreAsString
boolean bStoreAsString
If set the parse result for this item is stored as String from the source immediately.
-
bAssignIntoNextComponent
protected boolean bAssignIntoNextComponent
if it is set, the semantic of this component should be assigned into the next component
of the outer prescript.
-
bEntryComponentContainer
protected boolean bEntryComponentContainer
If it is set this result is stored in a container (List).
If the component is successfully parsed the component is stored multiple for each result in this container.
-
bAddOuterResults
protected boolean bAddOuterResults
see quest method.
-
childSyntaxPrescripts
java.util.List<ZbnfSyntaxPrescript> childSyntaxPrescripts
Either List of all syntax items one after another of this node
or List of all alternatives if this is an alternative syntax node.
It is an alternative syntax node if( (eType & (kAlternative | kAlternativOption...) !=0).
-
bChildSyntaxAreAlternatives
boolean bChildSyntaxAreAlternatives
If it is set, the childSyntaxPrescripts contains some alternative syntax prescripts,
otherwise childSyntaxPrescripts contain the items one after another of this syntax prescript.
alternative syntax prescripts are produced if some ...|...|... are present in source.
-
alsoEmptyOption
private boolean alsoEmptyOption
If it is true, it is also matching if no prescript matches to the parsed input.
-
sConstantSyntax
protected java.lang.String sConstantSyntax
A string accordingly to the syntax. The meaning depends on the type of prescript,
for example the constant string for terminal characters.
-
sSuperItemType
protected java.lang.String sSuperItemType
A string accordingly to the syntax.
If it is set then it is the name of a super class of the stored data.
Data with the same super class can be changed together.
-
listStrings
protected java.util.List<java.lang.String> listStrings
List of strings used by kStringUntilEndString or null if not used.
-
nFloatFactor
double nFloatFactor
Float-Factor see attribute kFloatToInt
-
nodeIdent
protected int nodeIdent
Identification number, auto generated, to store in the founded users syntax tree.
-
attributes
java.util.Map<java.lang.String,java.lang.String> attributes
If not null, than attributes of this item.
-
sSubSyntax
protected java.lang.String sSubSyntax
Required sub-syntax of a syntax component with string result.
If this is a special ComplexSyntax with a string result,
it is the name of the required syntax definition to parse implicitly the string,
disposed at <*...?!syntax>
.
-
sIndentChars
protected java.lang.String sIndentChars
Indent chars if it is a <*{...}?...>-construct.
-
sCommentStart1
private final java.lang.String sCommentStart1
Comment start to check whether parse terminal syntax as comment.
-
sCommentStart2
private final java.lang.String sCommentStart2
Comment start to check whether parse terminal syntax as comment.
-
bDebugParsing
public boolean bDebugParsing
Set to stop parsing on this item. Write <...?%...> to set it. Set breakpoint where bDebugParsing was set or checked.
-
report
final LogMessage report
LogMessage something
-
Constructor Detail
-
ZbnfSyntaxPrescript
private ZbnfSyntaxPrescript(ZbnfSyntaxPrescript parent,
LogMessage report,
boolean bWithSyntaxList,
int linefile)
Constructor only fills the data.
-
ZbnfSyntaxPrescript
private ZbnfSyntaxPrescript(LogMessage report,
boolean bWithSyntaxList,
java.lang.String sCommentStart1,
java.lang.String sCommentStart2,
int linefile)
Constructor only fills the data.
-
ZbnfSyntaxPrescript
ZbnfSyntaxPrescript(ZbnfSyntaxPrescript parent,
ZbnfSyntaxPrescript.EType type,
int linefile)
Constructor only fills the data.
-
Method Detail
-
createWithSyntax
static ZbnfSyntaxPrescript createWithSyntax(StringPartScan spInput,
java.lang.String sCommentStart1,
java.lang.String sCommentStart2,
LogMessage report)
throws java.text.ParseException
Creates an tree of instance with the given syntax. If any parse error occurs
by converting the syntax, a ParseException is thrown.
The input is typically a part of a longer text, the position should be
the beginning of the indent of the syntax term. The position in the Stringpart
is setted on finishing behind the ending point of the syntax term. So next parts
may be parsed outside this method, like other syntax terms or variables.
- Parameters:
spInput
- The syntax as part of a longer text. See Parser.setSyntax(StringPart)
.
report
- To report something.
- Returns:
- the created root instance
- Throws:
java.text.ParseException
- on error of input syntax. The message of the exception
contains a information about the error position.
-
getSemantic
void getSemantic(StringPartScan spInput)
Converts the semantic behind a ? in a <..?..>-Expression.
- Parameters:
spInput
- The input string, the actual position is behind the '?'
in a expression <..?...:...>.
The actual position after work is at the '>'.
-
getAttribute
void getAttribute(StringPartScan spInput)
throws java.text.ParseException
- Throws:
java.text.ParseException
-
stop
void stop()
It's a debug helper. The method is empty, but it is a mark to set a breakpoint.
-
convertSyntaxDefinition
private void convertSyntaxDefinition(StringPartScan spInput)
throws java.text.ParseException
Converts the whole syntax definition from identifier to the end point.
- Parameters:
spInput
- The SBNF string with start position at syntax definition ident.
- Throws:
java.text.ParseException
-
convertAssociatedSemantic
boolean convertAssociatedSemantic(StringPartScan spInput)
throws java.text.ParseException
Converts a associated semantic to the current syntax component.
A associated semantic is given by <?semantic>
on start
of a syntax component. It may be also [<?>
, in this case it is determined
that the component has no semantic, sSemantic is set to null.
semantic may be also "@identifier" or "text()", usefull for XML conversion.
- Parameters:
spInput
-
- Returns:
- the semantic identifier.
- Throws:
java.text.ParseException
-
convertTheStringGivenSyntax
char convertTheStringGivenSyntax(StringPartScan spInput,
java.lang.String charsEnd,
boolean bWhiteSpaces,
java.lang.CharSequence sSyntaxOnStartForErrorNothingFound)
throws java.text.ParseException
Converts a part of a ZBNF string to given and chars.
Called on top level and also nested.
- Parameters:
spInput
- SBNF string at the start position
charsEnd
- one or some end chars.
bWhiteSpaces
- true: than whitespaces in syntax prescript causes whitespaces parsing in input text
false: whitespaces in syntax prescript have no effect.
- Returns:
- The founded end char.
- Throws:
java.text.ParseException
- if the content do not match.
-
convertSyntaxComponent
private ZbnfSyntaxPrescript.ComplexSyntax convertSyntaxComponent(StringPartScan spInput)
throws java.text.ParseException
Reads the syntax of an <action>.
Syntax of this element::=
\<[<#?numberOfChars>]<syntax>[?<$?semantic>]\>
numberOfChars: max number of chars representing this element.
syntax ::= [ #-<?negativeNumber>
| #X<?hexNumber>
| #<?posNumber>
| $<?identifier>[<\.?additionalChars>
| \.<?anyChars>[^\.<exclusiveChars]>
].
It means (examlples)
sample meaning
32$?nameOfSomething>
Identifier with max 32 chars, it is the name of something
#?theNumberOfSomething>
A positiv number, it is the number of something
#-?theNumberOfSomething>
A positiv or negative number, it is the number of something
5#-?theNumberOfSomething>
A positiv or negative number with max 5 chars, it is the number of something
.^}?description>
All chars exclusive }, a description
10$\$&%-?ident>
An identifier with max 10 chars, also $&%- are identifier chars
""?description>
A description written in quotions
- Parameters:
spInput
- string to parse
- Returns:
- The neu ComplexSyntax item
- Throws:
java.text.ParseException
-
convertOptionSyntax
private ZbnfSyntaxPrescript convertOptionSyntax(StringPartScan spInput,
boolean bWhiteSpaces,
java.lang.CharSequence sSyntaxOnStartForErrorNothingFoundChild)
throws java.text.ParseException
- Throws:
java.text.ParseException
-
convertRepetitionSyntax
private ZbnfSyntaxPrescript.RepetitionSyntax convertRepetitionSyntax(StringPartScan spInput,
boolean bWhiteSpaces,
java.lang.CharSequence sSyntaxOnStartForErrorNothingFoundChild)
throws java.text.ParseException
- Throws:
java.text.ParseException
-
childsAdd
private void childsAdd(ZbnfSyntaxPrescript child)
-
xxxgetItem
java.lang.Object xxxgetItem(int idx)
Gets an item from list.
- Parameters:
idx
- Index, starts with 0. T xxx
- Returns:
-
getDefinitionIdent
java.lang.String getDefinitionIdent()
-
getSubSyntax
java.lang.String getSubSyntax()
-
getListPrescripts
public java.util.List<ZbnfSyntaxPrescript> getListPrescripts()
Gets the list of one alternative prescript inside this instance.
This method is used from the parser to test a syntax.
- Parameters:
idx
- Nr of the alternative, 0 for first
- Returns:
- null if no prescript exists for the alternative, otherwise
the list of syntax elements in the prescript.
-
childsHasSemantic
public boolean childsHasSemantic()
Checks whether any child produces data.
- Returns:
- false if no child has a
getSemantic()
-
hasAlternatives
boolean hasAlternatives()
Returns true if there are more as one alternative.
-
reportContent
void reportContent(LogMessage report,
int nLevel)
-
reportItem
private void reportItem(int nLevel,
java.lang.String sIndent,
boolean bHasNext,
LogMessage report)
-
getConstantSyntax
java.lang.String getConstantSyntax()
-
getListStrings
java.util.List<java.lang.String> getListStrings()
-
getSemantic
java.lang.String getSemantic()
Returns the semantic of the item.
- Returns:
- String with semantic.
-
getIndentChars
java.lang.String getIndentChars()
Returns the possible indent chars if the type is k..WithIndent
or null.
- Returns:
- String with the indent chars
-
getFloatFactor
double getFloatFactor()
Returns the factor to multiply for syntax <#f*factor?...>
-
isResultToAssignIntoNextComponent
boolean isResultToAssignIntoNextComponent()
Returns true, if the result of the parsing with this Syntaxprescript
is to assigned into the next component of the outer prescript
-
isToAddOuterResults
boolean isToAddOuterResults()
Returns true, if outer result of parsing with the outer prescript
are to assigned into this component.
-
isAlternative
boolean isAlternative()
Returns true if the Syntax item contains some alternatives getted by getListPrescripts.
- Returns:
- false if getListPrescripts supplies the one after another prescripts of the syntax term.
-
getMaxNrofCharsFromComplexItem
int getMaxNrofCharsFromComplexItem()
Gets the really max number of chars. If the max number is not defined
by textual syntax input, this method supplies the maximal integer value.
- Parameters:
item
- The syntax item.
- Returns:
- Max number, -1 if it is not a ComplexSyntax.
-
getRegexPatternFromComplexItem
java.util.regex.Pattern getRegexPatternFromComplexItem()
Gets the really max number of chars. If the max number is not defined
by textual syntax input, this method supplies the maximal integer value.
- Parameters:
item
- The syntax item.
- Returns:
- Max number, -1 if it is not a ComplexSyntax.
-
getType
ZbnfSyntaxPrescript.EType getType()
-
xxxgetSyntaxPrescript
ZbnfSyntaxPrescript xxxgetSyntaxPrescript()
-
isPossibleEmptyOption
boolean isPossibleEmptyOption()
Returns true if it is also valid if no input matches to this prescript,
defined by [option1|option2|] or [option]
-
xxxgetRepetitionForwardPrescript
ZbnfSyntaxPrescript xxxgetRepetitionForwardPrescript()
static boolean isPossibleEmptyOption(Object item)
{ if(item instanceof SyntaxPrescript.OptionSyntax)
{ return ((SyntaxPrescript.OptionSyntax)item).alsoEmptyOption;
}
else return false; //the user may be check if it is an OptionSyntax.
}
static SyntaxPrescript getOptionNextItem(Iterator iter)
{ if(iter.hasNext())
{ return (SyntaxPrescript)(iter.next());
}
else return null; //the user may be check if it is an OptionSyntax.
}
-
getRepetitionBackwardPrescript
ZbnfSyntaxPrescript getRepetitionBackwardPrescript()
-
getAttribute
public java.lang.String getAttribute(java.lang.String name)
Reads an attribute of this syntax item. An attribute is given by syntax:
<...?.name=value?...>
. Write a dot after the asterisk.
The attribute can be used in evaluating a parse result by the application.
- Parameters:
name
-
- Returns:
-
toString
public java.lang.String toString()
Shows the content in a readable format for debugging.
- Overrides:
toString
in class java.lang.Object
-
throwParseException
protected void throwParseException(StringPartScan spInput,
java.lang.String sMsg)
throws java.text.ParseException
Central method to invoke excpetion, usefull to set a breakpoint in debug
or to add some standard informations.
- Parameters:
sMsg
-
- Throws:
java.lang.IndexOutOfBoundsException
java.text.ParseException
-
writeSyntaxStruct
public void writeSyntaxStruct(java.lang.Appendable out,
int recursion)
throws java.io.IOException
Writes the syntax (#setSyntax(StringPartScan, String)
in a simple text file using toString()
in a recursively iteration. It is interesting to see. Can be improved for details.
This routine writes this Prescript and all sub prescripts from getListPrescripts()
.
- Parameters:
out
- to a Writer, StringBuilder or what ever.
- Throws:
java.io.IOException
- from Appendable.append(char)