/usr/share/pyshared/simpleparse/common/comments.py is in python-simpleparse 2.1.0a1-6build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | """Common comment formats
To process, handle the "comment" production,
(the specific named comment formats are all
expanded productions, so you won't get them
returned for processing).
hash_comment
# to EOL comments
slashslash_comment
// to EOL comments
semicolon_comment
; to EOL comments
slashbang_comment
c_comment
non-nesting /* */ comments
slashbang_nest_comment
c_nest_comment
nesting /* /* */ */ comments
"""
from simpleparse.parser import Parser
from simpleparse import common, objectgenerator
from simpleparse.common import chartypes
c = {}
eolcomments = r"""
### comment formats where the comment goes
### from a marker to the end of the line
comment := -'\012'*
<EOL> := ('\r'?,'\n')/EOF
>hash_comment< := '#', comment, EOL
>semicolon_comment< := ';', comment, EOL
>slashslash_comment< := '//', comment, EOL
"""
_p = Parser( eolcomments )
for name in ["hash_comment", "semicolon_comment", "slashslash_comment"]:
c[ name ] = objectgenerator.LibraryElement(
generator = _p._generator,
production = name,
)
ccomments = r"""
### comments in format /* comment */ with no recursion allowed
comment := -"*/"*
>slashbang_comment< := '/*', comment, '*/'
"""
_p = Parser( ccomments )
for name in ["c_comment","slashbang_comment"]:
c[ name ] = objectgenerator.LibraryElement(
generator = _p._generator,
production = "slashbang_comment",
)
nccomments = r"""
### nestable C comments of form /* comment /* innercomment */ back to previous */
<comment_start> := '/*'
<comment_stop> := '*/'
comment := (-(comment_stop/comment_start)+/slashbang_nest_comment)*
>slashbang_nest_comment< := comment_start, comment, comment_stop
"""
_p = Parser( nccomments )
for name in ["c_nest_comment","slashbang_nest_comment"]:
c[ name ] = objectgenerator.LibraryElement(
generator = _p._generator,
production = "slashbang_nest_comment",
)
common.share(c)
|