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