# module pyparsing.py
#
# Copyright (c) 2003-2016 Paul T. McGuire
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
__doc__ = \
"""
pyparsing module - Classes and methods to define and execute parsing grammars
The pyparsing module is an alternative approach to creating and executing simple grammars,
vs. the traditional lex/yacc approach, or the use of regular expressions. With pyparsing, you
don't need to learn a new syntax for defining grammars or matching expressions - the parsing module
provides a library of classes that you use to construct the grammar directly in Python.
Here is a program to parse "Hello, World!" (or any greeting of the form
C{"<salutation>, <addressee>!"}), built up using L{Word}, L{Literal}, and L{And} elements
(L{'+'<ParserElement.__add__>} operator gives L{And} expressions, strings are auto-converted to
L{Literal} expressions)::
from pip._vendor.pyparsing import Word, alphas
# define grammar of a greeting
greet = Word(alphas) + "," + Word(alphas) + "!"
hello = "Hello, World!"
print (hello, "->", greet.parseString(hello))
The program outputs the following::
Hello, World! -> ['Hello', ',', 'World', '!']
The Python representation of the grammar is quite readable, owing to the self-explanatory
class names, and the use of '+', '|' and '^' operators.
The L{ParseResults} object returned from L{ParserElement.parseString<ParserElement.parseString>} can be accessed as a nested list, a dictionary, or an
object with named attributes.
The pyparsing module handles some of the problems that are typically vexing when writing text parsers:
- extra or missing whitespace (the above program will also handle "Hello,World!", "Hello , World !", etc.)
- quoted strings
- embedded comments
"""
__version__ = "2.2.0"
__versionTime__ = "06 Mar 2017 02:06 UTC"
__author__ = "Paul McGuire <ptmcg@users.sourceforge.net>"
import string
from weakref import ref as wkref
import copy
import sys
import warnings
import re
import sre_constants
import collections
import pprint
import traceback
import types
from datetime import datetime
try:
from _thread import RLock
except ImportError:
from threading import RLock
try:
from collections import OrderedDict as _OrderedDict
except ImportError:
try:
from ordereddict import OrderedDict as _OrderedDict
except ImportError:
_OrderedDict = None
#~ sys.stderr.write( "testing pyparsing module, version %s, %s\n" % (__version__,__versionTime__ ) )
__all__ = [
'And', 'CaselessKeyword', 'CaselessLiteral', 'CharsNotIn', 'Combine', 'Dict', 'Each', 'Empty',
'FollowedBy', 'Forward', 'GoToColumn', 'Group', 'Keyword', 'LineEnd', 'LineStart', 'Literal',
'MatchFirst', 'NoMatch', 'NotAny', 'OneOrMore', 'OnlyOnce', 'Optional', 'Or',
'ParseBaseException', 'ParseElementEnhance', 'ParseException', 'ParseExpression', 'ParseFatalException',
'ParseResults', 'ParseSyntaxException', 'ParserElement', 'QuotedString', 'RecursiveGrammarException',
'Regex', 'SkipTo', 'StringEnd', 'StringStart', 'Suppress', 'Token', 'TokenConverter',
'White', 'Word', 'WordEnd', 'WordStart', 'ZeroOrMore',
'alphanums', 'alphas', 'alphas8bit', 'anyCloseTag', 'anyOpenTag', 'cStyleComment', 'col',
'commaSeparatedList', 'commonHTMLEntity', 'countedArray', 'cppStyleComment', 'dblQuotedString',
'dblSlashComment', 'delimitedList', 'dictOf', 'downcaseTokens', 'empty', 'hexnums',
'htmlComment', 'javaStyleComment', 'line', 'lineEnd', 'lineStart', 'lineno',
'makeHTMLTags', 'makeXMLTags', 'matchOnlyAtCol', 'matchPreviousExpr', 'matchPreviousLiteral',
'nestedExpr', 'nullDebugAction', 'nums', 'oneOf', 'opAssoc', 'operatorPrecedence', 'printables',
'punc8bit', 'pythonStyleComment', 'quotedString', 'removeQuotes', 'replaceHTMLEntity',
'replaceWith', 'restOfLine', 'sglQuotedString', 'srange', 'stringEnd',
'stringStart', 'traceParseAction', 'unicodeString', 'upcaseTokens', 'withAttribute',
'indentedBlock', 'originalTextFor', 'ungroup', 'infixNotation','locatedExpr', 'withClass',
'CloseMatch', 'tokenMap', 'pyparsing_common',
]
system_version = tuple(sys.version_info)[:3]
PY_3 = system_version[0] == 3
if PY_3:
_MAX_INT = sys.maxsize
basestring = str
unichr = chr
_ustr = str
# build list of single arg builtins, that can be used as parse actions
singleArgBuiltins = [sum, len, sorted, reversed, list, tuple, set, any, all, min, max]
else:
_MAX_INT = sys.maxint
range = xrange
def _ustr(obj):
"""Drop-in replacement for str(obj) that tries to be Unicode friendly. It first tries
str(obj). If that fails with a UnicodeEncodeError, then it tries unicode(obj). It
then < returns the unicode object | encodes it with the default encoding | ... >.
"""
if isinstance(obj,unicode):
return obj
try:
# If this works, then _ustr(obj) has the same behaviour as str(obj), so
# it won't break any existing code.
return str(obj)
except UnicodeEncodeError:
# Else encode it
ret = unicode(obj).encode(sys.getdefaultencoding(), 'xmlcharrefreplace')
xmlcharref = Regex(r'&#\d+;')
xmlcharref.setParseAction(lambda t: '\\u' + hex(int(t[0][2:-1]))[2:])
return xmlcharref.transformString(ret)
# build list of single arg builtins, tolerant of Python version, that can be used as parse actions
singleArgBuiltins = []
import __builtin__
for fname in "sum len sorted reversed list tuple set any all min max".split():
try:
singleArgBuiltins.append(getattr(__builtin__,fname))
except AttributeError:
continue
_generatorType = type((y for y in range(1)))
def _xml_escape(data):
"""Escape &, <, >, ", ', etc. in a string of data."""
# ampersand must be replaced first
from_symbols = '&><"\''
to_symbols = ('&'+s+';' for s in "amp gt lt quot apos".split())
for from_,to_ in zip(from_symbols, to_symbols):
data = data.replace(from_, to_)
return data
class _Constants(object):
pass
alphas = string.ascii_uppercase + string.ascii_lowercase
nums = "0123456789"
hexnums = nums + "ABCDEFabcdef"
alphanums = alphas + nums
_bslash = chr(92)
printables = "".join(c for c in string.printable if c not in string.whitespace)
class ParseBaseException(Exception):
"""base exception class for all parsing runtime exceptions"""
# Performance tuning: we construct a *lot* of these, so keep this
# constructor as small and fast as possible
def __init__( self, pstr, loc=0, msg=None, elem=None ):
self.loc = loc
if msg is None:
self.msg = pstr
self.pstr = ""
else:
self.msg = msg
self.pstr = pstr
self.parserElement = elem
self.args = (pstr, loc, msg)
@classmethod
def _from_exception(cls, pe):
"""
internal factory method to simplify creating one type
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
- 不懂运行,下载完可以私聊问,可远程教学 该资源内项目源码是个人的毕设,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! <项目介绍> 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。 --------
资源推荐
资源详情
资源评论
收起资源包目录
基于Hadoop+Spark+Django的LSH电影推荐系统+源码+文档说明 (2000个子文件)
style.css 148KB
bootstrap.css 138KB
animate.css 69KB
base.css 62KB
aui.css 58KB
common-less.css 46KB
font-awesome.css 34KB
mobiscroll.css 25KB
common-less.css 21KB
mooc.css 20KB
responsive.css 18KB
select2.css 17KB
course-comment.css 16KB
base.css 16KB
select2.min.css 15KB
layer.css 11KB
cityLayout.css 10KB
widgets.css 10KB
learn-less.css 9KB
login.css 9KB
forms.css 8KB
autocomplete.css 8KB
popuo-box.css 7KB
changelists.css 6KB
laydate.css 6KB
easy-responsive-tabs.css 6KB
table-style.css 5KB
zoomslider.css 5KB
lq.datetimepick.css 5KB
base.css 4KB
owl.carousel.css 4KB
rtl.css 4KB
laydate.css 3KB
layer.ext.css 3KB
reset.css 3KB
list.css 2KB
responsive_rtl.css 2KB
login.css 1KB
basictable.css 942B
ol3.css 657B
fonts.css 423B
dashboard.css 412B
_embedding.h 16KB
_cffi_include.h 12KB
parse_c_type.h 6KB
_cffi_errors.h 4KB
base.html 48KB
index.html 35KB
technical_500.html 17KB
default_urlconf.html 16KB
content.html 8KB
comments.html 6KB
register.html 5KB
login.html 5KB
tabular.html 4KB
base.html 4KB
index.html 3KB
change_form.html 3KB
change_list.html 3KB
technical_404.html 2KB
delete_confirmation.html 2KB
change_password.html 2KB
delete_selected_confirmation.html 2KB
stacked.html 2KB
password_change_form.html 2KB
openlayers.html 2KB
login.html 2KB
openlayers.html 2KB
model_detail.html 2KB
fieldset.html 2KB
template_filter_index.html 2KB
related_widget_wrapper.html 2KB
template_tag_index.html 2KB
view_index.html 2KB
change_list_results.html 2KB
object_history.html 1KB
related_widget_wrapper.html 1KB
password_reset_confirm.html 1KB
bookmarklets.html 1KB
model_index.html 1KB
index.html 1KB
actions.html 1KB
search_form.html 1020B
submit_line.html 1011B
template_detail.html 995B
password_reset_form.html 966B
view_detail.html 896B
missing_docutils.html 734B
password_change_done.html 671B
password_reset_done.html 669B
password_reset_email.html 582B
clearable_file_input.html 568B
pagination.html 553B
500.html 527B
date_hierarchy.html 518B
password_reset_complete.html 505B
multiple_input.html 462B
clearable_file_input.html 461B
clearable_file_input.html 461B
invalid_setup.html 437B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
机器学习的喵
- 粉丝: 2025
- 资源: 1783
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于Springboot+Vue疫情打卡健康评测系统-毕业源码案例设计(源码+项目说明+演示视频).zip
- 基于Springboot+Vue校园失物招领系统-毕业源码案例设计(高分毕业设计).zip
- 北京市各项指标.xlsx
- 基于Springboot+Vue新冠病毒密接者跟踪系统-毕业源码案例设计(高分项目).zip
- 机械设计电池焊脚检测设备sw18可编辑非常好的设计图纸100%好用.zip
- 基于Springboot+Vue校园疫情防控系统-毕业源码案例设计(源码+论文).zip
- 基于Springboot+Vue新闻稿件管理系统-毕业源码案例设计(高分毕业设计).zip
- 基于Springboot+Vue新闻资讯系统-毕业源码案例设计(95分以上).zip
- 基于Springboot+Vue学科竞赛报名管理系统毕业源码案例设计(源码+数据库).zip
- 基于Springboot+Vue学生评奖评优管理系统-毕业源码案例设计(高分毕业设计).zip
- Comsol冻土路基水热力源文件 该文件建立了路基水热耦合计算控制方程, 利用COMSOL 软件二次开发实现了路基冻胀融沉问题的水热耦合计算 本案例建立成二维模型,物理场采用两个PDE模块和固体力学
- 基于Springboot+Vue学生宿舍管理系统毕业源码案例设计(源码+论文).zip
- 基于Springboot+Vue学生网上请假系统设计与实现-毕业源码案例设计(源码+项目说明+演示视频).zip
- 基于Springboot+Vue学生宿舍信息系统-毕业源码案例设计(高分毕业设计).zip
- 基于Springboot+Vue学生选课系统-毕业源码案例设计(95分以上).zip
- GPT-SoVITS-WebUI
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功