Getting cursor position inside productions
frabert opened this issue · comments
Francesco Bertolaccini commented
I need to build an AST for a language, and I need it to contain information about the original source, like token position etc.
How would I do so?
I tried doing so:
block <Block>
= {{ var block = new Block() { File = cursor.FileName, Row = cursor.Line, Column = cursor.Column }; return block; }}
But the compiler yelled at me saying I can't refer to ref cursor
in an anonymous method or lambda. How would I do so?
John Gietzen commented
You can refer to the variable state
instead.