|
| |
| Navigation |
Synopsis Node in abstract pattern.
Syntax
Name ( Pat1, Pat2, ..., Patn )
Description A node pattern matches a node value or a datatype value, provided that
Name matches with the constructor symbol of that value
and Pat1, Pat2, ..., Patn match the children of that value in order.
Examples Match on node values (recall that the function symbol of a node has to be quoted, see Values/Node):
rascal>import IO; ok rascal>if("f"(A,13,B) := "f"("abc", 13, false)) >>>>>>> println("A = <A>, B = <B>"); A = abc, B = false okDefine a data type and use it to match: rascal>data Color = red(int N) | black(int N); ok rascal>if(red(K) := red(13)) >>>>>>> println("K = <K>"); K = 13 ok |