本文整理汇总了Python中pyparsing.stringEnd方法的典型用法代码示例。如果您正苦于以下问题:Python pyparsing.stringEnd方法的具体用法?Python pyparsing.stringEnd怎么用?Python pyparsing.stringEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyparsing
的用法示例。
在下文中一共展示了pyparsing.stringEnd方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import stringEnd [as 别名]
def __init__(self):
"""
Create a parser that parse arithmetic expressions. They can
contains variable identifiers or raw numbers. The meaning
for the identifiers is left to the
"""
number = p.Regex(r'\d+(\.\d*)?([eE]\d+)?')
identifier = p.Word(p.alphas)
terminal = identifier | number
self._expr = p.infixNotation(terminal, [
(p.oneOf('* /'), 2, p.opAssoc.LEFT),
(p.oneOf('+ -'), 2, p.opAssoc.LEFT)
]) + p.stringEnd()
示例2: __hasDeclEnd
# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import stringEnd [as 别名]
def __hasDeclEnd(self, line):
if not self.declEnd:
import pyparsing as p
self.declEnd = p.Literal("`") + p.stringEnd
self.declEnd.ignore(p.pythonStyleComment)
self.declEnd.ignore(p.quotedString)
if self.declEnd.searchString(line.strip()):
return True
return False
示例3: sub_expr_list
# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import stringEnd [as 别名]
def sub_expr_list(self):
# Remove all spaces before parsing. Simple, quick fix for whitespace
# issue with dimension list not allowing whitespace after comma.
parse_result = (expression + pyparsing.stringEnd).parseString(
self._expr)
sub_expr_list = parse_result[0].operands_list
return sub_expr_list
示例4: split_by_commas
# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import stringEnd [as 别名]
def split_by_commas(value):
"""Split values by commas and quotes according to api-wg
:param value: value to be split
.. versionadded:: 3.17
"""
word = (pp.QuotedString(quoteChar='"', escChar='\\') |
pp.Word(pp.printables, excludeChars='",'))
grammar = pp.stringStart + pp.delimitedList(word) + pp.stringEnd
try:
return list(grammar.parseString(value))
except pp.ParseException:
raise ValueError("Invalid value: %s" % value)