本文整理匯總了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)