/usr/share/pyshared/simpleparse/tests/test_deep_nesting.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 | from simpleparse.simpleparsegrammar import Parser
from simpleparse.stt.TextTools import TextTools
import pprint
from genericvalues import NullResult, AnyInt
declaration = r'''testparser := as?
as := a,as?
a := 'a'
'''
testdata = 'aaaa'
expectedResult = (1, [
('as', 0, 4, [
('a', 0, 1, NullResult),
('as', 1, 4, [
('a', 1, 2, NullResult),
('as', 2, 4, [
('a', 2, 3, NullResult),
('as', 3, 4, [
('a', 3, 4, NullResult)
])
])
])
])
], 4)
parser = Parser( declaration ).generator.buildParser( 'testparser' )
print "About to attempt the deep-nesting test"
print "If python goes into an infinite loop, then the test failed ;) "
print
result = TextTools.tag( testdata, parser )
if result != expectedResult:
print 'test-deep-nesting failed'
print '\texpected', expectedResult
print '\tgot', result
else:
print "test-deep-nesting succeeded!\nYou're probably using the non-recursive mx.TextTools rewrite"
|