I have the following code definition:
type Tree* = ref ...
type Parser* = ref object
hooks: Table[string, proc(it: var Tree)]
template hook*(this: var Parser, rule: string, body: untyped) =
this.hooks[rule] = proc(it: var Tree) =
body
But I get an error "Error: undeclared identifier: 'it'" when trying to use it like:
let gp: Parser = ...
gp.hook("Value"):
echo $it
I expect this to be translated to:
gp.hooks["Value"] = proc(it: var Tree) =
echo $it
And this works fine.