Creator of ParseKit here. ParseKit does not have a Channels
feature, nor does it have a ->
tree rewrite feature as ANTLR does. (In general, ParseKit is not as fully-featured as ANTLR).
However, you can probably achieve the effect you are looking for using ParseKit's discard feature.
When designing your ParseKit grammar, there are often tokens in your language which are pure syntax. These tokens are not important for computing a result nor for building an abstract syntax tree (for further processing). You'll usually want to automatically discard these tokens using the ParseKit !
directive.
For example, say you have a rule in your ParseKit grammar called primaryExpr
like:
primaryExpr = atom
| '(' expr ')'!
;
Notice the !
after the close parenthesis ')'
. This is the discard directive which instructs the ParseKit tokenizer to discard the )
token from the token stream reported to your ParseKit assembler (delegate) callbacks.
So in your -parser:didMatchPrimaryExpr:
callback, the assembly
parameter's stack will not contain the )
token. The )
token will have already been discarded. Discarding is desirable in this case, as the )
is pure syntax which is not important for processing the relevant parenthesized expression.
So to discard an unimportant token in your grammar, place a !
directive immediately after it.