On Tue, Aug 26, 2008 at 8:15 AM, Francesco Bochicchio
<[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I'd like to use PLY to parse a grammar which includes multi-line
> comments bounded by the '|' symbol.
> The following scanner rule only works for single-line comments:
>
> t_DOCSTRING = r'\|.*\|'
>
> Anybody knows if it is possible to define multi-line tokens in
> ply.lex? I also tried removing '\n' from t_ignore
> and making it a special token (which I'm not sure is suitable for me,
> since it would make the syntax rules
> way too complicate), but still does not work.

This is my rule for skipping C-style multi-line comments:

def t_MCOMMENT(t):
    r'/\*(.|\n)*?\*/'
    t.lineno += t.value.count('\n')

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to