SKIP |
Top Previous Next |
Scripts > Productions > SKIP
By means of the SKIP symbol sections of the text, for which there are no explicit rules can be skipped.
Remark: The skipped text is accessible by xState.str() or trim_right_copy( xState.str()).
The key word SKIP is a complex symbol. The meaning depends on the context. It depends on:
1. the alternatives
The SKIP alternative is chosen, if none of the alternatives matches the actual text. The SKIP alternative is chosenIn the production:
( "}" | "]" | SKIP )*
if there is neither a "}" nor a "]" at the actual position of the input.
2. the possible followers
The SKIP symbol matches the text beginning at the actual position and ending at the position, where the text is matched by a symbol, which can follow the SKIP symbol. If there are competing followers, the match at the next position will be chosen.
For example
SKIP ( "]" | "}" )
recognizes in the input
param1, param2 ] }
the text "param1, param2 ", because "]" follows immediately, while "}" follows at a later position. The rule above (point 1) will have the same result. In the first pass of the loop SKIP matches and in the second loop "]" matches. In the third loop "}" will be recognized too. But it must be taken into account, that the match of SKIP depends on the follower of the loop itself. In the following context:
Startrule ::= Rule1 Rule2
Rule1 ::= ( "]" | "}" | SKIP )*
Rule2 ::= "param2"
SKIP only would recognize "param1, ".
Supplementary explanations
Possible conflicts are treated differently depending on the options.
a) Isolation of SKIP and ANY
Occurrences of SKIP symbols must be isolated from each other. A SKIP may not have a second SKIP as alternative and a second SKIP may not follow it directly. The following isn't allowed:
(SKIP | ...) | (SKIP | ...) // wrong
or
(SKIP | ...) ( SKIP | ...) // wrong
ANY mustn't as well immediately follow on SKIP
(SKIP | ...) ( ANY | ...) // wrong
b) SKIP-Repeats
The following cases aren't different, they have the same result:
SKIP? SKIP*
A follower must be found at the actual position or at a later position. In the second case, SKIP is executed once. The case
SKIP+
differs in the circumstance, that there may not be a follower at the actual position, but there must be one at a later position. Again, the SKIP node is executed only once.
c) Konsumation of the ignored characters
The function of the SKIP symbol doesn't depend on the project options! E.g. SKIP EOL will recognize the line end, even if '\r' and '\n' belong to the character, which are to be ignored. While xState.str() after recognition of a normal token provides a text section, that stops before the following ignorable characters, this isn't the case at a text section recognized by SKIP. If the ignored characters are blanks, you can get the corresponding result by
trim_right_copy( xState.str())
d) no dynamic SKIP
The set of tokens, which can follow on SKIP is not dynamically changeable. If a placeholder token, which follows on SKIP, is augmented by a literal, this extension has no effect on the recognitions of the SKIP symbol.
e) naming of skip nodes
The name of a skip node is constructed of "SKIP" and the number, which represents the node in a first set. For example: SKIP12 is a skip node, which is registered in the first set of its superior node by the number 12. |
This page belongs to the TextTransformer Documentation |
Home Content German |