Re: PLY problem.
[email protected] Wed, 18 Jun 2003 09:23:20 +0200 (CEST)
| Newsgroups | gmane.comp.python.parser |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 17 Jun 2003, H Jansen wrote:
> The correct regular expression for a C-style comment in PLY seems to be:
knowing nothing about PLY, but in re this means
either "/* any character but no newline */"
or "/*\n*/".
> # C-style comment
>
> def t_comment(t):
> r'\/\*(.|\n)*?\*\/'
> t.lineno += t.value.count('\n')
>
> Since no return value is passed, the lexer should ignore this. However,
> when parsing the multiline comment
>
>
> """
>
> /* O
> K */
>
> """
>
>
> the lexer issues the following error:
>
> ...
> (<function t_newline at 0x4054317c>, 'newline')
>
>
> None /* O
> K */
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "/usr/tmp/python-XYAtGu.py", line 148, in ?
> yacc.parse(s, lexer=lexer, debug=1)
> File "yacc.py", line 197, in parse
> lookahead = get_token() # Get the next token
> File "lex.py", line 307, in realtoken
> # If token is processed by a function, call it
> TypeError: unpack non-sequence
> >>>
>
>
> Anybody a guess what's wrong?
--
BINGO: Sind Sie flexibel?
--- Engelbert Gruber -------+
SSG Fintl,Gruber,Lassnig /
A6170 Zirl Innweg 5b /
Tel. ++43-5238-93535 ---+