本文整理匯總了Python中parser.sequence2st方法的典型用法代碼示例。如果您正苦於以下問題:Python parser.sequence2st方法的具體用法?Python parser.sequence2st怎麽用?Python parser.sequence2st使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類parser
的用法示例。
在下文中一共展示了parser.sequence2st方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_illegal_encoding
# 需要導入模塊: import parser [as 別名]
# 或者: from parser import sequence2st [as 別名]
def test_illegal_encoding(self):
# Illegal encoding declaration
tree = \
(338,
(257, (0, '')))
self.check_bad_tree(tree, "missed encoding")
tree = \
(338,
(257, (0, '')),
b'iso-8859-1')
self.check_bad_tree(tree, "non-string encoding")
tree = \
(338,
(257, (0, '')),
'\udcff')
with self.assertRaises(UnicodeEncodeError):
parser.sequence2st(tree)
示例2: roundtrip
# 需要導入模塊: import parser [as 別名]
# 或者: from parser import sequence2st [as 別名]
def roundtrip(self, f, s):
st1 = f(s)
t = st1.totuple()
try:
st2 = parser.sequence2st(t)
except parser.ParserError, why:
self.fail("could not roundtrip %r: %s" % (s, why))
示例3: check_bad_tree
# 需要導入模塊: import parser [as 別名]
# 或者: from parser import sequence2st [as 別名]
def check_bad_tree(self, tree, label):
try:
parser.sequence2st(tree)
except parser.ParserError:
pass
else:
self.fail("did not detect invalid tree for %r" % label)
示例4: roundtrip
# 需要導入模塊: import parser [as 別名]
# 或者: from parser import sequence2st [as 別名]
def roundtrip(self, f, s):
st1 = f(s)
t = st1.totuple()
try:
st2 = parser.sequence2st(t)
except parser.ParserError as why:
self.fail("could not roundtrip %r: %s" % (s, why))
self.assertEqual(t, st2.totuple(),
"could not re-generate syntax tree")