EOF in TreeTop?

D

Day

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
 
C

Clifford Heath

Day said:
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.
 
D

Day

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top