このデバッグコードをプログラムに追加します。
firstLine.setName("firstLine").setDebug()
line.setName("line").setDebug()
secondLine.setName("secondLine").setDebug()
searchStringをparseStringに変更します。setDebug()は、式が一致しようとするたびに出力し、一致した場合は一致したもの、一致しなかった場合は例外を出力します。あなたのプログラムで、これらの変更を行った後、私は次のようになります。
Match firstLine at loc 0(1,1)
Matched firstLine -> ['ABC', '.... ']
Match line at loc 11(3,1)
Matched line -> ['DEF ']
Match line at loc 15(3,1)
Exception raised:Expected line (at char 17), (line:4, col:2)
Match secondLine at loc 15(3,1)
Exception raised:Expected "DEF" (at char 16), (line:4, col:1)
Traceback (most recent call last):
File "rrrr.py", line 19, in <module>
test.parseString(myText)
File "C:\Python25\lib\site-packages\pyparsing-1.5.5-py...
raise exc
pyparsing.ParseException: Expected "DEF" (at char 16), (line:4, col:1)
おそらくあなたが期待したものではありません。