/usr/share/doc/python-simpleparse-doc/examples/simpleexample2_3.py is in python-simpleparse-doc 2.1.0a1-6.
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 | """Re-written version of simpleexample for 2.0"""
from simpleparse.common import numbers, strings, comments
declaration = r'''# note use of raw string when embedding in python code...
file := [ \t\n]*, section+
section := '[',identifier,']', ts,'\n', body
body := statement*
statement := (ts,semicolon_comment)/equality/nullline
nullline := ts,'\n'
equality := ts, identifier,ts,'=',ts,identified,ts,'\n'
identifier := [a-zA-Z], [a-zA-Z0-9_]*
identified := string/number/identifier
ts := [ \t]*
'''
testData = """[test1]
val=23
val2="23"
val3 = "23\t\nskidoo\xee"
wherefore="art thou"
; why not
log = heavy_wood
[test2]
loose=lips
"""
from simpleparse.parser import Parser
import pprint
parser = Parser( declaration, "file" )
if __name__ =="__main__":
pprint.pprint( parser.parse( testData))
|