Next / Previous / Contents / Shipman's homepage

7.6. cppStyleComment: Parser for C++ comments

The variable pp.cppStyleComment is a parser that matches a comment in the C++ language. Comments may be either the old C style (see Section 7.4, “cStyleComment: Match a C-language comment”) or the newer C++ style (see Section 7.8, “dblSlashComment: Parser for a comment that starts with “//””).

>>> text = '// Look out of the yard? What will we see?'
>>> print pp.cppStyleComment.parseString(text)
['// Look out of the yard? What will we see?']
>>> print pp.cppStyleComment.parseString('/* Author: R. J. Gumby */')
['/* Author: R. J. Gumby */']