End of input

25 views
Skip to first unread message

Rob Nichols

unread,
Feb 14, 2017, 5:15:05 PM2/14/17
to Treetop Development
How do I detect that an element is the last one?

For example, if I parse the text "one two three" how can I create a rule which pulls out "three" because it is the last in the list. I've tried using "\n" for end of line, but that fails I think because there is not carriage return in "one two three".

Clifford Heath

unread,
Feb 14, 2017, 5:37:23 PM2/14/17
to treet...@googlegroups.com
On 15 Feb 2017, at 12:53 AM, Rob Nichols <r...@nicholshayes.co.uk> wrote:
> How do I detect that an element is the last one?

Using a trick: You need to say, effectively "not anything":

rule end_of_input
! .
end

> For example, if I parse the text "one two three" how can I create a rule which pulls out "three" because it is the last in the list. I've tried using "\n" for end of line, but that fails I think because there is not carriage return in "one two three".
>
> --
> You received this message because you are subscribed to the Google Groups "Treetop Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to treetop-dev...@googlegroups.com.
> To post to this group, send email to treet...@googlegroups.com.
> Visit this group at https://groups.google.com/group/treetop-dev.
> For more options, visit https://groups.google.com/d/optout.

Rob Nichols

unread,
Feb 24, 2017, 5:57:27 AM2/24/17
to Treetop Development
Thank you Clifford. That's what I needed!
Reply all
Reply to author
Forward
0 new messages