|
|||||
|
|||||
Related Concepts | |||||
control structure |
do skip |
Syntax
do skip ((past numeric-expression) | (over pattern) | (past numeric-expression over pattern)) local-declaration* action* (else local-declaration* action*)? done
An action that offers an efficient way of skipping selected blocks of data.
The block of input to be skipped by a do skip
action is described by specifying its length as a numeric-expression or the pattern that terminates it. When both are given, the specified number of characters are skipped first, then the do skip
action looks for the pattern.
A common application for the do skip
action is skipping header information. For example, the following rule will skip over the four characters following the matched "HEADER/", also skipping up to and over the next slash character:
find "HEADER/" do skip past 4 done do skip over "/" done
A do skip
action with no actions in it simply continues with the following action, whether or not it succeeded.
In a do skip...over
action, any pattern variables are available for use only within the actions up to the else
or done
keyword, whichever comes first. The relationship between the pattern and the actions is the same as that between the pattern and the actions in a match
part of a do scan
action.
The following code illustrates where the pattern variable "last-word" can and cannot be referenced:
translate "*HEADER/" do skip over (word-start letter* word-end) => last-word "/" output last-word ; allowed else output last-word ; not allowed done output last-word ; not allowed
over
and lookahead
can be combined in a do skip
:
do skip past 4 over lookahead "/" done
Related Concepts |
Copyright © Stilo International plc, 1988-2010.