次のコード
text = QuotedString(quoteChar="(", endQuoteChar=")", escChar="\\")
text.leaveWhitespace()
def test_hex_with_backslashN_code(self):
self.assertEqual(text.parseString("(\x01\x0a)")[0], "(\x01\x0a)")
例外をトリガーします。
ParseException: Expected quoted string, starting with ( ending with ) (at char 0), (line:1, col:1)
"\x0a" hex 値は '\n' として解釈され、leaveWhitespace 呼び出しでも通常の文字として考慮されないためです。
SkipTo も試しましたが、次のようなエスケープされた内側のブラケットを処理できませんでした。
"( I am \( John \))"
パーサーで
text = "(" + SkipTo(")")
それを修正/回避する方法はありますか?