本文整理汇总了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")