Next / Previous / Contents / Shipman's homepage

7.11. javaStyleComment: Comments in Java syntax

The variable pp.javaStyleComment matches a comment in one of two styles, either Section 7.4, “cStyleComment: Match a C-language comment” or Section 7.6, “cppStyleComment: Parser for C++ comments”. Note that the “//” style comment always ends at the end of the line.

>>> print pp.javaStyleComment.parseString('''/*
... multiline comment */''')
['/*\nmultiline comment */']
>>> print pp.javaStyleComment.parseString('''// This comment
... intentionally left almost blank\n''')
['// This comment']