Go to the first, previous, next, last section, table of contents.


Redefining Patterns

This is not for the faint hearted. You can skip to the next part (see section RDBMS Queries).

Sometimes the input text does not match an awk like structure. In this case the patterns defining how to process the input can be changed. This is done using the PATTERN predefined macro. This takes five arguments. The example below shows the pattern definitions to process awk like input (these are built in to grg).

%%PATTERN	"<awk><nul>" "<nul>" "" "<awk><sor>" "<sor>"
%%PATTERN	"<awk><sor>" "<wht>" "" "<awk><sor>" "<nul>"
%%PATTERN	"<awk><sor>" "<nul>" "" "<awk><sof>" "<sof>"
%%PATTERN	"<awk><sof>" "<del>" "" "<awk><sor>" "<eof>"
%%PATTERN	"<awk><sof>" "<any>" "" "<awk><sof>" "<fld>"
%%PATTERN	"<awk><sof>" "<nul>" "" "<awk><sor>" "<eof>"
%%PATTERN	"<awk><sor>" "<new>" "" "<awk><nul>" "<eor>"

The arguments are as follows. The first argument is the mode context. Each pattern can only apply if the current mode is the same as its mode context. The default mode is <awk><nul>, and therefore in the above only the first pattern will match. The second argument is the tokens in the text that must be present for the pattern to match, this is discussed in more detail later. The third argument is an equate expression that will be run if the pattern matched, this can then also have a say in whether the pattern matches or not. The fourth argument is the new mode to enter if the pattern matches. The fifth argument is the token to return to the parser if the pattern matches. These arguments are now discussed in more detail. Note that the first three arguments essentially define what the pattern to match is and the last two define what steps to take if the pattern does match.


Go to the first, previous, next, last section, table of contents.