EOF in TreeTop?

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

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 H…

On Feb 15, 2008 3:24 PM, Clifford H. [email protected] wrote:

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