Coming into this a bit late ...
On Aug 26 Francesco Bochicchio asked:
> Anybody knows if it is possible to define multi-line tokens in ply.lex?
I see some people pointed out more complex regular expression for
that.
A different solution I've used is with parser states. When you see
the start of a comment, switch to an exclusive state. Something like
the following untested snippets:
states = (
("COMMENT", "exclusive"),
)
def t_start_comment(t):
r" \| '"
t.lexer.push_state("COMMENT")
def t_COMMENT_contents(t):
r"[^|]*"
def t_COMMENT_end(t):
r" \| "
t.lexer.pop_state()
This approach also lets you do things like report if the comment is
unterminated, or support structured comments (a la Javadoc) embedded
inside.
Andrew
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ply-hack" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/ply-hack?hl=en
-~----------~----~----~----~------~----~------~--~---