本文整理汇总了Python中pyparsing.Word.leaveWhitespace方法的典型用法代码示例。如果您正苦于以下问题:Python Word.leaveWhitespace方法的具体用法?Python Word.leaveWhitespace怎么用?Python Word.leaveWhitespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyparsing.Word
的用法示例。
在下文中一共展示了Word.leaveWhitespace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parseExtensible
# 需要导入模块: from pyparsing import Word [as 别名]
# 或者: from pyparsing.Word import leaveWhitespace [as 别名]
def parseExtensible(attr, s):
raise NotImplementedError()
from pyparsing import Word, Literal, Optional, ZeroOrMore, Suppress, \
Group, Forward, OneOrMore, ParseException, \
CharsNotIn, Combine, StringStart, \
StringEnd, delimitedList
import string
filter_ = Forward()
attr = Word(string.ascii_letters,
string.ascii_letters + string.digits + ';-',)
attr.leaveWhitespace()
attr.setName('attr')
hexdigits = Word(string.hexdigits, exact=2)
hexdigits.setName('hexdigits')
escaped = Suppress(Literal('\\')) + hexdigits
escaped.setName('escaped')
def _p_escaped(s, l, t):
text = t[0]
return chr(int(text, 16))
escaped.setParseAction(_p_escaped)
value = Combine(OneOrMore(CharsNotIn('*()\\\0') | escaped))
value.setName('value')
示例2: oneOf
# 需要导入模块: from pyparsing import Word [as 别名]
# 或者: from pyparsing.Word import leaveWhitespace [as 别名]
compare_operators = oneOf("< > = >= <=")
valname = alphanums + "-_${}+"
# version number
# vnum = Word(nums) + Optional(Word(alphanums + ".-_"))
# It seems like j3.134l.i is a valid version number...
# It is not allowed, but some PKGBUILDs seem to contain hyphens (freeorion)
vnum = Word(alphanums + "._-")
# a valid name for a package
val_package_name = Combine(Word(alphas + "".join((valname, "."))))
pkgname = Literal("pkgname=") + (opQuotedString(val_package_name)
| "(" + opQuotedString(val_package_name) + ")")
pkgver = Literal("pkgver=") + vnum.leaveWhitespace() + LineEnd()
pkgrel = Literal("pkgrel=") + Word(nums)
epoch = Literal("epoch=") + Word(nums)
pkgdesc = Literal("pkgdesc=") + (QuotedString(quoteChar="'", multiline=True) | QuotedString(quoteChar='"', multiline=True))
screenshot = "screenshot=" + quotedString
# define a valid architecture
valid_arch = opQuotedString(Word(valname))
arch = Array("arch", OneOrMore(valid_arch), valid_arch)