Arguments to subrules
start: word rev[$item[1]] {1}
rev: word {$return = 1 if $arg [0] eq reverse $item [1]; undef}
word: /\w+/
In [1] := foo oof
Out [1] = 1
In [2] := foo bar
Out [2] = <<UNDEF>>
- Subrules can be called with arguments.
- Arguments are places inside square brackets.
- The arguments are in the subrule available as @arg or as
%arg.
- Both @arg and %arg are always available - one is free
to use whatever method one prefers.
- Arguments come before repetition specifier:
rule: sub other[$item[1]](s)
[Prev]
[Next]
[Index]