[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

EOF in TreeTop?

Day

2/15/2008 3:55:00 PM

I ran into a problem writing my praser: there's a comment in the last
line of my file and I'd defined comments to be '*' followed by
anything that's not a newline followed by a newline. The final comment
isn't followed by a newline (it might be, but it doesn't have to be),
so I need to tell TreeTop that comments can go until newline or end of
file, but the treetop web page doesn't seem to indicate a symbol for
EOF. I'm not at home and can't put subversion on this machine, so I
can't mess with it until I figure it out just now, so I thought I'd
see if anyone knew off the top of their head... I'm looking for
something like this, I think:

rule comment
'*' (!"\n" !eof .)* ("\n" / eof)
end

Thanks.


Ben

2 Answers

Clifford Heath

2/15/2008 9:24:00 PM

0

Day wrote:
> see if anyone knew off the top of their head... I'm looking for
> something like this, I think:
>
> rule comment
> '*' (!"\n" !eof .)* ("\n" / eof)
> end

This should work for detecting eof:

rule eof
! .
end

You might simplify by defining end of comment:

rule eoc
"\n" / eof
end

Then comment becomes:

rule comment
'*' (!eoc .)* eoc
end

Clifford Heath.

Day

2/15/2008 10:50:00 PM

0

On Feb 15, 2008 3:24 PM, Clifford Heath <no@spam.please.net> wrote:
> This should work for detecting eof:
>
> rule eof
> ! .
> end
>
> You might simplify by defining end of comment:
>
> rule eoc
> "\n" / eof
> end
>
> Then comment becomes:
>
> rule comment
> '*' (!eoc .)* eoc
> end

Nice! I'll try it out this evening. It never occured to me that EOF
would be "not anything". Sort of a funny concept. Thanks!


Ben