documenting PLYed parsers

Diez B. Roggisch deetsNOSPAM at web.de
Thu Nov 4 07:36:21 EST 2004


Maurice LING wrote:

> Hi,
> 
> I am using PLY (Python-Lex-Yacc) to write my parsers. However, it seems
> to me that PLY is using comments (especially multiline comments) in the
> Yacc component such as
> 
> def p_expression(p):
> '''expression : term PLUS term'''
> ...
> 
> So I was thinking about how can I document my codes, which can be
> processed by epydoc or happydoc? Will my comments, enclosed by ''',
> interferes with PLY?
> 
> Any comments?

How about trying it? I use spark, which utilizes comment strings, too - but
as it simply loops over the comment lines and tries to use them as grammar
rules without bailing out if a line isn't a grammar rule, I can happily put
comments in there.

And after all, you don't need to comment using the doc-string, you can use
#.  And I personally believe that a parser doesn't need to be
api-documented on every grammar rule, so you don't lose anything here.
-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list