I'm actually rusty at this, but I think the most direct way is to use the
"start" and "length" item descriptors in an array descriptor to get input
stream start location and length in characters:
http://search.cpan.org/~jkegl/Marpa-R2/pod/Semantics.pod#Array_descriptor_actions

To convert input stream locations to line/column locations, you can use the
$recce->line_column() method:
http://search.cpan.org/~jkegl/Marpa-R2/pod/Scanless/R.pod#line_column()

I hope this helps! -- jeffrey

On Sun, Mar 26, 2017 at 7:23 PM, stefan <[email protected]> wrote:

> Hi, folks.
>
> I'm a MARPA newbie, so my apologies if I am asking a question which is too
> obvious.
>
> I have a prototype parser for a DSL - my customer needs me to deliver an
> AST for it, where each node knows the line number (and perhaps even column
> number) at which that expression or construct began in the input stream.
>
> I have pored over the copious MARPA documentation and commentary by users,
> but I haven't yet understood how I can do this.
>
> I thought perhaps I could attach an event to every terminal, and have the
> event callback ask the parser where it is in the input stream? If so, I'm
> not even sure how to do that.
>
> I would be grateful for any advice.
>
> -stefan
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "marpa parser" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"marpa parser" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to