otac0n / Pegasus

A PEG parser generator for .NET that integrates with MSBuild and Visual Studio.

Home Page:http://otac0n.com/Pegasus/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting cursor position inside productions

frabert opened this issue · comments

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?

You can refer to the variable state instead.