next up previous contents
Next: Patterns Up: Predicates in rules Previous: Target code lines

Pattern match predicates


\begin{verbsyntax}\onerule{PatternMatchStatement}{Variable ('~' \vert 'matches' \vert 'instanceof' \vert '!~') Pattern}
\end{verbsyntax}

As predicates, pattern match statements on rule test nodes (rule test variables) are allowed. A variable is linked to a pattern with the tokens ~, matches, or instanceof. The pattern match statement succeeds if the variable has the form of the pattern. If a variable is linked to a pattern with !~ the pattern match statement succeeds if the variable has not the form of the pattern.
\begin{examplefoot}N ~ Block // node N matches type Block
N instanceof Block //...
... matches type Block
N !~ Block // node N is not of type Block
\end{examplefoot}

In rule transformations pattern matching is not allowed.



 

Uwe Assmann
1998-12-22