| 1 | # -*- coding: utf-8 -*- |
| 2 | # module pyparsing.py |
| 3 | # |
| 4 | # |
| 5 | # Note: We keep pyparsing 2.4 in here because this is what DaCHS |
| 6 | # assumes, and pyparsing has had some nasty incompatible changes |
| 7 | # in the past. DaCHS will still use the operating system's pyparsing |
| 8 | # by default. |
| 9 | # |
| 10 | # If DaCHS more complex parsers (in particular ADQL and STC-S) fail with |
| 11 | # your platform's pyparsing, as a quick fallback define the environment |
| 12 | # variable (e.g., GAVO_BUILTIN_PYPARSING=1 dachs...; DaCHS will |
| 13 | # then use this known-good version. |
| 14 | # |
| 15 | # |
| 16 | # Copyright (c) 2003-2019 Paul T. McGuire |
| 17 | # |
| 18 | # Permission is hereby granted, free of charge, to any person obtaining |
| 19 | # a copy of this software and associated documentation files (the |
| 20 | # "Software"), to deal in the Software without restriction, including |
| 21 | # without limitation the rights to use, copy, modify, merge, publish, |
| 22 | # distribute, sublicense, and/or sell copies of the Software, and to |
| 23 | # permit persons to whom the Software is furnished to do so, subject to |
| 24 | # the following conditions: |
| 25 | # |
| 26 | # The above copyright notice and this permission notice shall be |
| 27 | # included in all copies or substantial portions of the Software. |
| 28 | # |
| 29 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 30 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 31 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 32 | # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 33 | # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 34 | # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 35 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 36 | # |
| 37 | |
| 38 | __doc__scip-python python python-stdlib 3.11 builtins/__doc__# = \ |
| 39 | """ |
| 40 | pyparsing module - Classes and methods to define and execute parsing grammars |
| 41 | ============================================================================= |
| 42 | |
| 43 | The pyparsing module is an alternative approach to creating and |
| 44 | executing simple grammars, vs. the traditional lex/yacc approach, or the |
| 45 | use of regular expressions. With pyparsing, you don't need to learn |
| 46 | a new syntax for defining grammars or matching expressions - the parsing |
| 47 | module provides a library of classes that you use to construct the |
| 48 | grammar directly in Python. |
| 49 | |
| 50 | Here is a program to parse "Hello, World!" (or any greeting of the form |
| 51 | ``"<salutation>, <addressee>!"``), built up using :class:`Word`, |
| 52 | :class:`Literal`, and :class:`And` elements |
| 53 | (the :class:`'+'<ParserElement.__add__>` operators create :class:`And` expressions, |
| 54 | and the strings are auto-converted to :class:`Literal` expressions):: |
| 55 | |
| 56 | from pyparsing import Word, alphas |
| 57 | |
| 58 | # define grammar of a greeting |
| 59 | greet = Word(alphas) + "," + Word(alphas) + "!" |
| 60 | |
| 61 | hello = "Hello, World!" |
| 62 | print (hello, "->", greet.parseString(hello)) |
| 63 | |
| 64 | The program outputs the following:: |
| 65 | |
| 66 | Hello, World! -> ['Hello', ',', 'World', '!'] |
| 67 | |
| 68 | The Python representation of the grammar is quite readable, owing to the |
| 69 | self-explanatory class names, and the use of '+', '|' and '^' operators. |
| 70 | |
| 71 | The :class:`ParseResults` object returned from |
| 72 | :class:`ParserElement.parseString` can be |
| 73 | accessed as a nested list, a dictionary, or an object with named |
| 74 | attributes. |
| 75 | |
| 76 | The pyparsing module handles some of the problems that are typically |
| 77 | vexing when writing text parsers: |
| 78 | |
| 79 | - extra or missing whitespace (the above program will also handle |
| 80 | "Hello,World!", "Hello , World !", etc.) |
| 81 | - quoted strings |
| 82 | - embedded comments |
| 83 | |
| 84 | |
| 85 | Getting Started - |
| 86 | ----------------- |
| 87 | Visit the classes :class:`ParserElement` and :class:`ParseResults` to |
| 88 | see the base classes that most other pyparsing |
| 89 | classes inherit from. Use the docstrings for examples of how to: |
| 90 | |
| 91 | - construct literal match expressions from :class:`Literal` and |
| 92 | :class:`CaselessLiteral` classes |
| 93 | - construct character word-group expressions using the :class:`Word` |
| 94 | class |
| 95 | - see how to create repetitive expressions using :class:`ZeroOrMore` |
| 96 | and :class:`OneOrMore` classes |
| 97 | - use :class:`'+'<And>`, :class:`'|'<MatchFirst>`, :class:`'^'<Or>`, |
| 98 | and :class:`'&'<Each>` operators to combine simple expressions into |
| 99 | more complex ones |
| 100 | - associate names with your parsed results using |
| 101 | :class:`ParserElement.setResultsName` |
| 102 | - access the parsed data, which is returned as a :class:`ParseResults` |
| 103 | object |
| 104 | - find some helpful expression short-cuts like :class:`delimitedList` |
| 105 | and :class:`oneOf` |
| 106 | - find more useful common expressions in the :class:`pyparsing_common` |
| 107 | namespace class |
| 108 | """ |
| 109 | |
| 110 | __version__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__version__. = "2.4.7" |
| 111 | __versionTime__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__versionTime__. = "30 Mar 2020 00:43 UTC" |
| 112 | __author__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__author__. = "Paul McGuire <[email protected]>" |
| 113 | |
| 114 | import stringscip-python python python-stdlib 3.11 string/__init__: |
| 115 | from weakrefscip-python python python-stdlib 3.11 weakref/__init__: import ref as wkrefscip-python python python-stdlib 3.11 _weakref/ref. |
| 116 | import copyscip-python python python-stdlib 3.11 copy/__init__: |
| 117 | import sysscip-python python python-stdlib 3.11 sys/__init__: |
| 118 | import warningsscip-python python python-stdlib 3.11 warnings/__init__: |
| 119 | import rescip-python python python-stdlib 3.11 re/__init__: |
| 120 | import sre_constantsscip-python python python-stdlib 3.11 sre_constants/__init__: |
| 121 | import collectionsscip-python python python-stdlib 3.11 collections/__init__: |
| 122 | import pprintscip-python python python-stdlib 3.11 pprint/__init__: |
| 123 | import tracebackscip-python python python-stdlib 3.11 traceback/__init__: |
| 124 | import typesscip-python python python-stdlib 3.11 types/__init__: |
| 125 | from datetimescip-python python python-stdlib 3.11 datetime/__init__: import datetimescip-python python python-stdlib 3.11 datetime/datetime# |
| 126 | from operatorscip-python python python-stdlib 3.11 operator/__init__: import itemgetterscip-python python python-stdlib 3.11 _operator/itemgetter# |
| 127 | import itertoolsscip-python python python-stdlib 3.11 itertools/__init__: |
| 128 | from functoolsscip-python python python-stdlib 3.11 functools/__init__: import wrapsscip-python python python-stdlib 3.11 functools/wraps(). |
| 129 | from contextlibscip-python python python-stdlib 3.11 contextlib/__init__: import contextmanagerscip-python python python-stdlib 3.11 contextlib/contextmanager(). |
| 130 | |
| 131 | try: |
| 132 | # Python 3 |
| 133 | from itertoolsscip-python python python-stdlib 3.11 itertools/__init__: import filterfalsescip-python python python-stdlib 3.11 itertools/filterfalse# |
| 134 | except ImportErrorscip-python python python-stdlib 3.11 builtins/ImportError#: |
| 135 | from itertoolsscip-python python python-stdlib 3.11 itertools/__init__: import ifilterfalse as filterfalse |
| 136 | |
| 137 | try: |
| 138 | from _threadscip-python python python-stdlib 3.11 _thread/__init__: import RLock |
| 139 | except ImportErrorscip-python python python-stdlib 3.11 builtins/ImportError#: |
| 140 | from threadingscip-python python python-stdlib 3.11 threading/__init__: import RLock |
| 141 | |
| 142 | try: |
| 143 | # Python 3 |
| 144 | from collections.abcscip-python python python-stdlib 3.11 `collections.abc`/__init__: import Iterablescip-python python python-stdlib 3.11 typing/Iterable# |
| 145 | from collections.abcscip-python python python-stdlib 3.11 `collections.abc`/__init__: import MutableMappingscip-python python python-stdlib 3.11 typing/MutableMapping#, Mappingscip-python python python-stdlib 3.11 typing/Mapping# |
| 146 | except ImportErrorscip-python python python-stdlib 3.11 builtins/ImportError#: |
| 147 | # Python 2.7 |
| 148 | from collectionsscip-python python python-stdlib 3.11 collections/__init__: import Iterablescip-python python python-stdlib 3.11 typing/Iterable# |
| 149 | from collectionsscip-python python python-stdlib 3.11 collections/__init__: import MutableMappingscip-python python python-stdlib 3.11 typing/MutableMapping#, Mappingscip-python python python-stdlib 3.11 typing/Mapping# |
| 150 | |
| 151 | try: |
| 152 | from collectionsscip-python python python-stdlib 3.11 collections/__init__: import OrderedDict as _OrderedDictscip-python python python-stdlib 3.11 collections/OrderedDict# |
| 153 | except ImportErrorscip-python python python-stdlib 3.11 builtins/ImportError#: |
| 154 | try: |
| 155 | from ordereddictscip-python python gavodachs 2.13 ordereddict/__init__: import OrderedDict as _OrderedDict |
| 156 | except ImportErrorscip-python python python-stdlib 3.11 builtins/ImportError#: |
| 157 | _OrderedDictscip-python python python-stdlib 3.11 collections/OrderedDict# = None |
| 158 | |
| 159 | try: |
| 160 | from typesscip-python python python-stdlib 3.11 types/__init__: import SimpleNamespacescip-python python python-stdlib 3.11 types/SimpleNamespace# |
| 161 | except ImportErrorscip-python python python-stdlib 3.11 builtins/ImportError#: |
| 162 | class SimpleNamespacescip-python python python-stdlib 3.11 types/SimpleNamespace#: pass |
| 163 | |
| 164 | # version compatibility configuration |
| 165 | __compat__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__compat__. = SimpleNamespacescip-python python python-stdlib 3.11 types/SimpleNamespace#() |
| 166 | __compat__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__compat__..__doc__scip-python python python-stdlib 3.11 builtins/__doc__# = """ |
| 167 | A cross-version compatibility configuration for pyparsing features that will be |
| 168 | released in a future version. By setting values in this configuration to True, |
| 169 | those features can be enabled in prior versions for compatibility development |
| 170 | and testing. |
| 171 | |
| 172 | - collect_all_And_tokens - flag to enable fix for Issue #63 that fixes erroneous grouping |
| 173 | of results names when an And expression is nested within an Or or MatchFirst; set to |
| 174 | True to enable bugfix released in pyparsing 2.3.0, or False to preserve |
| 175 | pre-2.3.0 handling of named results |
| 176 | """ |
| 177 | __compat__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__compat__..collect_all_And_tokens = True |
| 178 | |
| 179 | __diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__. = SimpleNamespacescip-python python python-stdlib 3.11 types/SimpleNamespace#() |
| 180 | __diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__..__doc__scip-python python python-stdlib 3.11 builtins/__doc__# = """ |
| 181 | Diagnostic configuration (all default to False) |
| 182 | - warn_multiple_tokens_in_named_alternation - flag to enable warnings when a results |
| 183 | name is defined on a MatchFirst or Or expression with one or more And subexpressions |
| 184 | (only warns if __compat__.collect_all_And_tokens is False) |
| 185 | - warn_ungrouped_named_tokens_in_collection - flag to enable warnings when a results |
| 186 | name is defined on a containing expression with ungrouped subexpressions that also |
| 187 | have results names |
| 188 | - warn_name_set_on_empty_Forward - flag to enable warnings whan a Forward is defined |
| 189 | with a results name, but has no contents defined |
| 190 | - warn_on_multiple_string_args_to_oneof - flag to enable warnings whan oneOf is |
| 191 | incorrectly called with multiple str arguments |
| 192 | - enable_debug_on_named_expressions - flag to auto-enable debug on all subsequent |
| 193 | calls to ParserElement.setName() |
| 194 | """ |
| 195 | __diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__..warn_multiple_tokens_in_named_alternation = False |
| 196 | __diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__..warn_ungrouped_named_tokens_in_collection = False |
| 197 | __diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__..warn_name_set_on_empty_Forward = False |
| 198 | __diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__..warn_on_multiple_string_args_to_oneof = False |
| 199 | __diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__..enable_debug_on_named_expressions = False |
| 200 | __diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__.._all_names = [nm for nm in varsscip-python python python-stdlib 3.11 builtins/vars().(__diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__.) if nm.startswithscip-python python python-stdlib 3.11 builtins/str#startswith().("enable_") or nm.startswithscip-python python python-stdlib 3.11 builtins/str#startswith().("warn_")] |
| 201 | |
| 202 | def _enable_all_warningsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_enable_all_warnings().(): |
| 203 | __diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__..warn_multiple_tokens_in_named_alternation = True |
| 204 | __diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__..warn_ungrouped_named_tokens_in_collection = True |
| 205 | __diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__..warn_name_set_on_empty_Forward = True |
| 206 | __diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__..warn_on_multiple_string_args_to_oneof = True |
| 207 | __diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__..enable_all_warnings = _enable_all_warningsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_enable_all_warnings(). |
| 208 | |
| 209 | |
| 210 | __all__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__all__. = ['__version__', '__versionTime__', '__author__', '__compat__', '__diag__', |
| 211 | 'And', 'CaselessKeyword', 'CaselessLiteral', 'CharsNotIn', 'Combine', 'Dict', 'Each', 'Empty', |
| 212 | 'FollowedBy', 'Forward', 'GoToColumn', 'Group', 'Keyword', 'LineEnd', 'LineStart', 'Literal', |
| 213 | 'PrecededBy', 'MatchFirst', 'NoMatch', 'NotAny', 'OneOrMore', 'OnlyOnce', 'Optional', 'Or', |
| 214 | 'ParseBaseException', 'ParseElementEnhance', 'ParseException', 'ParseExpression', 'ParseFatalException', |
| 215 | 'ParseResults', 'ParseSyntaxException', 'ParserElement', 'QuotedString', 'RecursiveGrammarException', |
| 216 | 'Regex', 'SkipTo', 'StringEnd', 'StringStart', 'Suppress', 'Token', 'TokenConverter', |
| 217 | 'White', 'Word', 'WordEnd', 'WordStart', 'ZeroOrMore', 'Char', |
| 218 | 'alphanums', 'alphas', 'alphas8bit', 'anyCloseTag', 'anyOpenTag', 'cStyleComment', 'col', |
| 219 | 'commaSeparatedList', 'commonHTMLEntity', 'countedArray', 'cppStyleComment', 'dblQuotedString', |
| 220 | 'dblSlashComment', 'delimitedList', 'dictOf', 'downcaseTokens', 'empty', 'hexnums', |
| 221 | 'htmlComment', 'javaStyleComment', 'line', 'lineEnd', 'lineStart', 'lineno', |
| 222 | 'makeHTMLTags', 'makeXMLTags', 'matchOnlyAtCol', 'matchPreviousExpr', 'matchPreviousLiteral', |
| 223 | 'nestedExpr', 'nullDebugAction', 'nums', 'oneOf', 'opAssoc', 'operatorPrecedence', 'printables', |
| 224 | 'punc8bit', 'pythonStyleComment', 'quotedString', 'removeQuotes', 'replaceHTMLEntity', |
| 225 | 'replaceWith', 'restOfLine', 'sglQuotedString', 'srange', 'stringEnd', |
| 226 | 'stringStart', 'traceParseAction', 'unicodeString', 'upcaseTokens', 'withAttribute', |
| 227 | 'indentedBlock', 'originalTextFor', 'ungroup', 'infixNotation', 'locatedExpr', 'withClass', |
| 228 | 'CloseMatch', 'tokenMap', 'pyparsing_common', 'pyparsing_unicode', 'unicode_set', |
| 229 | 'conditionAsParseAction', 're', |
| 230 | ] |
| 231 | |
| 232 | system_versionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/system_version. = tuplescip-python python python-stdlib 3.11 builtins/tuple#(sysscip-python python python-stdlib 3.11 sys/__init__:.version_infoscip-python python python-stdlib 3.11 sys/version_info.version_info.)[:3] |
| 233 | PY_3scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PY_3. = system_versionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/system_version.[0] == 3 |
| 234 | if PY_3scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PY_3.: |
| 235 | _MAX_INTscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MAX_INT. = sysscip-python python python-stdlib 3.11 sys/__init__:.maxsizescip-python python python-stdlib 3.11 sys/maxsize.maxsize. |
| 236 | basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring. = strscip-python python python-stdlib 3.11 builtins/str# |
| 237 | unichrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unichr. = chr |
| 238 | unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode. = strscip-python python python-stdlib 3.11 builtins/str# |
| 239 | _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr. = strscip-python python python-stdlib 3.11 builtins/str# |
| 240 | |
| 241 | # build list of single arg builtins, that can be used as parse actions |
| 242 | singleArgBuiltinsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/singleArgBuiltins. = [sumscip-python python python-stdlib 3.11 builtins/sum()., len, sortedscip-python python python-stdlib 3.11 builtins/sorted()., reversedscip-python python python-stdlib 3.11 builtins/reversed#, listscip-python python python-stdlib 3.11 builtins/list#, tuplescip-python python python-stdlib 3.11 builtins/tuple#, setscip-python python python-stdlib 3.11 builtins/set#, any, all, minscip-python python python-stdlib 3.11 builtins/min()., maxscip-python python python-stdlib 3.11 builtins/max().] |
| 243 | |
| 244 | else: |
| 245 | _MAX_INTscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MAX_INT. = sysscip-python python python-stdlib 3.11 sys/__init__:.maxint |
| 246 | rangescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/range. = xrange |
| 247 | |
| 248 | def _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(objscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr().(obj)): |
| 249 | """Drop-in replacement for str(obj) that tries to be Unicode |
| 250 | friendly. It first tries str(obj). If that fails with |
| 251 | a UnicodeEncodeError, then it tries unicode(obj). It then |
| 252 | < returns the unicode object | encodes it with the default |
| 253 | encoding | ... >. |
| 254 | """ |
| 255 | if isinstance(objscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr().(obj), unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode.): |
| 256 | return objscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr().(obj) |
| 257 | |
| 258 | try: |
| 259 | # If this works, then _ustr(obj) has the same behaviour as str(obj), so |
| 260 | # it won't break any existing code. |
| 261 | return strscip-python python python-stdlib 3.11 builtins/str#(objscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr().(obj)) |
| 262 | |
| 263 | except UnicodeEncodeErrorscip-python python python-stdlib 3.11 builtins/UnicodeEncodeError#: |
| 264 | # Else encode it |
| 265 | ret = unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode.(objscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr().(obj)).encodescip-python python python-stdlib 3.11 builtins/str#encode().(sysscip-python python python-stdlib 3.11 sys/__init__:.getdefaultencodingscip-python python python-stdlib 3.11 sys/getdefaultencoding().(), 'xmlcharrefreplace') |
| 266 | xmlcharref = Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r'&#\d+;') |
| 267 | xmlcharref.setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(lambda t: '\\u' + hex(intscip-python python python-stdlib 3.11 builtins/int#(t[0][2:-1]))[2:]) |
| 268 | return xmlcharref.transformStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#transformString().(ret) |
| 269 | |
| 270 | # build list of single arg builtins, tolerant of Python version, that can be used as parse actions |
| 271 | singleArgBuiltinsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/singleArgBuiltins. = [] |
| 272 | import __builtin__ |
| 273 | |
| 274 | for fnamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/fname. in "sum len sorted reversed list tuple set any all min max".splitscip-python python python-stdlib 3.11 builtins/str#split().(): |
| 275 | try: |
| 276 | singleArgBuiltinsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/singleArgBuiltins..appendscip-python python python-stdlib 3.11 builtins/list#append().(getattrscip-python python python-stdlib 3.11 builtins/getattr().(__builtin__, fnamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/fname.)) |
| 277 | except AttributeErrorscip-python python python-stdlib 3.11 builtins/AttributeError#: |
| 278 | continue |
| 279 | |
| 280 | _generatorTypescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_generatorType. = typescip-python python python-stdlib 3.11 builtins/type#((y for y in rangescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/range.(1))) |
| 281 | |
| 282 | def _xml_escapescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_xml_escape().(datascip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_xml_escape().(data)): |
| 283 | """Escape &, <, >, ", ', etc. in a string of data.""" |
| 284 | |
| 285 | # ampersand must be replaced first |
| 286 | from_symbols = '&><"\'' |
| 287 | to_symbols = ('&' + s + ';' for s in "amp gt lt quot apos".splitscip-python python python-stdlib 3.11 builtins/str#split().()) |
| 288 | for from_, to_ in zipscip-python python python-stdlib 3.11 builtins/zip#(from_symbols, to_symbols): |
| 289 | datascip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_xml_escape().(data) = datascip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_xml_escape().(data).replace(from_, to_) |
| 290 | return datascip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_xml_escape().(data) |
| 291 | |
| 292 | alphasscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/alphas. = stringscip-python python python-stdlib 3.11 string/__init__:.ascii_uppercasescip-python python python-stdlib 3.11 string/ascii_uppercase.ascii_uppercase. + stringscip-python python python-stdlib 3.11 string/__init__:.ascii_lowercasescip-python python python-stdlib 3.11 string/ascii_lowercase.ascii_lowercase. |
| 293 | numsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nums. = "0123456789" |
| 294 | hexnumsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/hexnums. = numsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nums. + "ABCDEFabcdef" |
| 295 | alphanumsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/alphanums. = alphasscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/alphas. + numsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nums. |
| 296 | _bslashscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_bslash. = chr(92) |
| 297 | printablesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/printables. = "".joinscip-python python python-stdlib 3.11 builtins/str#join().(c for c in stringscip-python python python-stdlib 3.11 string/__init__:.printablescip-python python python-stdlib 3.11 string/printable.printable. if c not in stringscip-python python python-stdlib 3.11 string/__init__:.whitespacescip-python python python-stdlib 3.11 string/whitespace.whitespace.) |
| 298 | |
| 299 | |
| 300 | def conditionAsParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().(fnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().(fn), messagescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().(message)=None, fatalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().(fatal)=False): |
| 301 | msg = messagescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().(message) if messagescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().(message) is not None else "failed user-defined condition" |
| 302 | exc_type = ParseFatalExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseFatalException# if fatalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().(fatal) else ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException# |
| 303 | fnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().(fn) = _trim_arityscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().(fnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().(fn)) |
| 304 | |
| 305 | @wrapsscip-python python python-stdlib 3.11 functools/wraps().(fnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().(fn)) |
| 306 | def pascip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().pa().(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().pa().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().pa().(l), tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().pa().(t)): |
| 307 | if not boolscip-python python python-stdlib 3.11 builtins/bool#(fnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().(fn)(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().pa().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().pa().(l), tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().pa().(t))): |
| 308 | raise exc_type(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().pa().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().pa().(l), msg) |
| 309 | |
| 310 | return pascip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().pa(). |
| 311 | |
| 312 | class ParseBaseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#(Exceptionscip-python python python-stdlib 3.11 builtins/Exception#): |
| 313 | """base exception class for all parsing runtime exceptions""" |
| 314 | # Performance tuning: we construct a *lot* of these, so keep this |
| 315 | # constructor as small and fast as possible |
| 316 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(self), pstrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(pstr), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(loc)=0, msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(msg)=None, elemscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(elem)=None): |
| 317 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(self).locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#loc. = locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(loc) |
| 318 | if msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(msg) is None: |
| 319 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(self).msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#msg. = pstrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(pstr) |
| 320 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(self).pstrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#pstr. = "" |
| 321 | else: |
| 322 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(self).msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#msg. = msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(msg) |
| 323 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(self).pstrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#pstr. = pstrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(pstr) |
| 324 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(self).parserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#parserElement. = elemscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(elem) |
| 325 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(self).argsscip-python python python-stdlib 3.11 builtins/BaseException#args. = (pstrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(pstr), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(loc), msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__init__().(msg)) |
| 326 | |
| 327 | @classmethodscip-python python python-stdlib 3.11 builtins/classmethod# |
| 328 | def _from_exceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#_from_exception().(clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#_from_exception().(cls), pescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#_from_exception().(pe)): |
| 329 | """ |
| 330 | internal factory method to simplify creating one type of ParseException |
| 331 | from another - avoids having __init__ signature conflicts among subclasses |
| 332 | """ |
| 333 | return clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#_from_exception().(cls)(pescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#_from_exception().(pe).pstr, pescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#_from_exception().(pe).loc, pescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#_from_exception().(pe).msg, pescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#_from_exception().(pe).parserElement) |
| 334 | |
| 335 | def __getattr__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__getattr__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__getattr__().(self), anamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__getattr__().(aname)): |
| 336 | """supported attributes by name are: |
| 337 | - lineno - returns the line number of the exception text |
| 338 | - col - returns the column number of the exception text |
| 339 | - line - returns the line containing the exception text |
| 340 | """ |
| 341 | if anamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__getattr__().(aname) == "lineno": |
| 342 | return linenoscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/lineno().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__getattr__().(self).locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#loc., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__getattr__().(self).pstrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#pstr.) |
| 343 | elif anamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__getattr__().(aname) in ("col", "column"): |
| 344 | return colscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/col().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__getattr__().(self).locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#loc., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__getattr__().(self).pstrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#pstr.) |
| 345 | elif anamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__getattr__().(aname) == "line": |
| 346 | return linescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/line().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__getattr__().(self).locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#loc., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__getattr__().(self).pstrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#pstr.) |
| 347 | else: |
| 348 | raise AttributeErrorscip-python python python-stdlib 3.11 builtins/AttributeError#(anamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__getattr__().(aname)) |
| 349 | |
| 350 | def __str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__str__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__str__().(self)): |
| 351 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__str__().(self).pstrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#pstr.: |
| 352 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__str__().(self).locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#loc. >= len(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__str__().(self).pstrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#pstr.): |
| 353 | foundstr = ', found end of text' |
| 354 | else: |
| 355 | foundstr = (', found %r' % selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__str__().(self).pstrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#pstr.[selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__str__().(self).locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#loc.:selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__str__().(self).locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#loc. + 1]).replacescip-python python python-stdlib 3.11 builtins/str#replace().(r'\\', '\\') |
| 356 | else: |
| 357 | foundstr = '' |
| 358 | return ("%s%s (at char %d), (line:%d, col:%d)" % |
| 359 | (selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__str__().(self).msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#msg., foundstr, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__str__().(self).locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#loc., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__str__().(self).lineno, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__str__().(self).column)) |
| 360 | def __repr__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__repr__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__repr__().(self)): |
| 361 | return _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__repr__().(self)) |
| 362 | def markInputlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#markInputline().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#markInputline().(self), markerStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#markInputline().(markerString)=">!<"): |
| 363 | """Extracts the exception line from the input string, and marks |
| 364 | the location of the exception with a special symbol. |
| 365 | """ |
| 366 | line_str = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#markInputline().(self).line |
| 367 | line_column = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#markInputline().(self).column - 1 |
| 368 | if markerStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#markInputline().(markerString): |
| 369 | line_str = "".joinscip-python python python-stdlib 3.11 builtins/str#join().((line_str[:line_column], |
| 370 | markerStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#markInputline().(markerString), line_str[line_column:])) |
| 371 | return line_str.stripscip-python python python-stdlib 3.11 builtins/str#strip().() |
| 372 | def __dir__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__dir__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__dir__().(self)): |
| 373 | return "lineno col line".splitscip-python python python-stdlib 3.11 builtins/str#split().() + dir(typescip-python python python-stdlib 3.11 builtins/type#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#__dir__().(self))) |
| 374 | |
| 375 | class ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(ParseBaseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#): |
| 376 | """ |
| 377 | Exception thrown when parse expressions don't match class; |
| 378 | supported attributes by name are: |
| 379 | - lineno - returns the line number of the exception text |
| 380 | - col - returns the column number of the exception text |
| 381 | - line - returns the line containing the exception text |
| 382 | |
| 383 | Example:: |
| 384 | |
| 385 | try: |
| 386 | Word(nums).setName("integer").parseString("ABC") |
| 387 | except ParseException as pe: |
| 388 | print(pe) |
| 389 | print("column: {}".format(pe.col)) |
| 390 | |
| 391 | prints:: |
| 392 | |
| 393 | Expected integer (at char 0), (line:1, col:1) |
| 394 | column: 1 |
| 395 | |
| 396 | """ |
| 397 | |
| 398 | @staticmethodscip-python python python-stdlib 3.11 builtins/staticmethod# |
| 399 | def explainscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#explain().(excscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#explain().(exc), depthscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#explain().(depth)=16): |
| 400 | """ |
| 401 | Method to take an exception and translate the Python internal traceback into a list |
| 402 | of the pyparsing expressions that caused the exception to be raised. |
| 403 | |
| 404 | Parameters: |
| 405 | |
| 406 | - exc - exception raised during parsing (need not be a ParseException, in support |
| 407 | of Python exceptions that might be raised in a parse action) |
| 408 | - depth (default=16) - number of levels back in the stack trace to list expression |
| 409 | and function names; if None, the full stack trace names will be listed; if 0, only |
| 410 | the failing input line, marker, and exception string will be shown |
| 411 | |
| 412 | Returns a multi-line string listing the ParserElements and/or function names in the |
| 413 | exception's stack trace. |
| 414 | |
| 415 | Note: the diagnostic output will include string representations of the expressions |
| 416 | that failed to parse. These representations will be more helpful if you use `setName` to |
| 417 | give identifiable names to your expressions. Otherwise they will use the default string |
| 418 | forms, which may be cryptic to read. |
| 419 | |
| 420 | explain() is only supported under Python 3. |
| 421 | """ |
| 422 | import inspectscip-python python python-stdlib 3.11 inspect/__init__: |
| 423 | |
| 424 | if depthscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#explain().(depth) is None: |
| 425 | depthscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#explain().(depth) = sysscip-python python python-stdlib 3.11 sys/__init__:.getrecursionlimitscip-python python python-stdlib 3.11 sys/getrecursionlimit().() |
| 426 | ret = [] |
| 427 | if isinstance(excscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#explain().(exc), ParseBaseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#): |
| 428 | ret.appendscip-python python python-stdlib 3.11 builtins/list#append().(excscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#explain().(exc).line) |
| 429 | ret.appendscip-python python python-stdlib 3.11 builtins/list#append().(' ' * (excscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#explain().(exc).col - 1) + '^') |
| 430 | ret.appendscip-python python python-stdlib 3.11 builtins/list#append().("{0}: {1}".format(typescip-python python python-stdlib 3.11 builtins/type#(excscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#explain().(exc)).__name__scip-python python python-stdlib 3.11 builtins/__name__#, excscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#explain().(exc))) |
| 431 | |
| 432 | if depthscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#explain().(depth) > 0: |
| 433 | callers = inspectscip-python python python-stdlib 3.11 inspect/__init__:.getinnerframesscip-python python python-stdlib 3.11 inspect/getinnerframes().(excscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#explain().(exc).__traceback__scip-python python python-stdlib 3.11 builtins/BaseException#__traceback__., contextscip-python python python-stdlib 3.11 inspect/getinnerframes().(context)=depthscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#explain().(depth)) |
| 434 | seen = setscip-python python python-stdlib 3.11 builtins/set#() |
| 435 | for i, ff in enumeratescip-python python python-stdlib 3.11 builtins/enumerate#(callers[-depthscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#explain().(depth):]): |
| 436 | frm = ff[0] |
| 437 | |
| 438 | f_self = frm.f_localsscip-python python python-stdlib 3.11 types/FrameType#f_locals()..getscip-python python python-stdlib 3.11 builtins/dict#get().('self', None) |
| 439 | if isinstance(f_self, ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#): |
| 440 | if frm.f_codescip-python python python-stdlib 3.11 types/FrameType#f_code()..co_namescip-python python python-stdlib 3.11 types/CodeType#co_name(). not in ('parseImpl', '_parseNoCache'): |
| 441 | continue |
| 442 | if f_self in seen: |
| 443 | continue |
| 444 | seen.addscip-python python python-stdlib 3.11 builtins/set#add().(f_self) |
| 445 | |
| 446 | self_type = typescip-python python python-stdlib 3.11 builtins/type#(f_self) |
| 447 | ret.appendscip-python python python-stdlib 3.11 builtins/list#append().("{0}.{1} - {2}".format(self_type.__module__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#, |
| 448 | self_type.__name__scip-python python python-stdlib 3.11 builtins/__name__#, |
| 449 | f_self)) |
| 450 | elif f_self is not None: |
| 451 | self_type = typescip-python python python-stdlib 3.11 builtins/type#(f_self) |
| 452 | ret.appendscip-python python python-stdlib 3.11 builtins/list#append().("{0}.{1}".format(self_type.__module__, |
| 453 | self_type.__name__)) |
| 454 | else: |
| 455 | code = frm.f_codescip-python python python-stdlib 3.11 types/FrameType#f_code(). |
| 456 | if code.co_namescip-python python python-stdlib 3.11 types/CodeType#co_name(). in ('wrapper', '<module>'): |
| 457 | continue |
| 458 | |
| 459 | ret.appendscip-python python python-stdlib 3.11 builtins/list#append().("{0}".format(code.co_namescip-python python python-stdlib 3.11 types/CodeType#co_name().)) |
| 460 | |
| 461 | depthscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#explain().(depth) -= 1 |
| 462 | if not depthscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#explain().(depth): |
| 463 | break |
| 464 | |
| 465 | return '\n'.joinscip-python python python-stdlib 3.11 builtins/str#join().(ret) |
| 466 | |
| 467 | |
| 468 | class ParseFatalExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseFatalException#(ParseBaseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#): |
| 469 | """user-throwable exception thrown when inconsistent parse content |
| 470 | is found; stops all parsing immediately""" |
| 471 | pass |
| 472 | |
| 473 | class ParseSyntaxExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseSyntaxException#(ParseFatalExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseFatalException#): |
| 474 | """just like :class:`ParseFatalException`, but thrown internally |
| 475 | when an :class:`ErrorStop<And._ErrorStop>` ('-' operator) indicates |
| 476 | that parsing is to stop immediately because an unbacktrackable |
| 477 | syntax error has been found. |
| 478 | """ |
| 479 | pass |
| 480 | |
| 481 | #~ class ReparseException(ParseBaseException): |
| 482 | #~ """Experimental class - parse actions can raise this exception to cause |
| 483 | #~ pyparsing to reparse the input string: |
| 484 | #~ - with a modified input string, and/or |
| 485 | #~ - with a modified start location |
| 486 | #~ Set the values of the ReparseException in the constructor, and raise the |
| 487 | #~ exception in a parse action to cause pyparsing to use the new string/location. |
| 488 | #~ Setting the values as None causes no change to be made. |
| 489 | #~ """ |
| 490 | #~ def __init_( self, newstring, restartLoc ): |
| 491 | #~ self.newParseText = newstring |
| 492 | #~ self.reparseLoc = restartLoc |
| 493 | |
| 494 | class RecursiveGrammarExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/RecursiveGrammarException#(Exceptionscip-python python python-stdlib 3.11 builtins/Exception#): |
| 495 | """exception thrown by :class:`ParserElement.validate` if the |
| 496 | grammar could be improperly recursive |
| 497 | """ |
| 498 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/RecursiveGrammarException#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/RecursiveGrammarException#__init__().(self), parseElementListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/RecursiveGrammarException#__init__().(parseElementList)): |
| 499 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/RecursiveGrammarException#__init__().(self).parseElementTracescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/RecursiveGrammarException#parseElementTrace. = parseElementListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/RecursiveGrammarException#__init__().(parseElementList) |
| 500 | |
| 501 | def __str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/RecursiveGrammarException#__str__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/RecursiveGrammarException#__str__().(self)): |
| 502 | return "RecursiveGrammarException: %s" % selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/RecursiveGrammarException#__str__().(self).parseElementTracescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/RecursiveGrammarException#parseElementTrace. |
| 503 | |
| 504 | class _ParseResultsWithOffsetscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#(objectscip-python python python-stdlib 3.11 builtins/object#): |
| 505 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#__init__().(self), p1scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#__init__().(p1), p2scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#__init__().(p2)): |
| 506 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#__init__().(self).tupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#tup. = (p1scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#__init__().(p1), p2scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#__init__().(p2)) |
| 507 | def __getitem__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#__getitem__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#__getitem__().(self), iscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#__getitem__().(i)): |
| 508 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#__getitem__().(self).tupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#tup.[iscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#__getitem__().(i)] |
| 509 | def __repr__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#__repr__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#__repr__().(self)): |
| 510 | return repr(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#__repr__().(self).tupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#tup.[0]) |
| 511 | def setOffsetscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#setOffset().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#setOffset().(self), iscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#setOffset().(i)): |
| 512 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#setOffset().(self).tupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#tup. = (selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#setOffset().(self).tupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#tup.[0], iscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#setOffset().(i)) |
| 513 | |
| 514 | class ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#(objectscip-python python python-stdlib 3.11 builtins/object#): |
| 515 | """Structured parse results, to provide multiple means of access to |
| 516 | the parsed data: |
| 517 | |
| 518 | - as a list (``len(results)``) |
| 519 | - by list index (``results[0], results[1]``, etc.) |
| 520 | - by attribute (``results.<resultsName>`` - see :class:`ParserElement.setResultsName`) |
| 521 | |
| 522 | Example:: |
| 523 | |
| 524 | integer = Word(nums) |
| 525 | date_str = (integer.setResultsName("year") + '/' |
| 526 | + integer.setResultsName("month") + '/' |
| 527 | + integer.setResultsName("day")) |
| 528 | # equivalent form: |
| 529 | # date_str = integer("year") + '/' + integer("month") + '/' + integer("day") |
| 530 | |
| 531 | # parseString returns a ParseResults object |
| 532 | result = date_str.parseString("1999/12/31") |
| 533 | |
| 534 | def test(s, fn=repr): |
| 535 | print("%s -> %s" % (s, fn(eval(s)))) |
| 536 | test("list(result)") |
| 537 | test("result[0]") |
| 538 | test("result['month']") |
| 539 | test("result.day") |
| 540 | test("'month' in result") |
| 541 | test("'minutes' in result") |
| 542 | test("result.dump()", str) |
| 543 | |
| 544 | prints:: |
| 545 | |
| 546 | list(result) -> ['1999', '/', '12', '/', '31'] |
| 547 | result[0] -> '1999' |
| 548 | result['month'] -> '12' |
| 549 | result.day -> '31' |
| 550 | 'month' in result -> True |
| 551 | 'minutes' in result -> False |
| 552 | result.dump() -> ['1999', '/', '12', '/', '31'] |
| 553 | - day: 31 |
| 554 | - month: 12 |
| 555 | - year: 1999 |
| 556 | """ |
| 557 | def __new__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__new__().(clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__new__().(cls), toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__new__().(toklist)=None, namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__new__().(name)=None, asListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__new__().(asList)=True, modalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__new__().(modal)=True): |
| 558 | if isinstance(toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__new__().(toklist), clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__new__().(cls)): |
| 559 | return toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__new__().(toklist) |
| 560 | retobj = objectscip-python python python-stdlib 3.11 builtins/object#.__new__scip-python python python-stdlib 3.11 builtins/object#__new__().(clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__new__().(cls)) |
| 561 | retobj.__doinitscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__doinit. = True |
| 562 | return retobj |
| 563 | |
| 564 | # Performance tuning: we construct a *lot* of these, so keep this |
| 565 | # constructor as small and fast as possible |
| 566 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(self), toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(toklist)=None, namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(name)=None, asListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(asList)=True, modalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(modal)=True, isinstancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(isinstance)=isinstance): |
| 567 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(self).__doinitscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__doinit.: |
| 568 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(self).__doinitscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__doinit. = False |
| 569 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(self).__namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__name. = None |
| 570 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(self).__parentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__parent. = None |
| 571 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(self).__accumNamesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__accumNames. = {} |
| 572 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(self).__asListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__asList. = asListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(asList) |
| 573 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(self).__modalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__modal. = modalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(modal) |
| 574 | if toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(toklist) is None: |
| 575 | toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(toklist) = [] |
| 576 | if isinstancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(isinstance)(toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(toklist), listscip-python python python-stdlib 3.11 builtins/list#): |
| 577 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist. = toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(toklist)[:] |
| 578 | elif isinstancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(isinstance)(toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(toklist), _generatorTypescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_generatorType.): |
| 579 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist. = listscip-python python python-stdlib 3.11 builtins/list#(toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(toklist)) |
| 580 | else: |
| 581 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist. = [toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(toklist)] |
| 582 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict. = dictscip-python python python-stdlib 3.11 builtins/dict#() |
| 583 | |
| 584 | if namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(name) is not None and namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(name): |
| 585 | if not modalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(modal): |
| 586 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(self).__accumNamesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__accumNames.[namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(name)] = 0 |
| 587 | if isinstancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(isinstance)(namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(name), intscip-python python python-stdlib 3.11 builtins/int#): |
| 588 | namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(name) = _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(name)) # will always return a str, but use _ustr for consistency |
| 589 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(self).__namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__name. = namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(name) |
| 590 | if not (isinstancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(isinstance)(toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(toklist), (typescip-python python python-stdlib 3.11 builtins/type#(None), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring., listscip-python python python-stdlib 3.11 builtins/list#)) and toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(toklist) in (None, '', [])): |
| 591 | if isinstancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(isinstance)(toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(toklist), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 592 | toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(toklist) = [toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(toklist)] |
| 593 | if asListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(asList): |
| 594 | if isinstancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(isinstance)(toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(toklist), ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#): |
| 595 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(self)[namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(name)] = _ParseResultsWithOffsetscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#(ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#(toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(toklist).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist.), 0) |
| 596 | else: |
| 597 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(self)[namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(name)] = _ParseResultsWithOffsetscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#(ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#(toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(toklist)[0]), 0) |
| 598 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(self)[namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(name)].__namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__name. = namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(name) |
| 599 | else: |
| 600 | try: |
| 601 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(self)[namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(name)] = toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(toklist)[0] |
| 602 | except (KeyErrorscip-python python python-stdlib 3.11 builtins/KeyError#, TypeErrorscip-python python python-stdlib 3.11 builtins/TypeError#, IndexErrorscip-python python python-stdlib 3.11 builtins/IndexError#): |
| 603 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(self)[namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(name)] = toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(toklist) |
| 604 | |
| 605 | def __getitem__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getitem__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getitem__().(self), iscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getitem__().(i)): |
| 606 | if isinstance(iscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getitem__().(i), (intscip-python python python-stdlib 3.11 builtins/int#, slicescip-python python python-stdlib 3.11 builtins/slice#)): |
| 607 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getitem__().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist.[iscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getitem__().(i)] |
| 608 | else: |
| 609 | if iscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getitem__().(i) not in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getitem__().(self).__accumNamesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__accumNames.: |
| 610 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getitem__().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict.[iscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getitem__().(i)][-1][0] |
| 611 | else: |
| 612 | return ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#([v[0] for v in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getitem__().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict.[iscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getitem__().(i)]]) |
| 613 | |
| 614 | def __setitem__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(self), kscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(k), vscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(v), isinstancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(isinstance)=isinstance): |
| 615 | if isinstancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(isinstance)(vscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(v), _ParseResultsWithOffsetscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#): |
| 616 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict.[kscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(k)] = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict..getscip-python python python-stdlib 3.11 builtins/dict#get().(kscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(k), listscip-python python python-stdlib 3.11 builtins/list#()) + [vscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(v)] |
| 617 | sub = vscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(v)[0] |
| 618 | elif isinstancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(isinstance)(kscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(k), (intscip-python python python-stdlib 3.11 builtins/int#, slicescip-python python python-stdlib 3.11 builtins/slice#)): |
| 619 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist.[kscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(k)] = vscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(v) |
| 620 | sub = vscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(v) |
| 621 | else: |
| 622 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict.[kscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(k)] = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict..getscip-python python python-stdlib 3.11 builtins/dict#get().(kscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(k), listscip-python python python-stdlib 3.11 builtins/list#()) + [_ParseResultsWithOffsetscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#(vscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(v), 0)] |
| 623 | sub = vscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(v) |
| 624 | if isinstancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(isinstance)(sub, ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#): |
| 625 | sub.__parentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__parent. = wkrefscip-python python python-stdlib 3.11 _weakref/ref.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setitem__().(self)) |
| 626 | |
| 627 | def __delitem__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__delitem__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__delitem__().(self), iscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__delitem__().(i)): |
| 628 | if isinstance(iscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__delitem__().(i), (intscip-python python python-stdlib 3.11 builtins/int#, slicescip-python python python-stdlib 3.11 builtins/slice#)): |
| 629 | mylen = len(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__delitem__().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist.) |
| 630 | del selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__delitem__().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist.[iscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__delitem__().(i)] |
| 631 | |
| 632 | # convert int to slice |
| 633 | if isinstance(iscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__delitem__().(i), intscip-python python python-stdlib 3.11 builtins/int#): |
| 634 | if iscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__delitem__().(i) < 0: |
| 635 | iscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__delitem__().(i) += mylen |
| 636 | iscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__delitem__().(i) = slicescip-python python python-stdlib 3.11 builtins/slice#(iscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__delitem__().(i), iscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__delitem__().(i) + 1) |
| 637 | # get removed indices |
| 638 | removed = listscip-python python python-stdlib 3.11 builtins/list#(rangescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/range.(*iscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__delitem__().(i).indicesscip-python python python-stdlib 3.11 builtins/slice#indices().(mylen))) |
| 639 | removed.reversescip-python python python-stdlib 3.11 typing/MutableSequence#reverse().() |
| 640 | # fixup indices in token dictionary |
| 641 | for name, occurrences in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__delitem__().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict..itemsscip-python python python-stdlib 3.11 builtins/dict#items().(): |
| 642 | for j in removed: |
| 643 | for k, (value, position) in enumeratescip-python python python-stdlib 3.11 builtins/enumerate#(occurrences): |
| 644 | occurrences[k] = _ParseResultsWithOffsetscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#(value, position - (position > j)) |
| 645 | else: |
| 646 | del selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__delitem__().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict.[iscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__delitem__().(i)] |
| 647 | |
| 648 | def __contains__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__contains__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__contains__().(self), kscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__contains__().(k)): |
| 649 | return kscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__contains__().(k) in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__contains__().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict. |
| 650 | |
| 651 | def __len__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__len__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__len__().(self)): |
| 652 | return len(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__len__().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist.) |
| 653 | |
| 654 | def __bool__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__bool__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__bool__().(self)): |
| 655 | return (not not selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__bool__().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist.) |
| 656 | __nonzero__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__nonzero__. = __bool__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__bool__(). |
| 657 | |
| 658 | def __iter__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__iter__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__iter__().(self)): |
| 659 | return iterscip-python python python-stdlib 3.11 builtins/iter().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__iter__().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist.) |
| 660 | |
| 661 | def __reversed__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__reversed__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__reversed__().(self)): |
| 662 | return iterscip-python python python-stdlib 3.11 builtins/iter().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__reversed__().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist.[::-1]) |
| 663 | |
| 664 | def _iterkeysscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_iterkeys().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_iterkeys().(self)): |
| 665 | if hasattr(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_iterkeys().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict., "iterkeys"): |
| 666 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_iterkeys().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict..iterkeys() |
| 667 | else: |
| 668 | return iterscip-python python python-stdlib 3.11 builtins/iter().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_iterkeys().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict.) |
| 669 | |
| 670 | def _itervaluesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_itervalues().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_itervalues().(self)): |
| 671 | return (selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_itervalues().(self)[k] for k in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_itervalues().(self)._iterkeysscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_iterkeys().()) |
| 672 | |
| 673 | def _iteritemsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_iteritems().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_iteritems().(self)): |
| 674 | return ((k, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_iteritems().(self)[k]) for k in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_iteritems().(self)._iterkeysscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_iterkeys().()) |
| 675 | |
| 676 | if PY_3scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PY_3.: |
| 677 | keysscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#keys. = _iterkeysscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_iterkeys(). |
| 678 | """Returns an iterator of all named result keys.""" |
| 679 | |
| 680 | valuesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#values. = _itervaluesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_itervalues(). |
| 681 | """Returns an iterator of all named result values.""" |
| 682 | |
| 683 | itemsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#items. = _iteritemsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_iteritems(). |
| 684 | """Returns an iterator of all named result key-value tuples.""" |
| 685 | |
| 686 | else: |
| 687 | iterkeysscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#iterkeys. = _iterkeysscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_iterkeys(). |
| 688 | """Returns an iterator of all named result keys (Python 2.x only).""" |
| 689 | |
| 690 | itervaluesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#itervalues. = _itervaluesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_itervalues(). |
| 691 | """Returns an iterator of all named result values (Python 2.x only).""" |
| 692 | |
| 693 | iteritemsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#iteritems. = _iteritemsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_iteritems(). |
| 694 | """Returns an iterator of all named result key-value tuples (Python 2.x only).""" |
| 695 | |
| 696 | def keysscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#keys.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#keys().(self)): |
| 697 | """Returns all named result keys (as a list in Python 2.x, as an iterator in Python 3.x).""" |
| 698 | return listscip-python python python-stdlib 3.11 builtins/list#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#keys().(self).iterkeysscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#iterkeys.()) |
| 699 | |
| 700 | def valuesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#values.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#values().(self)): |
| 701 | """Returns all named result values (as a list in Python 2.x, as an iterator in Python 3.x).""" |
| 702 | return listscip-python python python-stdlib 3.11 builtins/list#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#values().(self).itervaluesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#itervalues.()) |
| 703 | |
| 704 | def itemsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#items.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#items().(self)): |
| 705 | """Returns all named result key-values (as a list of tuples in Python 2.x, as an iterator in Python 3.x).""" |
| 706 | return listscip-python python python-stdlib 3.11 builtins/list#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#items().(self).iteritemsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#iteritems.()) |
| 707 | |
| 708 | def haskeysscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#haskeys().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#haskeys().(self)): |
| 709 | """Since keys() returns an iterator, this method is helpful in bypassing |
| 710 | code that looks for the existence of any defined results names.""" |
| 711 | return boolscip-python python python-stdlib 3.11 builtins/bool#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#haskeys().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict.) |
| 712 | |
| 713 | def popscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pop().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pop().(self), *argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pop().(args), **kwargsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pop().(kwargs)): |
| 714 | """ |
| 715 | Removes and returns item at specified index (default= ``last``). |
| 716 | Supports both ``list`` and ``dict`` semantics for ``pop()``. If |
| 717 | passed no argument or an integer argument, it will use ``list`` |
| 718 | semantics and pop tokens from the list of parsed tokens. If passed |
| 719 | a non-integer argument (most likely a string), it will use ``dict`` |
| 720 | semantics and pop the corresponding value from any defined results |
| 721 | names. A second default return value argument is supported, just as in |
| 722 | ``dict.pop()``. |
| 723 | |
| 724 | Example:: |
| 725 | |
| 726 | def remove_first(tokens): |
| 727 | tokens.pop(0) |
| 728 | print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321'] |
| 729 | print(OneOrMore(Word(nums)).addParseAction(remove_first).parseString("0 123 321")) # -> ['123', '321'] |
| 730 | |
| 731 | label = Word(alphas) |
| 732 | patt = label("LABEL") + OneOrMore(Word(nums)) |
| 733 | print(patt.parseString("AAB 123 321").dump()) |
| 734 | |
| 735 | # Use pop() in a parse action to remove named result (note that corresponding value is not |
| 736 | # removed from list form of results) |
| 737 | def remove_LABEL(tokens): |
| 738 | tokens.pop("LABEL") |
| 739 | return tokens |
| 740 | patt.addParseAction(remove_LABEL) |
| 741 | print(patt.parseString("AAB 123 321").dump()) |
| 742 | |
| 743 | prints:: |
| 744 | |
| 745 | ['AAB', '123', '321'] |
| 746 | - LABEL: AAB |
| 747 | |
| 748 | ['AAB', '123', '321'] |
| 749 | """ |
| 750 | if not argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pop().(args): |
| 751 | argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pop().(args) = [-1] |
| 752 | for k, v in kwargsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pop().(kwargs).itemsscip-python python python-stdlib 3.11 builtins/dict#items().(): |
| 753 | if k == 'default': |
| 754 | argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pop().(args) = (argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pop().(args)[0], v) |
| 755 | else: |
| 756 | raise TypeErrorscip-python python python-stdlib 3.11 builtins/TypeError#("pop() got an unexpected keyword argument '%s'" % k) |
| 757 | if (isinstance(argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pop().(args)[0], intscip-python python python-stdlib 3.11 builtins/int#) |
| 758 | or len(argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pop().(args)) == 1 |
| 759 | or argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pop().(args)[0] in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pop().(self)): |
| 760 | index = argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pop().(args)[0] |
| 761 | ret = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pop().(self)[index] |
| 762 | del selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pop().(self)[index] |
| 763 | return ret |
| 764 | else: |
| 765 | defaultvalue = argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pop().(args)[1] |
| 766 | return defaultvalue |
| 767 | |
| 768 | def getscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#get().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#get().(self), keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#get().(key), defaultValuescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#get().(defaultValue)=None): |
| 769 | """ |
| 770 | Returns named result matching the given key, or if there is no |
| 771 | such name, then returns the given ``defaultValue`` or ``None`` if no |
| 772 | ``defaultValue`` is specified. |
| 773 | |
| 774 | Similar to ``dict.get()``. |
| 775 | |
| 776 | Example:: |
| 777 | |
| 778 | integer = Word(nums) |
| 779 | date_str = integer("year") + '/' + integer("month") + '/' + integer("day") |
| 780 | |
| 781 | result = date_str.parseString("1999/12/31") |
| 782 | print(result.get("year")) # -> '1999' |
| 783 | print(result.get("hour", "not specified")) # -> 'not specified' |
| 784 | print(result.get("hour")) # -> None |
| 785 | """ |
| 786 | if keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#get().(key) in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#get().(self): |
| 787 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#get().(self)[keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#get().(key)] |
| 788 | else: |
| 789 | return defaultValuescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#get().(defaultValue) |
| 790 | |
| 791 | def insertscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#insert().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#insert().(self), indexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#insert().(index), insStrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#insert().(insStr)): |
| 792 | """ |
| 793 | Inserts new element at location index in the list of parsed tokens. |
| 794 | |
| 795 | Similar to ``list.insert()``. |
| 796 | |
| 797 | Example:: |
| 798 | |
| 799 | print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321'] |
| 800 | |
| 801 | # use a parse action to insert the parse location in the front of the parsed results |
| 802 | def insert_locn(locn, tokens): |
| 803 | tokens.insert(0, locn) |
| 804 | print(OneOrMore(Word(nums)).addParseAction(insert_locn).parseString("0 123 321")) # -> [0, '0', '123', '321'] |
| 805 | """ |
| 806 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#insert().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist..insertscip-python python python-stdlib 3.11 builtins/list#insert().(indexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#insert().(index), insStrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#insert().(insStr)) |
| 807 | # fixup indices in token dictionary |
| 808 | for name, occurrences in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#insert().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict..itemsscip-python python python-stdlib 3.11 builtins/dict#items().(): |
| 809 | for k, (value, position) in enumeratescip-python python python-stdlib 3.11 builtins/enumerate#(occurrences): |
| 810 | occurrences[k] = _ParseResultsWithOffsetscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#(value, position + (position > indexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#insert().(index))) |
| 811 | |
| 812 | def appendscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#append().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#append().(self), itemscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#append().(item)): |
| 813 | """ |
| 814 | Add single element to end of ParseResults list of elements. |
| 815 | |
| 816 | Example:: |
| 817 | |
| 818 | print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321'] |
| 819 | |
| 820 | # use a parse action to compute the sum of the parsed integers, and add it to the end |
| 821 | def append_sum(tokens): |
| 822 | tokens.append(sum(map(int, tokens))) |
| 823 | print(OneOrMore(Word(nums)).addParseAction(append_sum).parseString("0 123 321")) # -> ['0', '123', '321', 444] |
| 824 | """ |
| 825 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#append().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist..appendscip-python python python-stdlib 3.11 builtins/list#append().(itemscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#append().(item)) |
| 826 | |
| 827 | def extendscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#extend().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#extend().(self), itemseqscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#extend().(itemseq)): |
| 828 | """ |
| 829 | Add sequence of elements to end of ParseResults list of elements. |
| 830 | |
| 831 | Example:: |
| 832 | |
| 833 | patt = OneOrMore(Word(alphas)) |
| 834 | |
| 835 | # use a parse action to append the reverse of the matched strings, to make a palindrome |
| 836 | def make_palindrome(tokens): |
| 837 | tokens.extend(reversed([t[::-1] for t in tokens])) |
| 838 | return ''.join(tokens) |
| 839 | print(patt.addParseAction(make_palindrome).parseString("lskdj sdlkjf lksd")) # -> 'lskdjsdlkjflksddsklfjkldsjdksl' |
| 840 | """ |
| 841 | if isinstance(itemseqscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#extend().(itemseq), ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#): |
| 842 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#extend().(self).__iadd__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__iadd__().(itemseqscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#extend().(itemseq)) |
| 843 | else: |
| 844 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#extend().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist..extendscip-python python python-stdlib 3.11 builtins/list#extend().(itemseqscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#extend().(itemseq)) |
| 845 | |
| 846 | def clearscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#clear().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#clear().(self)): |
| 847 | """ |
| 848 | Clear all elements and results names. |
| 849 | """ |
| 850 | del selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#clear().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist.[:] |
| 851 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#clear().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict..clearscip-python python python-stdlib 3.11 typing/MutableMapping#clear().() |
| 852 | |
| 853 | def __getattr__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getattr__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getattr__().(self), namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getattr__().(name)): |
| 854 | try: |
| 855 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getattr__().(self)[namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getattr__().(name)] |
| 856 | except KeyErrorscip-python python python-stdlib 3.11 builtins/KeyError#: |
| 857 | return "" |
| 858 | |
| 859 | def __add__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__add__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__add__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__add__().(other)): |
| 860 | ret = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__add__().(self).copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#copy().() |
| 861 | ret += otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__add__().(other) |
| 862 | return ret |
| 863 | |
| 864 | def __iadd__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__iadd__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__iadd__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__iadd__().(other)): |
| 865 | if otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__iadd__().(other).__tokdict: |
| 866 | offset = len(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__iadd__().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist.) |
| 867 | addoffset = lambda a: offset if a < 0 else a + offset |
| 868 | otheritems = otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__iadd__().(other).__tokdict.items() |
| 869 | otherdictitems = [(k, _ParseResultsWithOffsetscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#(v[0], addoffset(v[1]))) |
| 870 | for k, vlist in otheritems for v in vlist] |
| 871 | for k, v in otherdictitems: |
| 872 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__iadd__().(self)[k] = v |
| 873 | if isinstance(v[0], ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#): |
| 874 | v[0].__parent = wkrefscip-python python python-stdlib 3.11 _weakref/ref.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__iadd__().(self)) |
| 875 | |
| 876 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__iadd__().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist. += otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__iadd__().(other).__toklist |
| 877 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__iadd__().(self).__accumNamesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__accumNames..updatescip-python python python-stdlib 3.11 typing/MutableMapping#update().(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__iadd__().(other).__accumNames) |
| 878 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__iadd__().(self) |
| 879 | |
| 880 | def __radd__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__radd__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__radd__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__radd__().(other)): |
| 881 | if isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__radd__().(other), intscip-python python python-stdlib 3.11 builtins/int#) and otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__radd__().(other) == 0: |
| 882 | # useful for merging many ParseResults using sum() builtin |
| 883 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__radd__().(self).copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#copy().() |
| 884 | else: |
| 885 | # this may raise a TypeError - so be it |
| 886 | return otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__radd__().(other) + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__radd__().(self) |
| 887 | |
| 888 | def __repr__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__repr__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__repr__().(self)): |
| 889 | return "(%s, %s)" % (repr(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__repr__().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist.), repr(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__repr__().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict.)) |
| 890 | |
| 891 | def __str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__str__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__str__().(self)): |
| 892 | return '[' + ', '.joinscip-python python python-stdlib 3.11 builtins/str#join().(_ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(i) if isinstance(i, ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#) else repr(i) for i in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__str__().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist.) + ']' |
| 893 | |
| 894 | def _asStringListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_asStringList().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_asStringList().(self), sepscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_asStringList().(sep)=''): |
| 895 | out = [] |
| 896 | for item in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_asStringList().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist.: |
| 897 | if out and sepscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_asStringList().(sep): |
| 898 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().(sepscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_asStringList().(sep)) |
| 899 | if isinstance(item, ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#): |
| 900 | out += item._asStringListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#_asStringList().() |
| 901 | else: |
| 902 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().(_ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(item)) |
| 903 | return out |
| 904 | |
| 905 | def asListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asList().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asList().(self)): |
| 906 | """ |
| 907 | Returns the parse results as a nested list of matching tokens, all converted to strings. |
| 908 | |
| 909 | Example:: |
| 910 | |
| 911 | patt = OneOrMore(Word(alphas)) |
| 912 | result = patt.parseString("sldkj lsdkj sldkj") |
| 913 | # even though the result prints in string-like form, it is actually a pyparsing ParseResults |
| 914 | print(type(result), result) # -> <class 'pyparsing.ParseResults'> ['sldkj', 'lsdkj', 'sldkj'] |
| 915 | |
| 916 | # Use asList() to create an actual list |
| 917 | result_list = result.asList() |
| 918 | print(type(result_list), result_list) # -> <class 'list'> ['sldkj', 'lsdkj', 'sldkj'] |
| 919 | """ |
| 920 | return [res.asListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asList().() if isinstance(res, ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#) else res for res in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asList().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist.] |
| 921 | |
| 922 | def asDictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asDict().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asDict().(self)): |
| 923 | """ |
| 924 | Returns the named parse results as a nested dictionary. |
| 925 | |
| 926 | Example:: |
| 927 | |
| 928 | integer = Word(nums) |
| 929 | date_str = integer("year") + '/' + integer("month") + '/' + integer("day") |
| 930 | |
| 931 | result = date_str.parseString('12/31/1999') |
| 932 | print(type(result), repr(result)) # -> <class 'pyparsing.ParseResults'> (['12', '/', '31', '/', '1999'], {'day': [('1999', 4)], 'year': [('12', 0)], 'month': [('31', 2)]}) |
| 933 | |
| 934 | result_dict = result.asDict() |
| 935 | print(type(result_dict), repr(result_dict)) # -> <class 'dict'> {'day': '1999', 'year': '12', 'month': '31'} |
| 936 | |
| 937 | # even though a ParseResults supports dict-like access, sometime you just need to have a dict |
| 938 | import json |
| 939 | print(json.dumps(result)) # -> Exception: TypeError: ... is not JSON serializable |
| 940 | print(json.dumps(result.asDict())) # -> {"month": "31", "day": "1999", "year": "12"} |
| 941 | """ |
| 942 | if PY_3scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PY_3.: |
| 943 | item_fn = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asDict().(self).itemsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#items(). |
| 944 | else: |
| 945 | item_fn = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asDict().(self).iteritemsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#iteritems. |
| 946 | |
| 947 | def toItemscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#toItem().(objscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#toItem().(obj)): |
| 948 | if isinstance(objscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#toItem().(obj), ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#): |
| 949 | if objscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#toItem().(obj).haskeysscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#haskeys().(): |
| 950 | return objscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#toItem().(obj).asDictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asDict().() |
| 951 | else: |
| 952 | return [toItemscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#toItem().(v) for v in objscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#toItem().(obj)] |
| 953 | else: |
| 954 | return objscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#toItem().(obj) |
| 955 | |
| 956 | return dictscip-python python python-stdlib 3.11 builtins/dict#((k, toItemscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#toItem().(v)) for k, v in item_fn()) |
| 957 | |
| 958 | def copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#copy().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#copy().(self)): |
| 959 | """ |
| 960 | Returns a new copy of a :class:`ParseResults` object. |
| 961 | """ |
| 962 | ret = ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#copy().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist.) |
| 963 | ret.__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict. = dictscip-python python python-stdlib 3.11 builtins/dict#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#copy().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict..itemsscip-python python python-stdlib 3.11 builtins/dict#items().()) |
| 964 | ret.__parentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__parent. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#copy().(self).__parentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__parent. |
| 965 | ret.__accumNamesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__accumNames..updatescip-python python python-stdlib 3.11 typing/MutableMapping#update().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#copy().(self).__accumNamesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__accumNames.) |
| 966 | ret.__namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__name. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#copy().(self).__namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__name. |
| 967 | return ret |
| 968 | |
| 969 | def asXMLscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(self), doctagscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(doctag)=None, namedItemsOnlyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(namedItemsOnly)=False, indentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(indent)="", formattedscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(formatted)=True): |
| 970 | """ |
| 971 | (Deprecated) Returns the parse results as XML. Tags are created for tokens and lists that have defined results names. |
| 972 | """ |
| 973 | nl = "\n" |
| 974 | out = [] |
| 975 | namedItems = dictscip-python python python-stdlib 3.11 builtins/dict#((v[1], k) for (k, vlist) in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict..itemsscip-python python python-stdlib 3.11 builtins/dict#items().() |
| 976 | for v in vlist) |
| 977 | nextLevelIndent = indentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(indent) + " " |
| 978 | |
| 979 | # collapse out indents if formatting is not desired |
| 980 | if not formattedscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(formatted): |
| 981 | indentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(indent) = "" |
| 982 | nextLevelIndent = "" |
| 983 | nl = "" |
| 984 | |
| 985 | selfTag = None |
| 986 | if doctagscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(doctag) is not None: |
| 987 | selfTag = doctagscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(doctag) |
| 988 | else: |
| 989 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(self).__namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__name.: |
| 990 | selfTag = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(self).__namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__name. |
| 991 | |
| 992 | if not selfTag: |
| 993 | if namedItemsOnlyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(namedItemsOnly): |
| 994 | return "" |
| 995 | else: |
| 996 | selfTag = "ITEM" |
| 997 | |
| 998 | out += [nl, indentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(indent), "<", selfTag, ">"] |
| 999 | |
| 1000 | for i, res in enumeratescip-python python python-stdlib 3.11 builtins/enumerate#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist.): |
| 1001 | if isinstance(res, ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#): |
| 1002 | if i in namedItems: |
| 1003 | out += [res.asXMLscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(namedItems[i], |
| 1004 | namedItemsOnlyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(namedItemsOnly) and doctagscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(doctag) is None, |
| 1005 | nextLevelIndent, |
| 1006 | formattedscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(formatted))] |
| 1007 | else: |
| 1008 | out += [res.asXMLscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(None, |
| 1009 | namedItemsOnlyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(namedItemsOnly) and doctagscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(doctag) is None, |
| 1010 | nextLevelIndent, |
| 1011 | formattedscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(formatted))] |
| 1012 | else: |
| 1013 | # individual token, see if there is a name for it |
| 1014 | resTag = None |
| 1015 | if i in namedItems: |
| 1016 | resTag = namedItems[i] |
| 1017 | if not resTag: |
| 1018 | if namedItemsOnlyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(namedItemsOnly): |
| 1019 | continue |
| 1020 | else: |
| 1021 | resTag = "ITEM" |
| 1022 | xmlBodyText = _xml_escapescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_xml_escape().(_ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(res)) |
| 1023 | out += [nl, nextLevelIndent, "<", resTag, ">", |
| 1024 | xmlBodyText, |
| 1025 | "</", resTag, ">"] |
| 1026 | |
| 1027 | out += [nl, indentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asXML().(indent), "</", selfTag, ">"] |
| 1028 | return "".joinscip-python python python-stdlib 3.11 builtins/str#join().(out) |
| 1029 | |
| 1030 | def __lookupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__lookup().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__lookup().(self), subscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__lookup().(sub)): |
| 1031 | for k, vlist in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__lookup().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict..itemsscip-python python python-stdlib 3.11 builtins/dict#items().(): |
| 1032 | for v, loc in vlist: |
| 1033 | if subscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__lookup().(sub) is v: |
| 1034 | return k |
| 1035 | return None |
| 1036 | |
| 1037 | def getNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#getName().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#getName().(self)): |
| 1038 | r""" |
| 1039 | Returns the results name for this token expression. Useful when several |
| 1040 | different expressions might match at a particular location. |
| 1041 | |
| 1042 | Example:: |
| 1043 | |
| 1044 | integer = Word(nums) |
| 1045 | ssn_expr = Regex(r"\d\d\d-\d\d-\d\d\d\d") |
| 1046 | house_number_expr = Suppress('#') + Word(nums, alphanums) |
| 1047 | user_data = (Group(house_number_expr)("house_number") |
| 1048 | | Group(ssn_expr)("ssn") |
| 1049 | | Group(integer)("age")) |
| 1050 | user_info = OneOrMore(user_data) |
| 1051 | |
| 1052 | result = user_info.parseString("22 111-22-3333 #221B") |
| 1053 | for item in result: |
| 1054 | print(item.getName(), ':', item[0]) |
| 1055 | |
| 1056 | prints:: |
| 1057 | |
| 1058 | age : 22 |
| 1059 | ssn : 111-22-3333 |
| 1060 | house_number : 221B |
| 1061 | """ |
| 1062 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#getName().(self).__namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__name.: |
| 1063 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#getName().(self).__namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__name. |
| 1064 | elif selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#getName().(self).__parentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__parent.: |
| 1065 | par = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#getName().(self).__parentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__parent.() |
| 1066 | if par: |
| 1067 | return par.__lookup(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#getName().(self)) |
| 1068 | else: |
| 1069 | return None |
| 1070 | elif (len(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#getName().(self)) == 1 |
| 1071 | and len(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#getName().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict.) == 1 |
| 1072 | and nextscip-python python python-stdlib 3.11 builtins/next().(iterscip-python python python-stdlib 3.11 builtins/iter().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#getName().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict..valuesscip-python python python-stdlib 3.11 builtins/dict#values().()))[0][1] in (0, -1)): |
| 1073 | return nextscip-python python python-stdlib 3.11 builtins/next().(iterscip-python python python-stdlib 3.11 builtins/iter().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#getName().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict..keysscip-python python python-stdlib 3.11 builtins/dict#keys().())) |
| 1074 | else: |
| 1075 | return None |
| 1076 | |
| 1077 | def dumpscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(self), indentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(indent)='', fullscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(full)=True, include_listscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(include_list)=True, _depthscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(_depth)=0): |
| 1078 | """ |
| 1079 | Diagnostic method for listing out the contents of |
| 1080 | a :class:`ParseResults`. Accepts an optional ``indent`` argument so |
| 1081 | that this string can be embedded in a nested display of other data. |
| 1082 | |
| 1083 | Example:: |
| 1084 | |
| 1085 | integer = Word(nums) |
| 1086 | date_str = integer("year") + '/' + integer("month") + '/' + integer("day") |
| 1087 | |
| 1088 | result = date_str.parseString('12/31/1999') |
| 1089 | print(result.dump()) |
| 1090 | |
| 1091 | prints:: |
| 1092 | |
| 1093 | ['12', '/', '31', '/', '1999'] |
| 1094 | - day: 1999 |
| 1095 | - month: 31 |
| 1096 | - year: 12 |
| 1097 | """ |
| 1098 | out = [] |
| 1099 | NL = '\n' |
| 1100 | if include_listscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(include_list): |
| 1101 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().(indentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(indent) + _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(self).asListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asList().())) |
| 1102 | else: |
| 1103 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().('') |
| 1104 | |
| 1105 | if fullscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(full): |
| 1106 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(self).haskeysscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#haskeys().(): |
| 1107 | items = sortedscip-python python python-stdlib 3.11 builtins/sorted().((strscip-python python python-stdlib 3.11 builtins/str#(k), v) for k, v in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(self).itemsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#items().()) |
| 1108 | for k, v in items: |
| 1109 | if out: |
| 1110 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().(NL) |
| 1111 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().("%s%s- %s: " % (indentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(indent), (' ' * _depthscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(_depth)), k)) |
| 1112 | if isinstance(v, ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#): |
| 1113 | if v: |
| 1114 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().(v.dumpscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(indentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(indent)=indentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(indent), fullscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(full)=fullscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(full), include_listscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(include_list)=include_listscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(include_list), _depthscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(_depth)=_depthscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(_depth) + 1)) |
| 1115 | else: |
| 1116 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().(_ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(v)) |
| 1117 | else: |
| 1118 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().(repr(v)) |
| 1119 | elif any(isinstance(vv, ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#) for vv in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(self)): |
| 1120 | v = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(self) |
| 1121 | for i, vv in enumeratescip-python python python-stdlib 3.11 builtins/enumerate#(v): |
| 1122 | if isinstance(vv, ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#): |
| 1123 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().("\n%s%s[%d]:\n%s%s%s" % (indentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(indent), |
| 1124 | (' ' * (_depth)scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(_depth)), |
| 1125 | i, |
| 1126 | indentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(indent), |
| 1127 | (' ' * (_depthscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(_depth) + 1)), |
| 1128 | vv.dumpscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(indentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(indent)=indentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(indent), |
| 1129 | fullscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(full)=fullscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(full), |
| 1130 | include_listscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(include_list)=include_listscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(include_list), |
| 1131 | _depthscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(_depth)=_depthscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(_depth) + 1))) |
| 1132 | else: |
| 1133 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().("\n%s%s[%d]:\n%s%s%s" % (indentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(indent), |
| 1134 | (' ' * (_depth)scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(_depth)), |
| 1135 | i, |
| 1136 | indentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(indent), |
| 1137 | (' ' * (_depthscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().(_depth) + 1)), |
| 1138 | _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(vv))) |
| 1139 | |
| 1140 | return "".joinscip-python python python-stdlib 3.11 builtins/str#join().(out) |
| 1141 | |
| 1142 | def pprintscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pprint().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pprint().(self), *argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pprint().(args), **kwargsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pprint().(kwargs)): |
| 1143 | """ |
| 1144 | Pretty-printer for parsed results as a list, using the |
| 1145 | `pprint <https://docs.python.org/3/library/pprint.html>`_ module. |
| 1146 | Accepts additional positional or keyword args as defined for |
| 1147 | `pprint.pprint <https://docs.python.org/3/library/pprint.html#pprint.pprint>`_ . |
| 1148 | |
| 1149 | Example:: |
| 1150 | |
| 1151 | ident = Word(alphas, alphanums) |
| 1152 | num = Word(nums) |
| 1153 | func = Forward() |
| 1154 | term = ident | num | Group('(' + func + ')') |
| 1155 | func <<= ident + Group(Optional(delimitedList(term))) |
| 1156 | result = func.parseString("fna a,b,(fnb c,d,200),100") |
| 1157 | result.pprint(width=40) |
| 1158 | |
| 1159 | prints:: |
| 1160 | |
| 1161 | ['fna', |
| 1162 | ['a', |
| 1163 | 'b', |
| 1164 | ['(', 'fnb', ['c', 'd', '200'], ')'], |
| 1165 | '100']] |
| 1166 | """ |
| 1167 | pprintscip-python python python-stdlib 3.11 pprint/__init__:.pprintscip-python python python-stdlib 3.11 pprint/pprint().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pprint().(self).asListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asList().(), *argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pprint().(args), **kwargsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#pprint().(kwargs)) |
| 1168 | |
| 1169 | # add support for pickle protocol |
| 1170 | def __getstate__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getstate__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getstate__().(self)): |
| 1171 | return (selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getstate__().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist., |
| 1172 | (selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getstate__().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict..copyscip-python python python-stdlib 3.11 builtins/dict#copy().(), |
| 1173 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getstate__().(self).__parentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__parent. is not None and selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getstate__().(self).__parentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__parent.() or None, |
| 1174 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getstate__().(self).__accumNamesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__accumNames., |
| 1175 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getstate__().(self).__namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__name.)) |
| 1176 | |
| 1177 | def __setstate__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setstate__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setstate__().(self), statescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setstate__().(state)): |
| 1178 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setstate__().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist. = statescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setstate__().(state)[0] |
| 1179 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setstate__().(self).__tokdictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__tokdict., par, inAccumNames, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setstate__().(self).__namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__name. = statescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setstate__().(state)[1] |
| 1180 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setstate__().(self).__accumNamesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__accumNames. = {} |
| 1181 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setstate__().(self).__accumNamesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__accumNames..updatescip-python python python-stdlib 3.11 typing/MutableMapping#update().(inAccumNames) |
| 1182 | if par is not None: |
| 1183 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setstate__().(self).__parentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__parent. = wkrefscip-python python python-stdlib 3.11 _weakref/ref.(par) |
| 1184 | else: |
| 1185 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__setstate__().(self).__parentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__parent. = None |
| 1186 | |
| 1187 | def __getnewargs__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getnewargs__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getnewargs__().(self)): |
| 1188 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getnewargs__().(self).__toklistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__toklist., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getnewargs__().(self).__namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__name., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getnewargs__().(self).__asListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__asList., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__getnewargs__().(self).__modalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__modal. |
| 1189 | |
| 1190 | def __dir__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__dir__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__dir__().(self)): |
| 1191 | return dir(typescip-python python python-stdlib 3.11 builtins/type#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__dir__().(self))) + listscip-python python python-stdlib 3.11 builtins/list#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__dir__().(self).keysscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#keys().()) |
| 1192 | |
| 1193 | @classmethodscip-python python python-stdlib 3.11 builtins/classmethod# |
| 1194 | def from_dictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#from_dict().(clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#from_dict().(cls), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#from_dict().(other), namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#from_dict().(name)=None): |
| 1195 | """ |
| 1196 | Helper classmethod to construct a ParseResults from a dict, preserving the |
| 1197 | name-value relations as results names. If an optional 'name' argument is |
| 1198 | given, a nested ParseResults will be returned |
| 1199 | """ |
| 1200 | def is_iterablescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#is_iterable().(objscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#is_iterable().(obj)): |
| 1201 | try: |
| 1202 | iterscip-python python python-stdlib 3.11 builtins/iter().(objscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#is_iterable().(obj)) |
| 1203 | except Exceptionscip-python python python-stdlib 3.11 builtins/Exception#: |
| 1204 | return False |
| 1205 | else: |
| 1206 | if PY_3scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PY_3.: |
| 1207 | return not isinstance(objscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#is_iterable().(obj), (strscip-python python python-stdlib 3.11 builtins/str#, bytesscip-python python python-stdlib 3.11 builtins/bytes#)) |
| 1208 | else: |
| 1209 | return not isinstance(objscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#is_iterable().(obj), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.) |
| 1210 | |
| 1211 | ret = clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#from_dict().(cls)([]) |
| 1212 | for k, v in otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#from_dict().(other).items(): |
| 1213 | if isinstance(v, Mappingscip-python python python-stdlib 3.11 typing/Mapping#): |
| 1214 | ret += clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#from_dict().(cls).from_dictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#from_dict().(v, namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#from_dict().(name)=k) |
| 1215 | else: |
| 1216 | ret += clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#from_dict().(cls)([v], name=k, asList=is_iterablescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#is_iterable().(v)) |
| 1217 | if namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#from_dict().(name) is not None: |
| 1218 | ret = clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#from_dict().(cls)([ret], name=namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#from_dict().(name)) |
| 1219 | return ret |
| 1220 | |
| 1221 | MutableMappingscip-python python python-stdlib 3.11 typing/MutableMapping#.register(ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#) |
| 1222 | |
| 1223 | def colscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/col(). (locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/col().(loc), strgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/col().(strg)): |
| 1224 | """Returns current column within a string, counting newlines as line separators. |
| 1225 | The first column is number 1. |
| 1226 | |
| 1227 | Note: the default parsing behavior is to expand tabs in the input string |
| 1228 | before starting the parsing process. See |
| 1229 | :class:`ParserElement.parseString` for more |
| 1230 | information on parsing strings containing ``<TAB>`` s, and suggested |
| 1231 | methods to maintain a consistent view of the parsed string, the parse |
| 1232 | location, and line and column positions within the parsed string. |
| 1233 | """ |
| 1234 | s = strgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/col().(strg) |
| 1235 | return 1 if 0 < locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/col().(loc) < len(s) and s[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/col().(loc)-1] == '\n' else locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/col().(loc) - s.rfind("\n", 0, locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/col().(loc)) |
| 1236 | |
| 1237 | def linenoscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/lineno().(locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/lineno().(loc), strgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/lineno().(strg)): |
| 1238 | """Returns current line number within a string, counting newlines as line separators. |
| 1239 | The first line is number 1. |
| 1240 | |
| 1241 | Note - the default parsing behavior is to expand tabs in the input string |
| 1242 | before starting the parsing process. See :class:`ParserElement.parseString` |
| 1243 | for more information on parsing strings containing ``<TAB>`` s, and |
| 1244 | suggested methods to maintain a consistent view of the parsed string, the |
| 1245 | parse location, and line and column positions within the parsed string. |
| 1246 | """ |
| 1247 | return strgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/lineno().(strg).count("\n", 0, locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/lineno().(loc)) + 1 |
| 1248 | |
| 1249 | def linescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/line().(locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/line().(loc), strgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/line().(strg)): |
| 1250 | """Returns the line of text containing loc within a string, counting newlines as line separators. |
| 1251 | """ |
| 1252 | lastCR = strgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/line().(strg).rfind("\n", 0, locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/line().(loc)) |
| 1253 | nextCR = strgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/line().(strg).find("\n", locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/line().(loc)) |
| 1254 | if nextCR >= 0: |
| 1255 | return strgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/line().(strg)[lastCR + 1:nextCR] |
| 1256 | else: |
| 1257 | return strgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/line().(strg)[lastCR + 1:] |
| 1258 | |
| 1259 | def _defaultStartDebugActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultStartDebugAction().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultStartDebugAction().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultStartDebugAction().(loc), exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultStartDebugAction().(expr)): |
| 1260 | printscip-python python python-stdlib 3.11 builtins/print().(("Match " + _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultStartDebugAction().(expr)) + " at loc " + _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultStartDebugAction().(loc)) + "(%d,%d)" % (linenoscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/lineno().(locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultStartDebugAction().(loc), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultStartDebugAction().(instring)), colscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/col().(locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultStartDebugAction().(loc), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultStartDebugAction().(instring))))) |
| 1261 | |
| 1262 | def _defaultSuccessDebugActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultSuccessDebugAction().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultSuccessDebugAction().(instring), startlocscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultSuccessDebugAction().(startloc), endlocscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultSuccessDebugAction().(endloc), exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultSuccessDebugAction().(expr), toksscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultSuccessDebugAction().(toks)): |
| 1263 | printscip-python python python-stdlib 3.11 builtins/print().("Matched " + _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultSuccessDebugAction().(expr)) + " -> " + strscip-python python python-stdlib 3.11 builtins/str#(toksscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultSuccessDebugAction().(toks).asList())) |
| 1264 | |
| 1265 | def _defaultExceptionDebugActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultExceptionDebugAction().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultExceptionDebugAction().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultExceptionDebugAction().(loc), exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultExceptionDebugAction().(expr), excscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultExceptionDebugAction().(exc)): |
| 1266 | printscip-python python python-stdlib 3.11 builtins/print().("Exception raised:" + _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(excscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultExceptionDebugAction().(exc))) |
| 1267 | |
| 1268 | def nullDebugActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nullDebugAction().(*argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nullDebugAction().(args)): |
| 1269 | """'Do-nothing' debug action, to suppress debugging output during parsing.""" |
| 1270 | pass |
| 1271 | |
| 1272 | # Only works on Python 3.x - nonlocal is toxic to Python 2 installs |
| 1273 | #~ 'decorator to trim function calls to match the arity of the target' |
| 1274 | #~ def _trim_arity(func, maxargs=3): |
| 1275 | #~ if func in singleArgBuiltins: |
| 1276 | #~ return lambda s,l,t: func(t) |
| 1277 | #~ limit = 0 |
| 1278 | #~ foundArity = False |
| 1279 | #~ def wrapper(*args): |
| 1280 | #~ nonlocal limit,foundArity |
| 1281 | #~ while 1: |
| 1282 | #~ try: |
| 1283 | #~ ret = func(*args[limit:]) |
| 1284 | #~ foundArity = True |
| 1285 | #~ return ret |
| 1286 | #~ except TypeError: |
| 1287 | #~ if limit == maxargs or foundArity: |
| 1288 | #~ raise |
| 1289 | #~ limit += 1 |
| 1290 | #~ continue |
| 1291 | #~ return wrapper |
| 1292 | |
| 1293 | # this version is Python 2.x-3.x cross-compatible |
| 1294 | 'decorator to trim function calls to match the arity of the target' |
| 1295 | def _trim_arityscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().(funcscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().(func), maxargsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().(maxargs)=2): |
| 1296 | if funcscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().(func) in singleArgBuiltinsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/singleArgBuiltins.: |
| 1297 | return lambda s, l, t: funcscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().(func)(t) |
| 1298 | limit = [0] |
| 1299 | foundArity = [False] |
| 1300 | |
| 1301 | # traceback return data structure changed in Py3.5 - normalize back to plain tuples |
| 1302 | if system_versionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/system_version.[:2] >= (3, 5): |
| 1303 | def extract_stackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().extract_stack().(limitscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().extract_stack().(limit)=0): |
| 1304 | # special handling for Python 3.5.0 - extra deep call stack by 1 |
| 1305 | offset = -3 if system_versionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/system_version. == (3, 5, 0) else -2 |
| 1306 | frame_summary = tracebackscip-python python python-stdlib 3.11 traceback/__init__:.extract_stackscip-python python python-stdlib 3.11 traceback/extract_stack().(limitscip-python python python-stdlib 3.11 traceback/extract_stack().(limit)=-offset + limitscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().extract_stack().(limit) - 1)[offset] |
| 1307 | return [frame_summary[:2]] |
| 1308 | def extract_tbscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().extract_tb().(tbscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().extract_tb().(tb), limitscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().extract_tb().(limit)=0): |
| 1309 | frames = tracebackscip-python python python-stdlib 3.11 traceback/__init__:.extract_tbscip-python python python-stdlib 3.11 traceback/extract_tb().(tbscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().extract_tb().(tb), limitscip-python python python-stdlib 3.11 traceback/extract_tb().(limit)=limitscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().extract_tb().(limit)) |
| 1310 | frame_summary = frames[-1] |
| 1311 | return [frame_summary[:2]] |
| 1312 | else: |
| 1313 | extract_stackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().extract_stack(). = tracebackscip-python python python-stdlib 3.11 traceback/__init__:.extract_stackscip-python python python-stdlib 3.11 traceback/extract_stack(). |
| 1314 | extract_tbscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().extract_tb(). = tracebackscip-python python python-stdlib 3.11 traceback/__init__:.extract_tbscip-python python python-stdlib 3.11 traceback/extract_tb(). |
| 1315 | |
| 1316 | # synthesize what would be returned by traceback.extract_stack at the call to |
| 1317 | # user's parse action 'func', so that we don't incur call penalty at parse time |
| 1318 | |
| 1319 | LINE_DIFF = 6 |
| 1320 | # IF ANY CODE CHANGES, EVEN JUST COMMENTS OR BLANK LINES, BETWEEN THE NEXT LINE AND |
| 1321 | # THE CALL TO FUNC INSIDE WRAPPER, LINE_DIFF MUST BE MODIFIED!!!! |
| 1322 | this_line = extract_stackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().extract_stack().(limitscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().extract_stack().(limit)=2)[-1] |
| 1323 | pa_call_line_synth = (this_line[0], this_line[1] + LINE_DIFF) |
| 1324 | |
| 1325 | def wrapperscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().wrapper().(*argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().wrapper().(args)): |
| 1326 | while 1: |
| 1327 | try: |
| 1328 | ret = funcscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().(func)(*argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().wrapper().(args)[limit[0]:]) |
| 1329 | foundArity[0] = True |
| 1330 | return ret |
| 1331 | except TypeErrorscip-python python python-stdlib 3.11 builtins/TypeError#: |
| 1332 | # re-raise TypeErrors if they did not come from our arity testing |
| 1333 | if foundArity[0]: |
| 1334 | raise |
| 1335 | else: |
| 1336 | try: |
| 1337 | tb = sysscip-python python python-stdlib 3.11 sys/__init__:.exc_infoscip-python python python-stdlib 3.11 sys/exc_info().()[-1] |
| 1338 | if not extract_tbscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().extract_tb().(tb, limitscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().extract_tb().(limit)=2)[-1][:2] == pa_call_line_synth: |
| 1339 | raise |
| 1340 | finally: |
| 1341 | try: |
| 1342 | del tb |
| 1343 | except NameErrorscip-python python python-stdlib 3.11 builtins/NameError#: |
| 1344 | pass |
| 1345 | |
| 1346 | if limit[0] <= maxargsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().(maxargs): |
| 1347 | limit[0] += 1 |
| 1348 | continue |
| 1349 | raise |
| 1350 | |
| 1351 | # copy func name to wrapper for sensible debug output |
| 1352 | func_name = "<parse action>" |
| 1353 | try: |
| 1354 | func_name = getattrscip-python python python-stdlib 3.11 builtins/getattr().(funcscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().(func), '__name__', |
| 1355 | getattrscip-python python python-stdlib 3.11 builtins/getattr().(funcscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().(func), '__class__').__name__) |
| 1356 | except Exceptionscip-python python python-stdlib 3.11 builtins/Exception#: |
| 1357 | func_name = strscip-python python python-stdlib 3.11 builtins/str#(funcscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().(func)) |
| 1358 | wrapperscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().wrapper()..__name__ = func_name |
| 1359 | |
| 1360 | return wrapperscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().wrapper(). |
| 1361 | |
| 1362 | |
| 1363 | class ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#(objectscip-python python python-stdlib 3.11 builtins/object#): |
| 1364 | """Abstract base level parser element class.""" |
| 1365 | DEFAULT_WHITE_CHARSscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#DEFAULT_WHITE_CHARS. = " \n\t\r" |
| 1366 | verbose_stacktracescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#verbose_stacktrace. = False |
| 1367 | |
| 1368 | @staticmethodscip-python python python-stdlib 3.11 builtins/staticmethod# |
| 1369 | def setDefaultWhitespaceCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDefaultWhitespaceChars().(charsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDefaultWhitespaceChars().(chars)): |
| 1370 | r""" |
| 1371 | Overrides the default whitespace chars |
| 1372 | |
| 1373 | Example:: |
| 1374 | |
| 1375 | # default whitespace chars are space, <TAB> and newline |
| 1376 | OneOrMore(Word(alphas)).parseString("abc def\nghi jkl") # -> ['abc', 'def', 'ghi', 'jkl'] |
| 1377 | |
| 1378 | # change to just treat newline as significant |
| 1379 | ParserElement.setDefaultWhitespaceChars(" \t") |
| 1380 | OneOrMore(Word(alphas)).parseString("abc def\nghi jkl") # -> ['abc', 'def'] |
| 1381 | """ |
| 1382 | ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.DEFAULT_WHITE_CHARSscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#DEFAULT_WHITE_CHARS. = charsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDefaultWhitespaceChars().(chars) |
| 1383 | |
| 1384 | @staticmethodscip-python python python-stdlib 3.11 builtins/staticmethod# |
| 1385 | def inlineLiteralsUsingscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#inlineLiteralsUsing().(clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#inlineLiteralsUsing().(cls)): |
| 1386 | """ |
| 1387 | Set class to be used for inclusion of string literals into a parser. |
| 1388 | |
| 1389 | Example:: |
| 1390 | |
| 1391 | # default literal class used is Literal |
| 1392 | integer = Word(nums) |
| 1393 | date_str = integer("year") + '/' + integer("month") + '/' + integer("day") |
| 1394 | |
| 1395 | date_str.parseString("1999/12/31") # -> ['1999', '/', '12', '/', '31'] |
| 1396 | |
| 1397 | |
| 1398 | # change to Suppress |
| 1399 | ParserElement.inlineLiteralsUsing(Suppress) |
| 1400 | date_str = integer("year") + '/' + integer("month") + '/' + integer("day") |
| 1401 | |
| 1402 | date_str.parseString("1999/12/31") # -> ['1999', '12', '31'] |
| 1403 | """ |
| 1404 | ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#._literalStringClass = clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#inlineLiteralsUsing().(cls) |
| 1405 | |
| 1406 | @classmethodscip-python python python-stdlib 3.11 builtins/classmethod# |
| 1407 | def _trim_tracebackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_trim_traceback().(clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_trim_traceback().(cls), tbscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_trim_traceback().(tb)): |
| 1408 | while tbscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_trim_traceback().(tb).tb_next: |
| 1409 | tbscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_trim_traceback().(tb) = tbscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_trim_traceback().(tb).tb_next |
| 1410 | return tbscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_trim_traceback().(tb) |
| 1411 | |
| 1412 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(self), savelistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(savelist)=False): |
| 1413 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(self).parseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseAction. = listscip-python python python-stdlib 3.11 builtins/list#() |
| 1414 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(self).failActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#failAction. = None |
| 1415 | # ~ self.name = "<unknown>" # don't define self.name, let subclasses try/except upcall |
| 1416 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#strRepr. = None |
| 1417 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(self).resultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#resultsName. = None |
| 1418 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(self).saveAsListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#saveAsList. = savelistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(savelist) |
| 1419 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(self).skipWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#skipWhitespace. = True |
| 1420 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(self).whiteCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#whiteChars. = setscip-python python python-stdlib 3.11 builtins/set#(ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.DEFAULT_WHITE_CHARSscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#DEFAULT_WHITE_CHARS.) |
| 1421 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(self).copyDefaultWhiteCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copyDefaultWhiteChars. = True |
| 1422 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayReturnEmpty. = False # used when checking for left-recursion |
| 1423 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(self).keepTabsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#keepTabs. = False |
| 1424 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(self).ignoreExprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignoreExprs. = listscip-python python python-stdlib 3.11 builtins/list#() |
| 1425 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(self).debugscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#debug. = False |
| 1426 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(self).streamlinedscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#streamlined. = False |
| 1427 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(self).mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayIndexError. = True # used to optimize exception handling for subclasses that don't advance parse index |
| 1428 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#errmsg. = "" |
| 1429 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(self).modalResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#modalResults. = True # used to mark results names as modal (report only last) or cumulative (list all) |
| 1430 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(self).debugActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#debugActions. = (None, None, None) # custom debug actions |
| 1431 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(self).rescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#re. = None |
| 1432 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(self).callPreparsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#callPreparse. = True # used to avoid redundant calls to preParse |
| 1433 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(self).callDuringTryscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#callDuringTry. = False |
| 1434 | |
| 1435 | def copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().(self)): |
| 1436 | """ |
| 1437 | Make a copy of this :class:`ParserElement`. Useful for defining |
| 1438 | different parse actions for the same parsing pattern, using copies of |
| 1439 | the original parse element. |
| 1440 | |
| 1441 | Example:: |
| 1442 | |
| 1443 | integer = Word(nums).setParseAction(lambda toks: int(toks[0])) |
| 1444 | integerK = integer.copy().addParseAction(lambda toks: toks[0] * 1024) + Suppress("K") |
| 1445 | integerM = integer.copy().addParseAction(lambda toks: toks[0] * 1024 * 1024) + Suppress("M") |
| 1446 | |
| 1447 | print(OneOrMore(integerK | integerM | integer).parseString("5K 100 640K 256M")) |
| 1448 | |
| 1449 | prints:: |
| 1450 | |
| 1451 | [5120, 100, 655360, 268435456] |
| 1452 | |
| 1453 | Equivalent form of ``expr.copy()`` is just ``expr()``:: |
| 1454 | |
| 1455 | integerM = integer().addParseAction(lambda toks: toks[0] * 1024 * 1024) + Suppress("M") |
| 1456 | """ |
| 1457 | cpy = copyscip-python python python-stdlib 3.11 copy/__init__:.copyscip-python python python-stdlib 3.11 copy/copy().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().(self)) |
| 1458 | cpy.parseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseAction. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().(self).parseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseAction.[:] |
| 1459 | cpy.ignoreExprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignoreExprs. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().(self).ignoreExprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignoreExprs.[:] |
| 1460 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().(self).copyDefaultWhiteCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copyDefaultWhiteChars.: |
| 1461 | cpy.whiteCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#whiteChars. = ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.DEFAULT_WHITE_CHARSscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#DEFAULT_WHITE_CHARS. |
| 1462 | return cpy |
| 1463 | |
| 1464 | def setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().(self), namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().(name)): |
| 1465 | """ |
| 1466 | Define name for this expression, makes debugging and exception messages clearer. |
| 1467 | |
| 1468 | Example:: |
| 1469 | |
| 1470 | Word(nums).parseString("ABC") # -> Exception: Expected W:(0123...) (at char 0), (line:1, col:1) |
| 1471 | Word(nums).setName("integer").parseString("ABC") # -> Exception: Expected integer (at char 0), (line:1, col:1) |
| 1472 | """ |
| 1473 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#name. = namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().(name) |
| 1474 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#errmsg. = "Expected " + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#name. |
| 1475 | if __diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__..enable_debug_on_named_expressions: |
| 1476 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().(self).setDebugscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDebug().() |
| 1477 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().(self) |
| 1478 | |
| 1479 | def setResultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setResultsName().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setResultsName().(self), namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setResultsName().(name), listAllMatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setResultsName().(listAllMatches)=False): |
| 1480 | """ |
| 1481 | Define name for referencing matching tokens as a nested attribute |
| 1482 | of the returned parse results. |
| 1483 | NOTE: this returns a *copy* of the original :class:`ParserElement` object; |
| 1484 | this is so that the client can define a basic element, such as an |
| 1485 | integer, and reference it in multiple places with different names. |
| 1486 | |
| 1487 | You can also set results names using the abbreviated syntax, |
| 1488 | ``expr("name")`` in place of ``expr.setResultsName("name")`` |
| 1489 | - see :class:`__call__`. |
| 1490 | |
| 1491 | Example:: |
| 1492 | |
| 1493 | date_str = (integer.setResultsName("year") + '/' |
| 1494 | + integer.setResultsName("month") + '/' |
| 1495 | + integer.setResultsName("day")) |
| 1496 | |
| 1497 | # equivalent form: |
| 1498 | date_str = integer("year") + '/' + integer("month") + '/' + integer("day") |
| 1499 | """ |
| 1500 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setResultsName().(self)._setResultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_setResultsName().(namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setResultsName().(name), listAllMatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setResultsName().(listAllMatches)) |
| 1501 | |
| 1502 | def _setResultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_setResultsName().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_setResultsName().(self), namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_setResultsName().(name), listAllMatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_setResultsName().(listAllMatches)=False): |
| 1503 | newself = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_setResultsName().(self).copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().() |
| 1504 | if namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_setResultsName().(name).endswith("*"): |
| 1505 | namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_setResultsName().(name) = namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_setResultsName().(name)[:-1] |
| 1506 | listAllMatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_setResultsName().(listAllMatches) = True |
| 1507 | newself.resultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#resultsName. = namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_setResultsName().(name) |
| 1508 | newself.modalResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#modalResults. = not listAllMatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_setResultsName().(listAllMatches) |
| 1509 | return newself |
| 1510 | |
| 1511 | def setBreakscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setBreak().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setBreak().(self), breakFlagscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setBreak().(breakFlag)=True): |
| 1512 | """Method to invoke the Python pdb debugger when this element is |
| 1513 | about to be parsed. Set ``breakFlag`` to True to enable, False to |
| 1514 | disable. |
| 1515 | """ |
| 1516 | if breakFlagscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setBreak().(breakFlag): |
| 1517 | _parseMethod = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setBreak().(self)._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse. |
| 1518 | def breakerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#breaker().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#breaker().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#breaker().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#breaker().(doActions)=True, callPreParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#breaker().(callPreParse)=True): |
| 1519 | import pdbscip-python python python-stdlib 3.11 pdb/__init__: |
| 1520 | # this call to pdb.set_trace() is intentional, not a checkin error |
| 1521 | pdbscip-python python python-stdlib 3.11 pdb/__init__:.set_tracescip-python python python-stdlib 3.11 pdb/set_trace().() |
| 1522 | return _parseMethod(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#breaker().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#breaker().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#breaker().(doActions), callPreParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#breaker().(callPreParse)) |
| 1523 | breakerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#breaker().._originalParseMethod = _parseMethod |
| 1524 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setBreak().(self)._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse. = breakerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#breaker(). |
| 1525 | else: |
| 1526 | if hasattr(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setBreak().(self)._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse., "_originalParseMethod"): |
| 1527 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setBreak().(self)._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setBreak().(self)._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse.._originalParseMethod |
| 1528 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setBreak().(self) |
| 1529 | |
| 1530 | def setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(self), *fnsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(fns), **kwargsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(kwargs)): |
| 1531 | """ |
| 1532 | Define one or more actions to perform when successfully matching parse element definition. |
| 1533 | Parse action fn is a callable method with 0-3 arguments, called as ``fn(s, loc, toks)`` , |
| 1534 | ``fn(loc, toks)`` , ``fn(toks)`` , or just ``fn()`` , where: |
| 1535 | |
| 1536 | - s = the original string being parsed (see note below) |
| 1537 | - loc = the location of the matching substring |
| 1538 | - toks = a list of the matched tokens, packaged as a :class:`ParseResults` object |
| 1539 | |
| 1540 | If the functions in fns modify the tokens, they can return them as the return |
| 1541 | value from fn, and the modified list of tokens will replace the original. |
| 1542 | Otherwise, fn does not need to return any value. |
| 1543 | |
| 1544 | If None is passed as the parse action, all previously added parse actions for this |
| 1545 | expression are cleared. |
| 1546 | |
| 1547 | Optional keyword arguments: |
| 1548 | - callDuringTry = (default= ``False``) indicate if parse action should be run during lookaheads and alternate testing |
| 1549 | |
| 1550 | Note: the default parsing behavior is to expand tabs in the input string |
| 1551 | before starting the parsing process. See :class:`parseString for more |
| 1552 | information on parsing strings containing ``<TAB>`` s, and suggested |
| 1553 | methods to maintain a consistent view of the parsed string, the parse |
| 1554 | location, and line and column positions within the parsed string. |
| 1555 | |
| 1556 | Example:: |
| 1557 | |
| 1558 | integer = Word(nums) |
| 1559 | date_str = integer + '/' + integer + '/' + integer |
| 1560 | |
| 1561 | date_str.parseString("1999/12/31") # -> ['1999', '/', '12', '/', '31'] |
| 1562 | |
| 1563 | # use parse action to convert to ints at parse time |
| 1564 | integer = Word(nums).setParseAction(lambda toks: int(toks[0])) |
| 1565 | date_str = integer + '/' + integer + '/' + integer |
| 1566 | |
| 1567 | # note that integer fields are now ints, not strings |
| 1568 | date_str.parseString("1999/12/31") # -> [1999, '/', 12, '/', 31] |
| 1569 | """ |
| 1570 | if listscip-python python python-stdlib 3.11 builtins/list#(fnsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(fns)) == [None,]: |
| 1571 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(self).parseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseAction. = [] |
| 1572 | else: |
| 1573 | if not all(callable(fn) for fn in fnsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(fns)): |
| 1574 | raise TypeErrorscip-python python python-stdlib 3.11 builtins/TypeError#("parse actions must be callable") |
| 1575 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(self).parseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseAction. = listscip-python python python-stdlib 3.11 builtins/list#(mapscip-python python python-stdlib 3.11 builtins/map#(_trim_arityscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity()., listscip-python python python-stdlib 3.11 builtins/list#(fnsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(fns)))) |
| 1576 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(self).callDuringTryscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#callDuringTry. = kwargsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(kwargs).getscip-python python python-stdlib 3.11 builtins/dict#get().("callDuringTry", False) |
| 1577 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(self) |
| 1578 | |
| 1579 | def addParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addParseAction().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addParseAction().(self), *fnsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addParseAction().(fns), **kwargsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addParseAction().(kwargs)): |
| 1580 | """ |
| 1581 | Add one or more parse actions to expression's list of parse actions. See :class:`setParseAction`. |
| 1582 | |
| 1583 | See examples in :class:`copy`. |
| 1584 | """ |
| 1585 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addParseAction().(self).parseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseAction. += listscip-python python python-stdlib 3.11 builtins/list#(mapscip-python python python-stdlib 3.11 builtins/map#(_trim_arityscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity()., listscip-python python python-stdlib 3.11 builtins/list#(fnsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addParseAction().(fns)))) |
| 1586 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addParseAction().(self).callDuringTryscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#callDuringTry. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addParseAction().(self).callDuringTryscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#callDuringTry. or kwargsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addParseAction().(kwargs).getscip-python python python-stdlib 3.11 builtins/dict#get().("callDuringTry", False) |
| 1587 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addParseAction().(self) |
| 1588 | |
| 1589 | def addConditionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addCondition().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addCondition().(self), *fnsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addCondition().(fns), **kwargsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addCondition().(kwargs)): |
| 1590 | """Add a boolean predicate function to expression's list of parse actions. See |
| 1591 | :class:`setParseAction` for function call signatures. Unlike ``setParseAction``, |
| 1592 | functions passed to ``addCondition`` need to return boolean success/fail of the condition. |
| 1593 | |
| 1594 | Optional keyword arguments: |
| 1595 | - message = define a custom message to be used in the raised exception |
| 1596 | - fatal = if True, will raise ParseFatalException to stop parsing immediately; otherwise will raise ParseException |
| 1597 | |
| 1598 | Example:: |
| 1599 | |
| 1600 | integer = Word(nums).setParseAction(lambda toks: int(toks[0])) |
| 1601 | year_int = integer.copy() |
| 1602 | year_int.addCondition(lambda toks: toks[0] >= 2000, message="Only support years 2000 and later") |
| 1603 | date_str = year_int + '/' + integer + '/' + integer |
| 1604 | |
| 1605 | result = date_str.parseString("1999/12/31") # -> Exception: Only support years 2000 and later (at char 0), (line:1, col:1) |
| 1606 | """ |
| 1607 | for fn in fnsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addCondition().(fns): |
| 1608 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addCondition().(self).parseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseAction..appendscip-python python python-stdlib 3.11 builtins/list#append().(conditionAsParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().(fn, messagescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().(message)=kwargsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addCondition().(kwargs).getscip-python python python-stdlib 3.11 builtins/dict#get().('message'), |
| 1609 | fatalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/conditionAsParseAction().(fatal)=kwargsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addCondition().(kwargs).getscip-python python python-stdlib 3.11 builtins/dict#get().('fatal', False))) |
| 1610 | |
| 1611 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addCondition().(self).callDuringTryscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#callDuringTry. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addCondition().(self).callDuringTryscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#callDuringTry. or kwargsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addCondition().(kwargs).getscip-python python python-stdlib 3.11 builtins/dict#get().("callDuringTry", False) |
| 1612 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addCondition().(self) |
| 1613 | |
| 1614 | def setFailActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setFailAction().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setFailAction().(self), fnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setFailAction().(fn)): |
| 1615 | """Define action to perform if parsing fails at this expression. |
| 1616 | Fail acton fn is a callable function that takes the arguments |
| 1617 | ``fn(s, loc, expr, err)`` where: |
| 1618 | - s = string being parsed |
| 1619 | - loc = location where expression match was attempted and failed |
| 1620 | - expr = the parse expression that failed |
| 1621 | - err = the exception thrown |
| 1622 | The function returns no value. It may throw :class:`ParseFatalException` |
| 1623 | if it is desired to stop parsing immediately.""" |
| 1624 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setFailAction().(self).failActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#failAction. = fnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setFailAction().(fn) |
| 1625 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setFailAction().(self) |
| 1626 | |
| 1627 | def _skipIgnorablesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_skipIgnorables().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_skipIgnorables().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_skipIgnorables().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_skipIgnorables().(loc)): |
| 1628 | exprsFound = True |
| 1629 | while exprsFound: |
| 1630 | exprsFound = False |
| 1631 | for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_skipIgnorables().(self).ignoreExprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignoreExprs.: |
| 1632 | try: |
| 1633 | while 1: |
| 1634 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_skipIgnorables().(loc), dummy = e._parse(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_skipIgnorables().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_skipIgnorables().(loc)) |
| 1635 | exprsFound = True |
| 1636 | except ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#: |
| 1637 | pass |
| 1638 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_skipIgnorables().(loc) |
| 1639 | |
| 1640 | def preParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse().(loc)): |
| 1641 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse().(self).ignoreExprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignoreExprs.: |
| 1642 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse().(loc) = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse().(self)._skipIgnorablesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_skipIgnorables().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse().(loc)) |
| 1643 | |
| 1644 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse().(self).skipWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#skipWhitespace.: |
| 1645 | wt = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse().(self).whiteCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#whiteChars. |
| 1646 | instrlen = len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse().(instring)) |
| 1647 | while locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse().(loc) < instrlen and instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse().(loc)] in wt: |
| 1648 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse().(loc) += 1 |
| 1649 | |
| 1650 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse().(loc) |
| 1651 | |
| 1652 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseImpl().(doActions)=True): |
| 1653 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseImpl().(loc), [] |
| 1654 | |
| 1655 | def postParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#postParse().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#postParse().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#postParse().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#postParse().(loc), tokenlistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#postParse().(tokenlist)): |
| 1656 | return tokenlistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#postParse().(tokenlist) |
| 1657 | |
| 1658 | # ~ @profile |
| 1659 | def _parseNoCachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(doActions)=True, callPreParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(callPreParse)=True): |
| 1660 | TRY, MATCH, FAIL = 0, 1, 2 |
| 1661 | debugging = (selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).debugscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#debug.) # and doActions) |
| 1662 | |
| 1663 | if debugging or selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).failActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#failAction.: |
| 1664 | # ~ print ("Match", self, "at loc", loc, "(%d, %d)" % (lineno(loc, instring), col(loc, instring))) |
| 1665 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).debugActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#debugActions.[TRY]: |
| 1666 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).debugActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#debugActions.[TRY](instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self)) |
| 1667 | try: |
| 1668 | if callPreParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(callPreParse) and selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).callPreparsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#callPreparse.: |
| 1669 | preloc = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).preParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(loc)) |
| 1670 | else: |
| 1671 | preloc = locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(loc) |
| 1672 | tokensStart = preloc |
| 1673 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayIndexError. or preloc >= len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instring)): |
| 1674 | try: |
| 1675 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(loc), tokens = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseImpl().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instring), preloc, doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(doActions)) |
| 1676 | except IndexErrorscip-python python python-stdlib 3.11 builtins/IndexError#: |
| 1677 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instring), len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instring)), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self)) |
| 1678 | else: |
| 1679 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(loc), tokens = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseImpl().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instring), preloc, doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(doActions)) |
| 1680 | except Exceptionscip-python python python-stdlib 3.11 builtins/Exception# as err: |
| 1681 | # ~ print ("Exception raised:", err) |
| 1682 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).debugActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#debugActions.[FAIL]: |
| 1683 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).debugActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#debugActions.[FAIL](instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instring), tokensStart, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self), err) |
| 1684 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).failActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#failAction.: |
| 1685 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).failActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#failAction.(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instring), tokensStart, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self), err) |
| 1686 | raise |
| 1687 | else: |
| 1688 | if callPreParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(callPreParse) and selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).callPreparsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#callPreparse.: |
| 1689 | preloc = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).preParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(loc)) |
| 1690 | else: |
| 1691 | preloc = locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(loc) |
| 1692 | tokensStart = preloc |
| 1693 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayIndexError. or preloc >= len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instring)): |
| 1694 | try: |
| 1695 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(loc), tokens = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseImpl().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instring), preloc, doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(doActions)) |
| 1696 | except IndexErrorscip-python python python-stdlib 3.11 builtins/IndexError#: |
| 1697 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instring), len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instring)), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self)) |
| 1698 | else: |
| 1699 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(loc), tokens = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseImpl().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instring), preloc, doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(doActions)) |
| 1700 | |
| 1701 | tokens = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).postParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#postParse().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(loc), tokens) |
| 1702 | |
| 1703 | retTokens = ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#(tokens, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).resultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#resultsName., asListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(asList)=selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).saveAsListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#saveAsList., modalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(modal)=selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).modalResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#modalResults.) |
| 1704 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).parseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseAction. and (doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(doActions) or selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).callDuringTryscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#callDuringTry.): |
| 1705 | if debugging: |
| 1706 | try: |
| 1707 | for fn in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).parseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseAction.: |
| 1708 | try: |
| 1709 | tokens = fn(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instring), tokensStart, retTokens) |
| 1710 | except IndexErrorscip-python python python-stdlib 3.11 builtins/IndexError# as parse_action_exc: |
| 1711 | exc = ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#("exception raised in parse action") |
| 1712 | exc.__cause__scip-python python python-stdlib 3.11 builtins/BaseException#__cause__. = parse_action_exc |
| 1713 | raise exc |
| 1714 | |
| 1715 | if tokens is not None and tokens is not retTokens: |
| 1716 | retTokens = ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#(tokens, |
| 1717 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).resultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#resultsName., |
| 1718 | asListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(asList)=selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).saveAsListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#saveAsList. and isinstance(tokens, (ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#, listscip-python python python-stdlib 3.11 builtins/list#)), |
| 1719 | modalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(modal)=selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).modalResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#modalResults.) |
| 1720 | except Exceptionscip-python python python-stdlib 3.11 builtins/Exception# as err: |
| 1721 | # ~ print "Exception raised in user parse action:", err |
| 1722 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).debugActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#debugActions.[FAIL]: |
| 1723 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).debugActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#debugActions.[FAIL](instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instring), tokensStart, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self), err) |
| 1724 | raise |
| 1725 | else: |
| 1726 | for fn in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).parseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseAction.: |
| 1727 | try: |
| 1728 | tokens = fn(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instring), tokensStart, retTokens) |
| 1729 | except IndexErrorscip-python python python-stdlib 3.11 builtins/IndexError# as parse_action_exc: |
| 1730 | exc = ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#("exception raised in parse action") |
| 1731 | exc.__cause__scip-python python python-stdlib 3.11 builtins/BaseException#__cause__. = parse_action_exc |
| 1732 | raise exc |
| 1733 | |
| 1734 | if tokens is not None and tokens is not retTokens: |
| 1735 | retTokens = ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#(tokens, |
| 1736 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).resultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#resultsName., |
| 1737 | asListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(asList)=selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).saveAsListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#saveAsList. and isinstance(tokens, (ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#, listscip-python python python-stdlib 3.11 builtins/list#)), |
| 1738 | modalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(modal)=selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).modalResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#modalResults.) |
| 1739 | if debugging: |
| 1740 | # ~ print ("Matched", self, "->", retTokens.asList()) |
| 1741 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).debugActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#debugActions.[MATCH]: |
| 1742 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self).debugActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#debugActions.[MATCH](instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instring), tokensStart, locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(self), retTokens) |
| 1743 | |
| 1744 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(loc), retTokens |
| 1745 | |
| 1746 | def tryParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#tryParse().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#tryParse().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#tryParse().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#tryParse().(loc)): |
| 1747 | try: |
| 1748 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#tryParse().(self)._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse.(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#tryParse().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#tryParse().(loc), doActions=False)[0] |
| 1749 | except ParseFatalExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseFatalException#: |
| 1750 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#tryParse().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#tryParse().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#tryParse().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#tryParse().(self)) |
| 1751 | |
| 1752 | def canParseNextscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#canParseNext().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#canParseNext().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#canParseNext().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#canParseNext().(loc)): |
| 1753 | try: |
| 1754 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#canParseNext().(self).tryParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#tryParse().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#canParseNext().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#canParseNext().(loc)) |
| 1755 | except (ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#, IndexErrorscip-python python python-stdlib 3.11 builtins/IndexError#): |
| 1756 | return False |
| 1757 | else: |
| 1758 | return True |
| 1759 | |
| 1760 | class _UnboundedCachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#(objectscip-python python python-stdlib 3.11 builtins/object#): |
| 1761 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#__init__().(self)): |
| 1762 | cache = {} |
| 1763 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#__init__().(self).not_in_cachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_UnboundedCache#not_in_cache. = not_in_cache = objectscip-python python python-stdlib 3.11 builtins/object#() |
| 1764 | |
| 1765 | def getscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#get().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#get().(self), keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#get().(key)): |
| 1766 | return cache.getscip-python python python-stdlib 3.11 builtins/dict#get().(keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#get().(key), not_in_cache) |
| 1767 | |
| 1768 | def setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#set().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#set().(self), keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#set().(key), valuescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#set().(value)): |
| 1769 | cache[keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#set().(key)] = valuescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#set().(value) |
| 1770 | |
| 1771 | def clearscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#clear().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#clear().(self)): |
| 1772 | cache.clearscip-python python python-stdlib 3.11 typing/MutableMapping#clear().() |
| 1773 | |
| 1774 | def cache_lenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#cache_len().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#cache_len().(self)): |
| 1775 | return len(cache) |
| 1776 | |
| 1777 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#__init__().(self).getscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_UnboundedCache#get. = typesscip-python python python-stdlib 3.11 types/__init__:.MethodTypescip-python python python-stdlib 3.11 types/MethodType#(getscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#get()., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#__init__().(self)) |
| 1778 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#__init__().(self).setscip-python python python-stdlib 3.11 builtins/set# = typesscip-python python python-stdlib 3.11 types/__init__:.MethodTypescip-python python python-stdlib 3.11 types/MethodType#(setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#set()., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#__init__().(self)) |
| 1779 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#__init__().(self).clearscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_UnboundedCache#clear. = typesscip-python python python-stdlib 3.11 types/__init__:.MethodTypescip-python python python-stdlib 3.11 types/MethodType#(clearscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#clear()., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#__init__().(self)) |
| 1780 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#__init__().(self).__len__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_UnboundedCache#__len__. = typesscip-python python python-stdlib 3.11 types/__init__:.MethodTypescip-python python python-stdlib 3.11 types/MethodType#(cache_lenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#cache_len()., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#__init__().(self)) |
| 1781 | |
| 1782 | if _OrderedDictscip-python python python-stdlib 3.11 collections/OrderedDict# is not None: |
| 1783 | class _FifoCachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#(objectscip-python python python-stdlib 3.11 builtins/object#): |
| 1784 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(self), sizescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(size)): |
| 1785 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(self).not_in_cachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_FifoCache#not_in_cache. = not_in_cache = objectscip-python python python-stdlib 3.11 builtins/object#() |
| 1786 | |
| 1787 | cache = _OrderedDictscip-python python python-stdlib 3.11 collections/OrderedDict#() |
| 1788 | |
| 1789 | def getscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#get().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#get().(self), keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#get().(key)): |
| 1790 | return cache.getscip-python python python-stdlib 3.11 builtins/dict#get().(keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#get().(key), not_in_cache) |
| 1791 | |
| 1792 | def setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#set().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#set().(self), keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#set().(key), valuescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#set().(value)): |
| 1793 | cache[keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#set().(key)] = valuescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#set().(value) |
| 1794 | while len(cache) > sizescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(size): |
| 1795 | try: |
| 1796 | cache.popitemscip-python python python-stdlib 3.11 collections/OrderedDict#popitem().(False) |
| 1797 | except KeyErrorscip-python python python-stdlib 3.11 builtins/KeyError#: |
| 1798 | pass |
| 1799 | |
| 1800 | def clearscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#clear().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#clear().(self)): |
| 1801 | cache.clearscip-python python python-stdlib 3.11 typing/MutableMapping#clear().() |
| 1802 | |
| 1803 | def cache_lenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#cache_len().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#cache_len().(self)): |
| 1804 | return len(cache) |
| 1805 | |
| 1806 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(self).getscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_FifoCache#get. = typesscip-python python python-stdlib 3.11 types/__init__:.MethodTypescip-python python python-stdlib 3.11 types/MethodType#(getscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#get()., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(self)) |
| 1807 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(self).setscip-python python python-stdlib 3.11 builtins/set# = typesscip-python python python-stdlib 3.11 types/__init__:.MethodTypescip-python python python-stdlib 3.11 types/MethodType#(setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#set()., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(self)) |
| 1808 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(self).clearscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_FifoCache#clear. = typesscip-python python python-stdlib 3.11 types/__init__:.MethodTypescip-python python python-stdlib 3.11 types/MethodType#(clearscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#clear()., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(self)) |
| 1809 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(self).__len__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_FifoCache#__len__. = typesscip-python python python-stdlib 3.11 types/__init__:.MethodTypescip-python python python-stdlib 3.11 types/MethodType#(cache_lenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#cache_len()., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(self)) |
| 1810 | |
| 1811 | else: |
| 1812 | class _FifoCachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#(objectscip-python python python-stdlib 3.11 builtins/object#): |
| 1813 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(self), sizescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(size)): |
| 1814 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(self).not_in_cachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_FifoCache#not_in_cache. = not_in_cache = objectscip-python python python-stdlib 3.11 builtins/object#() |
| 1815 | |
| 1816 | cache = {} |
| 1817 | key_fifo = collectionsscip-python python python-stdlib 3.11 collections/__init__:.dequescip-python python python-stdlib 3.11 collections/deque#([], sizescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(size)) |
| 1818 | |
| 1819 | def getscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#get().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#get().(self), keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#get().(key)): |
| 1820 | return cache.getscip-python python python-stdlib 3.11 builtins/dict#get().(keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#get().(key), not_in_cache) |
| 1821 | |
| 1822 | def setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#set().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#set().(self), keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#set().(key), valuescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#set().(value)): |
| 1823 | cache[keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#set().(key)] = valuescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#set().(value) |
| 1824 | while len(key_fifo) > sizescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(size): |
| 1825 | cache.popscip-python python python-stdlib 3.11 builtins/dict#pop().(key_fifo.popleftscip-python python python-stdlib 3.11 collections/deque#popleft().(), None) |
| 1826 | key_fifo.appendscip-python python python-stdlib 3.11 collections/deque#append().(keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#set().(key)) |
| 1827 | |
| 1828 | def clearscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#clear().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#clear().(self)): |
| 1829 | cache.clearscip-python python python-stdlib 3.11 typing/MutableMapping#clear().() |
| 1830 | key_fifo.clearscip-python python python-stdlib 3.11 typing/MutableSequence#clear().() |
| 1831 | |
| 1832 | def cache_lenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#cache_len().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#cache_len().(self)): |
| 1833 | return len(cache) |
| 1834 | |
| 1835 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(self).getscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_FifoCache#get. = typesscip-python python python-stdlib 3.11 types/__init__:.MethodTypescip-python python python-stdlib 3.11 types/MethodType#(getscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#get()., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(self)) |
| 1836 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(self).setscip-python python python-stdlib 3.11 builtins/set# = typesscip-python python python-stdlib 3.11 types/__init__:.MethodTypescip-python python python-stdlib 3.11 types/MethodType#(setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#set()., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(self)) |
| 1837 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(self).clearscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_FifoCache#clear. = typesscip-python python python-stdlib 3.11 types/__init__:.MethodTypescip-python python python-stdlib 3.11 types/MethodType#(clearscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#clear()., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(self)) |
| 1838 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(self).__len__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_FifoCache#__len__. = typesscip-python python python-stdlib 3.11 types/__init__:.MethodTypescip-python python python-stdlib 3.11 types/MethodType#(cache_lenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#cache_len()., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#__init__().(self)) |
| 1839 | |
| 1840 | # argument cache for optimizing repeated calls when backtracking through recursive expressions |
| 1841 | packrat_cachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#packrat_cache. = {} # this is set later by enabledPackrat(); this is here so that resetCache() doesn't fail |
| 1842 | packrat_cache_lockscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#packrat_cache_lock. = RLock() |
| 1843 | packrat_cache_statsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#packrat_cache_stats. = [0, 0] |
| 1844 | |
| 1845 | # this method gets repeatedly called during backtracking with the same arguments - |
| 1846 | # we can cache these arguments and save ourselves the trouble of re-parsing the contained expression |
| 1847 | def _parseCachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseCache().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseCache().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseCache().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseCache().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseCache().(doActions)=True, callPreParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseCache().(callPreParse)=True): |
| 1848 | HIT, MISS = 0, 1 |
| 1849 | lookup = (selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseCache().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseCache().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseCache().(loc), callPreParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseCache().(callPreParse), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseCache().(doActions)) |
| 1850 | with ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.packrat_cache_lockscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#packrat_cache_lock.: |
| 1851 | cache = ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.packrat_cachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#packrat_cache. |
| 1852 | value = cache.getscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_UnboundedCache#get.(lookup) |
| 1853 | if value is cache.not_in_cachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_UnboundedCache#not_in_cache.: |
| 1854 | ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.packrat_cache_statsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#packrat_cache_stats.[MISS] += 1 |
| 1855 | try: |
| 1856 | value = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseCache().(self)._parseNoCachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseCache().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseCache().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseCache().(doActions), callPreParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseCache().(callPreParse)) |
| 1857 | except ParseBaseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException# as pe: |
| 1858 | # cache a copy of the exception, without the traceback |
| 1859 | cache.setscip-python python python-stdlib 3.11 builtins/set#(lookup, pe.__class__scip-python python python-stdlib 3.11 builtins/object#__class__().(*pe.argsscip-python python python-stdlib 3.11 builtins/BaseException#args.)) |
| 1860 | raise |
| 1861 | else: |
| 1862 | cache.setscip-python python python-stdlib 3.11 builtins/set#(lookup, (value[0], value[1].copy())) |
| 1863 | return value |
| 1864 | else: |
| 1865 | ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.packrat_cache_statsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#packrat_cache_stats.[HIT] += 1 |
| 1866 | if isinstance(value, Exceptionscip-python python python-stdlib 3.11 builtins/Exception#): |
| 1867 | raise value |
| 1868 | return value[0], value[1].copy() |
| 1869 | |
| 1870 | _parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse. = _parseNoCachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseNoCache(). |
| 1871 | |
| 1872 | @staticmethodscip-python python python-stdlib 3.11 builtins/staticmethod# |
| 1873 | def resetCachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#resetCache().(): |
| 1874 | ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.packrat_cachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#packrat_cache..clearscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_UnboundedCache#clear.() |
| 1875 | ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.packrat_cache_statsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#packrat_cache_stats.[:] = [0] * len(ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.packrat_cache_statsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#packrat_cache_stats.) |
| 1876 | |
| 1877 | _packratEnabledscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_packratEnabled. = False |
| 1878 | @staticmethodscip-python python python-stdlib 3.11 builtins/staticmethod# |
| 1879 | def enablePackratscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#enablePackrat().(cache_size_limitscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#enablePackrat().(cache_size_limit)=128): |
| 1880 | """Enables "packrat" parsing, which adds memoizing to the parsing logic. |
| 1881 | Repeated parse attempts at the same string location (which happens |
| 1882 | often in many complex grammars) can immediately return a cached value, |
| 1883 | instead of re-executing parsing/validating code. Memoizing is done of |
| 1884 | both valid results and parsing exceptions. |
| 1885 | |
| 1886 | Parameters: |
| 1887 | |
| 1888 | - cache_size_limit - (default= ``128``) - if an integer value is provided |
| 1889 | will limit the size of the packrat cache; if None is passed, then |
| 1890 | the cache size will be unbounded; if 0 is passed, the cache will |
| 1891 | be effectively disabled. |
| 1892 | |
| 1893 | This speedup may break existing programs that use parse actions that |
| 1894 | have side-effects. For this reason, packrat parsing is disabled when |
| 1895 | you first import pyparsing. To activate the packrat feature, your |
| 1896 | program must call the class method :class:`ParserElement.enablePackrat`. |
| 1897 | For best results, call ``enablePackrat()`` immediately after |
| 1898 | importing pyparsing. |
| 1899 | |
| 1900 | Example:: |
| 1901 | |
| 1902 | import pyparsing |
| 1903 | pyparsing.ParserElement.enablePackrat() |
| 1904 | """ |
| 1905 | if not ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#._packratEnabledscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_packratEnabled.: |
| 1906 | ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#._packratEnabledscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_packratEnabled. = True |
| 1907 | if cache_size_limitscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#enablePackrat().(cache_size_limit) is None: |
| 1908 | ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.packrat_cachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#packrat_cache. = ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#._UnboundedCachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_UnboundedCache#() |
| 1909 | else: |
| 1910 | ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.packrat_cachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#packrat_cache. = ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#._FifoCachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_FifoCache#(cache_size_limitscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#enablePackrat().(cache_size_limit)) |
| 1911 | ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse. = ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#._parseCachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parseCache(). |
| 1912 | |
| 1913 | def parseStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(instring), parseAllscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(parseAll)=False): |
| 1914 | """ |
| 1915 | Execute the parse expression with the given string. |
| 1916 | This is the main interface to the client code, once the complete |
| 1917 | expression has been built. |
| 1918 | |
| 1919 | Returns the parsed data as a :class:`ParseResults` object, which may be |
| 1920 | accessed as a list, or as a dict or object with attributes if the given parser |
| 1921 | includes results names. |
| 1922 | |
| 1923 | If you want the grammar to require that the entire input string be |
| 1924 | successfully parsed, then set ``parseAll`` to True (equivalent to ending |
| 1925 | the grammar with ``StringEnd()``). |
| 1926 | |
| 1927 | Note: ``parseString`` implicitly calls ``expandtabs()`` on the input string, |
| 1928 | in order to report proper column numbers in parse actions. |
| 1929 | If the input string contains tabs and |
| 1930 | the grammar uses parse actions that use the ``loc`` argument to index into the |
| 1931 | string being parsed, you can ensure you have a consistent view of the input |
| 1932 | string by: |
| 1933 | |
| 1934 | - calling ``parseWithTabs`` on your grammar before calling ``parseString`` |
| 1935 | (see :class:`parseWithTabs`) |
| 1936 | - define your parse action using the full ``(s, loc, toks)`` signature, and |
| 1937 | reference the input string using the parse action's ``s`` argument |
| 1938 | - explicitly expand the tabs in your input string before calling |
| 1939 | ``parseString`` |
| 1940 | |
| 1941 | Example:: |
| 1942 | |
| 1943 | Word('a').parseString('aaaaabaaa') # -> ['aaaaa'] |
| 1944 | Word('a').parseString('aaaaabaaa', parseAll=True) # -> Exception: Expected end of text |
| 1945 | """ |
| 1946 | ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.resetCachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#resetCache().() |
| 1947 | if not selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(self).streamlinedscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#streamlined.: |
| 1948 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(self).streamlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#streamline().() |
| 1949 | # ~ self.saveAsList = True |
| 1950 | for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(self).ignoreExprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignoreExprs.: |
| 1951 | e.streamline() |
| 1952 | if not selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(self).keepTabsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#keepTabs.: |
| 1953 | instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(instring) = instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(instring).expandtabs() |
| 1954 | try: |
| 1955 | loc, tokens = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(self)._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse.(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(instring), 0) |
| 1956 | if parseAllscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(parseAll): |
| 1957 | loc = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(self).preParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(instring), loc) |
| 1958 | se = Emptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#() + StringEndscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#() |
| 1959 | se._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse.(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(instring), loc) |
| 1960 | except ParseBaseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException# as exc: |
| 1961 | if ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.verbose_stacktracescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#verbose_stacktrace.: |
| 1962 | raise |
| 1963 | else: |
| 1964 | # catch and re-raise exception from here, clearing out pyparsing internal stack trace |
| 1965 | if getattrscip-python python python-stdlib 3.11 builtins/getattr().(exc, '__traceback__', None) is not None: |
| 1966 | exc.__traceback__scip-python python python-stdlib 3.11 builtins/BaseException#__traceback__. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(self)._trim_tracebackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_trim_traceback().(exc.__traceback__scip-python python python-stdlib 3.11 builtins/BaseException#__traceback__.) |
| 1967 | raise exc |
| 1968 | else: |
| 1969 | return tokens |
| 1970 | |
| 1971 | def scanStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(instring), maxMatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(maxMatches)=_MAX_INTscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MAX_INT., overlapscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(overlap)=False): |
| 1972 | """ |
| 1973 | Scan the input string for expression matches. Each match will return the |
| 1974 | matching tokens, start location, and end location. May be called with optional |
| 1975 | ``maxMatches`` argument, to clip scanning after 'n' matches are found. If |
| 1976 | ``overlap`` is specified, then overlapping matches will be reported. |
| 1977 | |
| 1978 | Note that the start and end locations are reported relative to the string |
| 1979 | being parsed. See :class:`parseString` for more information on parsing |
| 1980 | strings with embedded tabs. |
| 1981 | |
| 1982 | Example:: |
| 1983 | |
| 1984 | source = "sldjf123lsdjjkf345sldkjf879lkjsfd987" |
| 1985 | print(source) |
| 1986 | for tokens, start, end in Word(alphas).scanString(source): |
| 1987 | print(' '*start + '^'*(end-start)) |
| 1988 | print(' '*start + tokens[0]) |
| 1989 | |
| 1990 | prints:: |
| 1991 | |
| 1992 | sldjf123lsdjjkf345sldkjf879lkjsfd987 |
| 1993 | ^^^^^ |
| 1994 | sldjf |
| 1995 | ^^^^^^^ |
| 1996 | lsdjjkf |
| 1997 | ^^^^^^ |
| 1998 | sldkjf |
| 1999 | ^^^^^^ |
| 2000 | lkjsfd |
| 2001 | """ |
| 2002 | if not selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(self).streamlinedscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#streamlined.: |
| 2003 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(self).streamlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#streamline().() |
| 2004 | for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(self).ignoreExprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignoreExprs.: |
| 2005 | e.streamline() |
| 2006 | |
| 2007 | if not selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(self).keepTabsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#keepTabs.: |
| 2008 | instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(instring) = _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(instring)).expandtabs() |
| 2009 | instrlen = len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(instring)) |
| 2010 | loc = 0 |
| 2011 | preparseFn = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(self).preParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse(). |
| 2012 | parseFn = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(self)._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse. |
| 2013 | ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.resetCachescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#resetCache().() |
| 2014 | matches = 0 |
| 2015 | try: |
| 2016 | while loc <= instrlen and matches < maxMatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(maxMatches): |
| 2017 | try: |
| 2018 | preloc = preparseFn(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(instring), loc) |
| 2019 | nextLoc, tokens = parseFn(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(instring), preloc, callPreParse=False) |
| 2020 | except ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#: |
| 2021 | loc = preloc + 1 |
| 2022 | else: |
| 2023 | if nextLoc > loc: |
| 2024 | matches += 1 |
| 2025 | yield tokens, preloc, nextLoc |
| 2026 | if overlapscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(overlap): |
| 2027 | nextloc = preparseFn(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(instring), loc) |
| 2028 | if nextloc > loc: |
| 2029 | loc = nextLoc |
| 2030 | else: |
| 2031 | loc += 1 |
| 2032 | else: |
| 2033 | loc = nextLoc |
| 2034 | else: |
| 2035 | loc = preloc + 1 |
| 2036 | except ParseBaseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException# as exc: |
| 2037 | if ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.verbose_stacktracescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#verbose_stacktrace.: |
| 2038 | raise |
| 2039 | else: |
| 2040 | # catch and re-raise exception from here, clearing out pyparsing internal stack trace |
| 2041 | if getattrscip-python python python-stdlib 3.11 builtins/getattr().(exc, '__traceback__', None) is not None: |
| 2042 | exc.__traceback__scip-python python python-stdlib 3.11 builtins/BaseException#__traceback__. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(self)._trim_tracebackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_trim_traceback().(exc.__traceback__scip-python python python-stdlib 3.11 builtins/BaseException#__traceback__.) |
| 2043 | raise exc |
| 2044 | |
| 2045 | def transformStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#transformString().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#transformString().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#transformString().(instring)): |
| 2046 | """ |
| 2047 | Extension to :class:`scanString`, to modify matching text with modified tokens that may |
| 2048 | be returned from a parse action. To use ``transformString``, define a grammar and |
| 2049 | attach a parse action to it that modifies the returned token list. |
| 2050 | Invoking ``transformString()`` on a target string will then scan for matches, |
| 2051 | and replace the matched text patterns according to the logic in the parse |
| 2052 | action. ``transformString()`` returns the resulting transformed string. |
| 2053 | |
| 2054 | Example:: |
| 2055 | |
| 2056 | wd = Word(alphas) |
| 2057 | wd.setParseAction(lambda toks: toks[0].title()) |
| 2058 | |
| 2059 | print(wd.transformString("now is the winter of our discontent made glorious summer by this sun of york.")) |
| 2060 | |
| 2061 | prints:: |
| 2062 | |
| 2063 | Now Is The Winter Of Our Discontent Made Glorious Summer By This Sun Of York. |
| 2064 | """ |
| 2065 | out = [] |
| 2066 | lastE = 0 |
| 2067 | # force preservation of <TAB>s, to minimize unwanted transformation of string, and to |
| 2068 | # keep string locs straight between transformString and scanString |
| 2069 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#transformString().(self).keepTabsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#keepTabs. = True |
| 2070 | try: |
| 2071 | for t, s, e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#transformString().(self).scanStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#transformString().(instring)): |
| 2072 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#transformString().(instring)[lastE:s]) |
| 2073 | if t: |
| 2074 | if isinstance(t, ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#): |
| 2075 | out += t.asListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#asList().() |
| 2076 | elif isinstance(t, listscip-python python python-stdlib 3.11 builtins/list#): |
| 2077 | out += t |
| 2078 | else: |
| 2079 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().(t) |
| 2080 | lastE = e |
| 2081 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#transformString().(instring)[lastE:]) |
| 2082 | out = [o for o in out if o] |
| 2083 | return "".joinscip-python python python-stdlib 3.11 builtins/str#join().(mapscip-python python python-stdlib 3.11 builtins/map#(_ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr., _flattenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_flatten().(out))) |
| 2084 | except ParseBaseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException# as exc: |
| 2085 | if ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.verbose_stacktracescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#verbose_stacktrace.: |
| 2086 | raise |
| 2087 | else: |
| 2088 | # catch and re-raise exception from here, clearing out pyparsing internal stack trace |
| 2089 | if getattrscip-python python python-stdlib 3.11 builtins/getattr().(exc, '__traceback__', None) is not None: |
| 2090 | exc.__traceback__scip-python python python-stdlib 3.11 builtins/BaseException#__traceback__. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#transformString().(self)._trim_tracebackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_trim_traceback().(exc.__traceback__scip-python python python-stdlib 3.11 builtins/BaseException#__traceback__.) |
| 2091 | raise exc |
| 2092 | |
| 2093 | def searchStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#searchString().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#searchString().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#searchString().(instring), maxMatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#searchString().(maxMatches)=_MAX_INTscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MAX_INT.): |
| 2094 | """ |
| 2095 | Another extension to :class:`scanString`, simplifying the access to the tokens found |
| 2096 | to match the given parse expression. May be called with optional |
| 2097 | ``maxMatches`` argument, to clip searching after 'n' matches are found. |
| 2098 | |
| 2099 | Example:: |
| 2100 | |
| 2101 | # a capitalized word starts with an uppercase letter, followed by zero or more lowercase letters |
| 2102 | cap_word = Word(alphas.upper(), alphas.lower()) |
| 2103 | |
| 2104 | print(cap_word.searchString("More than Iron, more than Lead, more than Gold I need Electricity")) |
| 2105 | |
| 2106 | # the sum() builtin can be used to merge results into a single ParseResults object |
| 2107 | print(sum(cap_word.searchString("More than Iron, more than Lead, more than Gold I need Electricity"))) |
| 2108 | |
| 2109 | prints:: |
| 2110 | |
| 2111 | [['More'], ['Iron'], ['Lead'], ['Gold'], ['I'], ['Electricity']] |
| 2112 | ['More', 'Iron', 'Lead', 'Gold', 'I', 'Electricity'] |
| 2113 | """ |
| 2114 | try: |
| 2115 | return ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#([t for t, s, e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#searchString().(self).scanStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#searchString().(instring), maxMatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#searchString().(maxMatches))]) |
| 2116 | except ParseBaseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException# as exc: |
| 2117 | if ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.verbose_stacktracescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#verbose_stacktrace.: |
| 2118 | raise |
| 2119 | else: |
| 2120 | # catch and re-raise exception from here, clearing out pyparsing internal stack trace |
| 2121 | if getattrscip-python python python-stdlib 3.11 builtins/getattr().(exc, '__traceback__', None) is not None: |
| 2122 | exc.__traceback__scip-python python python-stdlib 3.11 builtins/BaseException#__traceback__. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#searchString().(self)._trim_tracebackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_trim_traceback().(exc.__traceback__scip-python python python-stdlib 3.11 builtins/BaseException#__traceback__.) |
| 2123 | raise exc |
| 2124 | |
| 2125 | def splitscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#split().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#split().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#split().(instring), maxsplitscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#split().(maxsplit)=_MAX_INTscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MAX_INT., includeSeparatorsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#split().(includeSeparators)=False): |
| 2126 | """ |
| 2127 | Generator method to split a string using the given expression as a separator. |
| 2128 | May be called with optional ``maxsplit`` argument, to limit the number of splits; |
| 2129 | and the optional ``includeSeparators`` argument (default= ``False``), if the separating |
| 2130 | matching text should be included in the split results. |
| 2131 | |
| 2132 | Example:: |
| 2133 | |
| 2134 | punc = oneOf(list(".,;:/-!?")) |
| 2135 | print(list(punc.split("This, this?, this sentence, is badly punctuated!"))) |
| 2136 | |
| 2137 | prints:: |
| 2138 | |
| 2139 | ['This', ' this', '', ' this sentence', ' is badly punctuated', ''] |
| 2140 | """ |
| 2141 | splits = 0 |
| 2142 | last = 0 |
| 2143 | for t, s, e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#split().(self).scanStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#split().(instring), maxMatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#scanString().(maxMatches)=maxsplitscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#split().(maxsplit)): |
| 2144 | yield instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#split().(instring)[last:s] |
| 2145 | if includeSeparatorsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#split().(includeSeparators): |
| 2146 | yield t[0] |
| 2147 | last = e |
| 2148 | yield instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#split().(instring)[last:] |
| 2149 | |
| 2150 | def __add__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__add__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__add__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__add__().(other)): |
| 2151 | """ |
| 2152 | Implementation of + operator - returns :class:`And`. Adding strings to a ParserElement |
| 2153 | converts them to :class:`Literal`s by default. |
| 2154 | |
| 2155 | Example:: |
| 2156 | |
| 2157 | greet = Word(alphas) + "," + Word(alphas) + "!" |
| 2158 | hello = "Hello, World!" |
| 2159 | print (hello, "->", greet.parseString(hello)) |
| 2160 | |
| 2161 | prints:: |
| 2162 | |
| 2163 | Hello, World! -> ['Hello', ',', 'World', '!'] |
| 2164 | |
| 2165 | ``...`` may be used as a parse expression as a short form of :class:`SkipTo`. |
| 2166 | |
| 2167 | Literal('start') + ... + Literal('end') |
| 2168 | |
| 2169 | is equivalent to: |
| 2170 | |
| 2171 | Literal('start') + SkipTo('end')("_skipped*") + Literal('end') |
| 2172 | |
| 2173 | Note that the skipped text is returned with '_skipped' as a results name, |
| 2174 | and to support having multiple skips in the same parser, the value returned is |
| 2175 | a list of all skipped text. |
| 2176 | """ |
| 2177 | if otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__add__().(other) is Ellipsisscip-python python python-stdlib 3.11 builtins/Ellipsis#: |
| 2178 | return _PendingSkipscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__add__().(self)) |
| 2179 | |
| 2180 | if isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__add__().(other), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 2181 | otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__add__().(other) = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__add__().(self)._literalStringClass(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__add__().(other)) |
| 2182 | if not isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__add__().(other), ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#): |
| 2183 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("Cannot combine element of type %s with ParserElement" % typescip-python python python-stdlib 3.11 builtins/type#(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__add__().(other)), |
| 2184 | SyntaxWarningscip-python python python-stdlib 3.11 builtins/SyntaxWarning#, stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 2185 | return None |
| 2186 | return Andscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#([selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__add__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__add__().(other)]) |
| 2187 | |
| 2188 | def __radd__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__radd__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__radd__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__radd__().(other)): |
| 2189 | """ |
| 2190 | Implementation of + operator when left operand is not a :class:`ParserElement` |
| 2191 | """ |
| 2192 | if otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__radd__().(other) is Ellipsisscip-python python python-stdlib 3.11 builtins/Ellipsis#: |
| 2193 | return SkipToscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__radd__().(self))("_skipped*") + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__radd__().(self) |
| 2194 | |
| 2195 | if isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__radd__().(other), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 2196 | otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__radd__().(other) = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__radd__().(self)._literalStringClass(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__radd__().(other)) |
| 2197 | if not isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__radd__().(other), ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#): |
| 2198 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("Cannot combine element of type %s with ParserElement" % typescip-python python python-stdlib 3.11 builtins/type#(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__radd__().(other)), |
| 2199 | SyntaxWarningscip-python python python-stdlib 3.11 builtins/SyntaxWarning#, stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 2200 | return None |
| 2201 | return otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__radd__().(other) + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__radd__().(self) |
| 2202 | |
| 2203 | def __sub__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__sub__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__sub__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__sub__().(other)): |
| 2204 | """ |
| 2205 | Implementation of - operator, returns :class:`And` with error stop |
| 2206 | """ |
| 2207 | if isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__sub__().(other), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 2208 | otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__sub__().(other) = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__sub__().(self)._literalStringClass(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__sub__().(other)) |
| 2209 | if not isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__sub__().(other), ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#): |
| 2210 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("Cannot combine element of type %s with ParserElement" % typescip-python python python-stdlib 3.11 builtins/type#(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__sub__().(other)), |
| 2211 | SyntaxWarningscip-python python python-stdlib 3.11 builtins/SyntaxWarning#, stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 2212 | return None |
| 2213 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__sub__().(self) + Andscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#._ErrorStopscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#_ErrorStop#() + otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__sub__().(other) |
| 2214 | |
| 2215 | def __rsub__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rsub__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rsub__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rsub__().(other)): |
| 2216 | """ |
| 2217 | Implementation of - operator when left operand is not a :class:`ParserElement` |
| 2218 | """ |
| 2219 | if isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rsub__().(other), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 2220 | otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rsub__().(other) = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rsub__().(self)._literalStringClass(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rsub__().(other)) |
| 2221 | if not isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rsub__().(other), ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#): |
| 2222 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("Cannot combine element of type %s with ParserElement" % typescip-python python python-stdlib 3.11 builtins/type#(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rsub__().(other)), |
| 2223 | SyntaxWarningscip-python python python-stdlib 3.11 builtins/SyntaxWarning#, stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 2224 | return None |
| 2225 | return otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rsub__().(other) - selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rsub__().(self) |
| 2226 | |
| 2227 | def __mul__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other)): |
| 2228 | """ |
| 2229 | Implementation of * operator, allows use of ``expr * 3`` in place of |
| 2230 | ``expr + expr + expr``. Expressions may also me multiplied by a 2-integer |
| 2231 | tuple, similar to ``{min, max}`` multipliers in regular expressions. Tuples |
| 2232 | may also include ``None`` as in: |
| 2233 | - ``expr*(n, None)`` or ``expr*(n, )`` is equivalent |
| 2234 | to ``expr*n + ZeroOrMore(expr)`` |
| 2235 | (read as "at least n instances of ``expr``") |
| 2236 | - ``expr*(None, n)`` is equivalent to ``expr*(0, n)`` |
| 2237 | (read as "0 to n instances of ``expr``") |
| 2238 | - ``expr*(None, None)`` is equivalent to ``ZeroOrMore(expr)`` |
| 2239 | - ``expr*(1, None)`` is equivalent to ``OneOrMore(expr)`` |
| 2240 | |
| 2241 | Note that ``expr*(None, n)`` does not raise an exception if |
| 2242 | more than n exprs exist in the input stream; that is, |
| 2243 | ``expr*(None, n)`` does not enforce a maximum number of expr |
| 2244 | occurrences. If this behavior is desired, then write |
| 2245 | ``expr*(None, n) + ~expr`` |
| 2246 | """ |
| 2247 | if otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other) is Ellipsisscip-python python python-stdlib 3.11 builtins/Ellipsis#: |
| 2248 | otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other) = (0, None) |
| 2249 | elif isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other), tuplescip-python python python-stdlib 3.11 builtins/tuple#) and otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other)[:1] == (Ellipsisscip-python python python-stdlib 3.11 builtins/Ellipsis#,): |
| 2250 | otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other) = ((0, ) + otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other)[1:] + (None,))[:2] |
| 2251 | |
| 2252 | if isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other), intscip-python python python-stdlib 3.11 builtins/int#): |
| 2253 | minElements, optElements = otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other), 0 |
| 2254 | elif isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other), tuplescip-python python python-stdlib 3.11 builtins/tuple#): |
| 2255 | otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other) = tuplescip-python python python-stdlib 3.11 builtins/tuple#(o if o is not Ellipsisscip-python python python-stdlib 3.11 builtins/Ellipsis# else None for o in otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other)) |
| 2256 | otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other) = (otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other) + (None, None))[:2] |
| 2257 | if otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other)[0] is None: |
| 2258 | otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other) = (0, otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other)[1]) |
| 2259 | if isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other)[0], intscip-python python python-stdlib 3.11 builtins/int#) and otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other)[1] is None: |
| 2260 | if otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other)[0] == 0: |
| 2261 | return ZeroOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(self)) |
| 2262 | if otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other)[0] == 1: |
| 2263 | return OneOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(self)) |
| 2264 | else: |
| 2265 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(self) * otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other)[0] + ZeroOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(self)) |
| 2266 | elif isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other)[0], intscip-python python python-stdlib 3.11 builtins/int#) and isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other)[1], intscip-python python python-stdlib 3.11 builtins/int#): |
| 2267 | minElements, optElements = otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other) |
| 2268 | optElements -= minElements |
| 2269 | else: |
| 2270 | raise TypeErrorscip-python python python-stdlib 3.11 builtins/TypeError#("cannot multiply 'ParserElement' and ('%s', '%s') objects", typescip-python python python-stdlib 3.11 builtins/type#(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other)[0]), typescip-python python python-stdlib 3.11 builtins/type#(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other)[1])) |
| 2271 | else: |
| 2272 | raise TypeErrorscip-python python python-stdlib 3.11 builtins/TypeError#("cannot multiply 'ParserElement' and '%s' objects", typescip-python python python-stdlib 3.11 builtins/type#(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(other))) |
| 2273 | |
| 2274 | if minElements < 0: |
| 2275 | raise ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#("cannot multiply ParserElement by negative value") |
| 2276 | if optElements < 0: |
| 2277 | raise ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#("second tuple value must be greater or equal to first tuple value") |
| 2278 | if minElements == optElements == 0: |
| 2279 | raise ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#("cannot multiply ParserElement by 0 or (0, 0)") |
| 2280 | |
| 2281 | if optElements: |
| 2282 | def makeOptionalListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#makeOptionalList().(nscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#makeOptionalList().(n)): |
| 2283 | if nscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#makeOptionalList().(n) > 1: |
| 2284 | return Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(self) + makeOptionalListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#makeOptionalList().(nscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#makeOptionalList().(n) - 1)) |
| 2285 | else: |
| 2286 | return Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(self)) |
| 2287 | if minElements: |
| 2288 | if minElements == 1: |
| 2289 | ret = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(self) + makeOptionalListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#makeOptionalList().(optElements) |
| 2290 | else: |
| 2291 | ret = Andscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#([selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(self)] * minElements) + makeOptionalListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#makeOptionalList().(optElements) |
| 2292 | else: |
| 2293 | ret = makeOptionalListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#makeOptionalList().(optElements) |
| 2294 | else: |
| 2295 | if minElements == 1: |
| 2296 | ret = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(self) |
| 2297 | else: |
| 2298 | ret = Andscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#([selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(self)] * minElements) |
| 2299 | return ret |
| 2300 | |
| 2301 | def __rmul__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rmul__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rmul__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rmul__().(other)): |
| 2302 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rmul__().(self).__mul__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__mul__().(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rmul__().(other)) |
| 2303 | |
| 2304 | def __or__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__or__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__or__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__or__().(other)): |
| 2305 | """ |
| 2306 | Implementation of | operator - returns :class:`MatchFirst` |
| 2307 | """ |
| 2308 | if otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__or__().(other) is Ellipsisscip-python python python-stdlib 3.11 builtins/Ellipsis#: |
| 2309 | return _PendingSkipscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__or__().(self), must_skipscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__init__().(must_skip)=True) |
| 2310 | |
| 2311 | if isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__or__().(other), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 2312 | otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__or__().(other) = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__or__().(self)._literalStringClass(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__or__().(other)) |
| 2313 | if not isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__or__().(other), ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#): |
| 2314 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("Cannot combine element of type %s with ParserElement" % typescip-python python python-stdlib 3.11 builtins/type#(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__or__().(other)), |
| 2315 | SyntaxWarningscip-python python python-stdlib 3.11 builtins/SyntaxWarning#, stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 2316 | return None |
| 2317 | return MatchFirstscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#([selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__or__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__or__().(other)]) |
| 2318 | |
| 2319 | def __ror__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__ror__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__ror__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__ror__().(other)): |
| 2320 | """ |
| 2321 | Implementation of | operator when left operand is not a :class:`ParserElement` |
| 2322 | """ |
| 2323 | if isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__ror__().(other), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 2324 | otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__ror__().(other) = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__ror__().(self)._literalStringClass(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__ror__().(other)) |
| 2325 | if not isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__ror__().(other), ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#): |
| 2326 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("Cannot combine element of type %s with ParserElement" % typescip-python python python-stdlib 3.11 builtins/type#(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__ror__().(other)), |
| 2327 | SyntaxWarningscip-python python python-stdlib 3.11 builtins/SyntaxWarning#, stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 2328 | return None |
| 2329 | return otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__ror__().(other) | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__ror__().(self) |
| 2330 | |
| 2331 | def __xor__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__xor__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__xor__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__xor__().(other)): |
| 2332 | """ |
| 2333 | Implementation of ^ operator - returns :class:`Or` |
| 2334 | """ |
| 2335 | if isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__xor__().(other), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 2336 | otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__xor__().(other) = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__xor__().(self)._literalStringClass(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__xor__().(other)) |
| 2337 | if not isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__xor__().(other), ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#): |
| 2338 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("Cannot combine element of type %s with ParserElement" % typescip-python python python-stdlib 3.11 builtins/type#(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__xor__().(other)), |
| 2339 | SyntaxWarningscip-python python python-stdlib 3.11 builtins/SyntaxWarning#, stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 2340 | return None |
| 2341 | return Orscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#([selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__xor__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__xor__().(other)]) |
| 2342 | |
| 2343 | def __rxor__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rxor__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rxor__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rxor__().(other)): |
| 2344 | """ |
| 2345 | Implementation of ^ operator when left operand is not a :class:`ParserElement` |
| 2346 | """ |
| 2347 | if isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rxor__().(other), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 2348 | otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rxor__().(other) = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rxor__().(self)._literalStringClass(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rxor__().(other)) |
| 2349 | if not isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rxor__().(other), ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#): |
| 2350 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("Cannot combine element of type %s with ParserElement" % typescip-python python python-stdlib 3.11 builtins/type#(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rxor__().(other)), |
| 2351 | SyntaxWarningscip-python python python-stdlib 3.11 builtins/SyntaxWarning#, stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 2352 | return None |
| 2353 | return otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rxor__().(other) ^ selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rxor__().(self) |
| 2354 | |
| 2355 | def __and__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__and__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__and__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__and__().(other)): |
| 2356 | """ |
| 2357 | Implementation of & operator - returns :class:`Each` |
| 2358 | """ |
| 2359 | if isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__and__().(other), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 2360 | otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__and__().(other) = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__and__().(self)._literalStringClass(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__and__().(other)) |
| 2361 | if not isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__and__().(other), ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#): |
| 2362 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("Cannot combine element of type %s with ParserElement" % typescip-python python python-stdlib 3.11 builtins/type#(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__and__().(other)), |
| 2363 | SyntaxWarningscip-python python python-stdlib 3.11 builtins/SyntaxWarning#, stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 2364 | return None |
| 2365 | return Eachscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#([selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__and__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__and__().(other)]) |
| 2366 | |
| 2367 | def __rand__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rand__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rand__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rand__().(other)): |
| 2368 | """ |
| 2369 | Implementation of & operator when left operand is not a :class:`ParserElement` |
| 2370 | """ |
| 2371 | if isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rand__().(other), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 2372 | otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rand__().(other) = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rand__().(self)._literalStringClass(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rand__().(other)) |
| 2373 | if not isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rand__().(other), ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#): |
| 2374 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("Cannot combine element of type %s with ParserElement" % typescip-python python python-stdlib 3.11 builtins/type#(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rand__().(other)), |
| 2375 | SyntaxWarningscip-python python python-stdlib 3.11 builtins/SyntaxWarning#, stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 2376 | return None |
| 2377 | return otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rand__().(other) & selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rand__().(self) |
| 2378 | |
| 2379 | def __invert__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__invert__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__invert__().(self)): |
| 2380 | """ |
| 2381 | Implementation of ~ operator - returns :class:`NotAny` |
| 2382 | """ |
| 2383 | return NotAnyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__invert__().(self)) |
| 2384 | |
| 2385 | def __iter__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__iter__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__iter__().(self)): |
| 2386 | # must implement __iter__ to override legacy use of sequential access to __getitem__ to |
| 2387 | # iterate over a sequence |
| 2388 | raise TypeErrorscip-python python python-stdlib 3.11 builtins/TypeError#('%r object is not iterable' % selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__iter__().(self).__class__scip-python python python-stdlib 3.11 builtins/object#__class__()..__name__scip-python python python-stdlib 3.11 builtins/__name__#) |
| 2389 | |
| 2390 | def __getitem__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__getitem__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__getitem__().(self), keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__getitem__().(key)): |
| 2391 | """ |
| 2392 | use ``[]`` indexing notation as a short form for expression repetition: |
| 2393 | - ``expr[n]`` is equivalent to ``expr*n`` |
| 2394 | - ``expr[m, n]`` is equivalent to ``expr*(m, n)`` |
| 2395 | - ``expr[n, ...]`` or ``expr[n,]`` is equivalent |
| 2396 | to ``expr*n + ZeroOrMore(expr)`` |
| 2397 | (read as "at least n instances of ``expr``") |
| 2398 | - ``expr[..., n]`` is equivalent to ``expr*(0, n)`` |
| 2399 | (read as "0 to n instances of ``expr``") |
| 2400 | - ``expr[...]`` and ``expr[0, ...]`` are equivalent to ``ZeroOrMore(expr)`` |
| 2401 | - ``expr[1, ...]`` is equivalent to ``OneOrMore(expr)`` |
| 2402 | ``None`` may be used in place of ``...``. |
| 2403 | |
| 2404 | Note that ``expr[..., n]`` and ``expr[m, n]``do not raise an exception |
| 2405 | if more than ``n`` ``expr``s exist in the input stream. If this behavior is |
| 2406 | desired, then write ``expr[..., n] + ~expr``. |
| 2407 | """ |
| 2408 | |
| 2409 | # convert single arg keys to tuples |
| 2410 | try: |
| 2411 | if isinstance(keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__getitem__().(key), strscip-python python python-stdlib 3.11 builtins/str#): |
| 2412 | keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__getitem__().(key) = (keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__getitem__().(key),) |
| 2413 | iterscip-python python python-stdlib 3.11 builtins/iter().(keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__getitem__().(key)) |
| 2414 | except TypeErrorscip-python python python-stdlib 3.11 builtins/TypeError#: |
| 2415 | keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__getitem__().(key) = (keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__getitem__().(key), keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__getitem__().(key)) |
| 2416 | |
| 2417 | if len(keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__getitem__().(key)) > 2: |
| 2418 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("only 1 or 2 index arguments supported ({0}{1})".format(keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__getitem__().(key)[:5], |
| 2419 | '... [{0}]'.format(len(keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__getitem__().(key))) |
| 2420 | if len(keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__getitem__().(key)) > 5 else '')) |
| 2421 | |
| 2422 | # clip to 2 elements |
| 2423 | ret = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__getitem__().(self) * tuplescip-python python python-stdlib 3.11 builtins/tuple#(keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__getitem__().(key)[:2]) |
| 2424 | return ret |
| 2425 | |
| 2426 | def __call__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__call__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__call__().(self), namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__call__().(name)=None): |
| 2427 | """ |
| 2428 | Shortcut for :class:`setResultsName`, with ``listAllMatches=False``. |
| 2429 | |
| 2430 | If ``name`` is given with a trailing ``'*'`` character, then ``listAllMatches`` will be |
| 2431 | passed as ``True``. |
| 2432 | |
| 2433 | If ``name` is omitted, same as calling :class:`copy`. |
| 2434 | |
| 2435 | Example:: |
| 2436 | |
| 2437 | # these are equivalent |
| 2438 | userdata = Word(alphas).setResultsName("name") + Word(nums + "-").setResultsName("socsecno") |
| 2439 | userdata = Word(alphas)("name") + Word(nums + "-")("socsecno") |
| 2440 | """ |
| 2441 | if namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__call__().(name) is not None: |
| 2442 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__call__().(self)._setResultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_setResultsName().(namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__call__().(name)) |
| 2443 | else: |
| 2444 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__call__().(self).copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().() |
| 2445 | |
| 2446 | def suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#suppress().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#suppress().(self)): |
| 2447 | """ |
| 2448 | Suppresses the output of this :class:`ParserElement`; useful to keep punctuation from |
| 2449 | cluttering up returned output. |
| 2450 | """ |
| 2451 | return Suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#suppress().(self)) |
| 2452 | |
| 2453 | def leaveWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#leaveWhitespace().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#leaveWhitespace().(self)): |
| 2454 | """ |
| 2455 | Disables the skipping of whitespace before matching the characters in the |
| 2456 | :class:`ParserElement`'s defined pattern. This is normally only used internally by |
| 2457 | the pyparsing module, but may be needed in some whitespace-sensitive grammars. |
| 2458 | """ |
| 2459 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#leaveWhitespace().(self).skipWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#skipWhitespace. = False |
| 2460 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#leaveWhitespace().(self) |
| 2461 | |
| 2462 | def setWhitespaceCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setWhitespaceChars().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setWhitespaceChars().(self), charsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setWhitespaceChars().(chars)): |
| 2463 | """ |
| 2464 | Overrides the default whitespace chars |
| 2465 | """ |
| 2466 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setWhitespaceChars().(self).skipWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#skipWhitespace. = True |
| 2467 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setWhitespaceChars().(self).whiteCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#whiteChars. = charsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setWhitespaceChars().(chars) |
| 2468 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setWhitespaceChars().(self).copyDefaultWhiteCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copyDefaultWhiteChars. = False |
| 2469 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setWhitespaceChars().(self) |
| 2470 | |
| 2471 | def parseWithTabsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseWithTabs().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseWithTabs().(self)): |
| 2472 | """ |
| 2473 | Overrides default behavior to expand ``<TAB>``s to spaces before parsing the input string. |
| 2474 | Must be called before ``parseString`` when the input grammar contains elements that |
| 2475 | match ``<TAB>`` characters. |
| 2476 | """ |
| 2477 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseWithTabs().(self).keepTabsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#keepTabs. = True |
| 2478 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseWithTabs().(self) |
| 2479 | |
| 2480 | def ignorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(other)): |
| 2481 | """ |
| 2482 | Define expression to be ignored (e.g., comments) while doing pattern |
| 2483 | matching; may be called repeatedly, to define multiple comment or other |
| 2484 | ignorable patterns. |
| 2485 | |
| 2486 | Example:: |
| 2487 | |
| 2488 | patt = OneOrMore(Word(alphas)) |
| 2489 | patt.parseString('ablaj /* comment */ lskjd') # -> ['ablaj'] |
| 2490 | |
| 2491 | patt.ignore(cStyleComment) |
| 2492 | patt.parseString('ablaj /* comment */ lskjd') # -> ['ablaj', 'lskjd'] |
| 2493 | """ |
| 2494 | if isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(other), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 2495 | otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(other) = Suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(other)) |
| 2496 | |
| 2497 | if isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(other), Suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#): |
| 2498 | if otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(other) not in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(self).ignoreExprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignoreExprs.: |
| 2499 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(self).ignoreExprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignoreExprs..appendscip-python python python-stdlib 3.11 builtins/list#append().(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(other)) |
| 2500 | else: |
| 2501 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(self).ignoreExprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignoreExprs..appendscip-python python python-stdlib 3.11 builtins/list#append().(Suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(other).copy())) |
| 2502 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(self) |
| 2503 | |
| 2504 | def setDebugActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDebugActions().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDebugActions().(self), startActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDebugActions().(startAction), successActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDebugActions().(successAction), exceptionActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDebugActions().(exceptionAction)): |
| 2505 | """ |
| 2506 | Enable display of debugging messages while doing pattern matching. |
| 2507 | """ |
| 2508 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDebugActions().(self).debugActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#debugActions. = (startActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDebugActions().(startAction) or _defaultStartDebugActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultStartDebugAction()., |
| 2509 | successActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDebugActions().(successAction) or _defaultSuccessDebugActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultSuccessDebugAction()., |
| 2510 | exceptionActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDebugActions().(exceptionAction) or _defaultExceptionDebugActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultExceptionDebugAction().) |
| 2511 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDebugActions().(self).debugscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#debug. = True |
| 2512 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDebugActions().(self) |
| 2513 | |
| 2514 | def setDebugscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDebug().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDebug().(self), flagscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDebug().(flag)=True): |
| 2515 | """ |
| 2516 | Enable display of debugging messages while doing pattern matching. |
| 2517 | Set ``flag`` to True to enable, False to disable. |
| 2518 | |
| 2519 | Example:: |
| 2520 | |
| 2521 | wd = Word(alphas).setName("alphaword") |
| 2522 | integer = Word(nums).setName("numword") |
| 2523 | term = wd | integer |
| 2524 | |
| 2525 | # turn on debugging for wd |
| 2526 | wd.setDebug() |
| 2527 | |
| 2528 | OneOrMore(term).parseString("abc 123 xyz 890") |
| 2529 | |
| 2530 | prints:: |
| 2531 | |
| 2532 | Match alphaword at loc 0(1,1) |
| 2533 | Matched alphaword -> ['abc'] |
| 2534 | Match alphaword at loc 3(1,4) |
| 2535 | Exception raised:Expected alphaword (at char 4), (line:1, col:5) |
| 2536 | Match alphaword at loc 7(1,8) |
| 2537 | Matched alphaword -> ['xyz'] |
| 2538 | Match alphaword at loc 11(1,12) |
| 2539 | Exception raised:Expected alphaword (at char 12), (line:1, col:13) |
| 2540 | Match alphaword at loc 15(1,16) |
| 2541 | Exception raised:Expected alphaword (at char 15), (line:1, col:16) |
| 2542 | |
| 2543 | The output shown is that produced by the default debug actions - custom debug actions can be |
| 2544 | specified using :class:`setDebugActions`. Prior to attempting |
| 2545 | to match the ``wd`` expression, the debugging message ``"Match <exprname> at loc <n>(<line>,<col>)"`` |
| 2546 | is shown. Then if the parse succeeds, a ``"Matched"`` message is shown, or an ``"Exception raised"`` |
| 2547 | message is shown. Also note the use of :class:`setName` to assign a human-readable name to the expression, |
| 2548 | which makes debugging and exception messages easier to understand - for instance, the default |
| 2549 | name created for the :class:`Word` expression without calling ``setName`` is ``"W:(ABCD...)"``. |
| 2550 | """ |
| 2551 | if flagscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDebug().(flag): |
| 2552 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDebug().(self).setDebugActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDebugActions().(_defaultStartDebugActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultStartDebugAction()., _defaultSuccessDebugActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultSuccessDebugAction()., _defaultExceptionDebugActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_defaultExceptionDebugAction().) |
| 2553 | else: |
| 2554 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDebug().(self).debugscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#debug. = False |
| 2555 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDebug().(self) |
| 2556 | |
| 2557 | def __str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__str__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__str__().(self)): |
| 2558 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__str__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#name. |
| 2559 | |
| 2560 | def __repr__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__repr__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__repr__().(self)): |
| 2561 | return _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__repr__().(self)) |
| 2562 | |
| 2563 | def streamlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#streamline().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#streamline().(self)): |
| 2564 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#streamline().(self).streamlinedscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#streamlined. = True |
| 2565 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#streamline().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#strRepr. = None |
| 2566 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#streamline().(self) |
| 2567 | |
| 2568 | def checkRecursionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#checkRecursion().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#checkRecursion().(self), parseElementListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#checkRecursion().(parseElementList)): |
| 2569 | pass |
| 2570 | |
| 2571 | def validatescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#validate().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#validate().(self), validateTracescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#validate().(validateTrace)=None): |
| 2572 | """ |
| 2573 | Check defined expressions for valid structure, check for infinite recursive definitions. |
| 2574 | """ |
| 2575 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#validate().(self).checkRecursionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#checkRecursion().([]) |
| 2576 | |
| 2577 | def parseFilescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseFile().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseFile().(self), file_or_filenamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseFile().(file_or_filename), parseAllscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseFile().(parseAll)=False): |
| 2578 | """ |
| 2579 | Execute the parse expression on the given file or filename. |
| 2580 | If a filename is specified (instead of a file object), |
| 2581 | the entire file is opened, read, and closed before parsing. |
| 2582 | """ |
| 2583 | try: |
| 2584 | file_contents = file_or_filenamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseFile().(file_or_filename).read() |
| 2585 | except AttributeErrorscip-python python python-stdlib 3.11 builtins/AttributeError#: |
| 2586 | with openscip-python python python-stdlib 3.11 builtins/open().(file_or_filenamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseFile().(file_or_filename), "r") as f: |
| 2587 | file_contents = f.readscip-python python python-stdlib 3.11 io/TextIOBase#read().() |
| 2588 | try: |
| 2589 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseFile().(self).parseStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(file_contents, parseAllscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseFile().(parseAll)) |
| 2590 | except ParseBaseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException# as exc: |
| 2591 | if ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.verbose_stacktracescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#verbose_stacktrace.: |
| 2592 | raise |
| 2593 | else: |
| 2594 | # catch and re-raise exception from here, clearing out pyparsing internal stack trace |
| 2595 | if getattrscip-python python python-stdlib 3.11 builtins/getattr().(exc, '__traceback__', None) is not None: |
| 2596 | exc.__traceback__scip-python python python-stdlib 3.11 builtins/BaseException#__traceback__. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseFile().(self)._trim_tracebackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_trim_traceback().(exc.__traceback__scip-python python python-stdlib 3.11 builtins/BaseException#__traceback__.) |
| 2597 | raise exc |
| 2598 | |
| 2599 | def __eq__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__eq__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__eq__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__eq__().(other)): |
| 2600 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__eq__().(self) is otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__eq__().(other): |
| 2601 | return True |
| 2602 | elif isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__eq__().(other), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 2603 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__eq__().(self).matchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#matches().(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__eq__().(other)) |
| 2604 | elif isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__eq__().(other), ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#): |
| 2605 | return varsscip-python python python-stdlib 3.11 builtins/vars().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__eq__().(self)) == varsscip-python python python-stdlib 3.11 builtins/vars().(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__eq__().(other)) |
| 2606 | return False |
| 2607 | |
| 2608 | def __ne__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__ne__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__ne__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__ne__().(other)): |
| 2609 | return not (selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__ne__().(self) == otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__ne__().(other)) |
| 2610 | |
| 2611 | def __hash__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__hash__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__hash__().(self)): |
| 2612 | return id(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__hash__().(self)) |
| 2613 | |
| 2614 | def __req__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__req__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__req__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__req__().(other)): |
| 2615 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__req__().(self) == otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__req__().(other) |
| 2616 | |
| 2617 | def __rne__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rne__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rne__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rne__().(other)): |
| 2618 | return not (selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rne__().(self) == otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__rne__().(other)) |
| 2619 | |
| 2620 | def matchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#matches().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#matches().(self), testStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#matches().(testString), parseAllscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#matches().(parseAll)=True): |
| 2621 | """ |
| 2622 | Method for quick testing of a parser against a test string. Good for simple |
| 2623 | inline microtests of sub expressions while building up larger parser. |
| 2624 | |
| 2625 | Parameters: |
| 2626 | - testString - to test against this expression for a match |
| 2627 | - parseAll - (default= ``True``) - flag to pass to :class:`parseString` when running tests |
| 2628 | |
| 2629 | Example:: |
| 2630 | |
| 2631 | expr = Word(nums) |
| 2632 | assert expr.matches("100") |
| 2633 | """ |
| 2634 | try: |
| 2635 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#matches().(self).parseStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(_ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(testStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#matches().(testString)), parseAllscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(parseAll)=parseAllscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#matches().(parseAll)) |
| 2636 | return True |
| 2637 | except ParseBaseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#: |
| 2638 | return False |
| 2639 | |
| 2640 | def runTestsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(self), testsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(tests), parseAllscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(parseAll)=True, commentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(comment)='#', |
| 2641 | fullDumpscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(fullDump)=True, printResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(printResults)=True, failureTestsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(failureTests)=False, postParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(postParse)=None, |
| 2642 | filescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(file)=None): |
| 2643 | """ |
| 2644 | Execute the parse expression on a series of test strings, showing each |
| 2645 | test, the parsed results or where the parse failed. Quick and easy way to |
| 2646 | run a parse expression against a list of sample strings. |
| 2647 | |
| 2648 | Parameters: |
| 2649 | - tests - a list of separate test strings, or a multiline string of test strings |
| 2650 | - parseAll - (default= ``True``) - flag to pass to :class:`parseString` when running tests |
| 2651 | - comment - (default= ``'#'``) - expression for indicating embedded comments in the test |
| 2652 | string; pass None to disable comment filtering |
| 2653 | - fullDump - (default= ``True``) - dump results as list followed by results names in nested outline; |
| 2654 | if False, only dump nested list |
| 2655 | - printResults - (default= ``True``) prints test output to stdout |
| 2656 | - failureTests - (default= ``False``) indicates if these tests are expected to fail parsing |
| 2657 | - postParse - (default= ``None``) optional callback for successful parse results; called as |
| 2658 | `fn(test_string, parse_results)` and returns a string to be added to the test output |
| 2659 | - file - (default=``None``) optional file-like object to which test output will be written; |
| 2660 | if None, will default to ``sys.stdout`` |
| 2661 | |
| 2662 | Returns: a (success, results) tuple, where success indicates that all tests succeeded |
| 2663 | (or failed if ``failureTests`` is True), and the results contain a list of lines of each |
| 2664 | test's output |
| 2665 | |
| 2666 | Example:: |
| 2667 | |
| 2668 | number_expr = pyparsing_common.number.copy() |
| 2669 | |
| 2670 | result = number_expr.runTests(''' |
| 2671 | # unsigned integer |
| 2672 | 100 |
| 2673 | # negative integer |
| 2674 | -100 |
| 2675 | # float with scientific notation |
| 2676 | 6.02e23 |
| 2677 | # integer with scientific notation |
| 2678 | 1e-12 |
| 2679 | ''') |
| 2680 | print("Success" if result[0] else "Failed!") |
| 2681 | |
| 2682 | result = number_expr.runTests(''' |
| 2683 | # stray character |
| 2684 | 100Z |
| 2685 | # missing leading digit before '.' |
| 2686 | -.100 |
| 2687 | # too many '.' |
| 2688 | 3.14.159 |
| 2689 | ''', failureTests=True) |
| 2690 | print("Success" if result[0] else "Failed!") |
| 2691 | |
| 2692 | prints:: |
| 2693 | |
| 2694 | # unsigned integer |
| 2695 | 100 |
| 2696 | [100] |
| 2697 | |
| 2698 | # negative integer |
| 2699 | -100 |
| 2700 | [-100] |
| 2701 | |
| 2702 | # float with scientific notation |
| 2703 | 6.02e23 |
| 2704 | [6.02e+23] |
| 2705 | |
| 2706 | # integer with scientific notation |
| 2707 | 1e-12 |
| 2708 | [1e-12] |
| 2709 | |
| 2710 | Success |
| 2711 | |
| 2712 | # stray character |
| 2713 | 100Z |
| 2714 | ^ |
| 2715 | FAIL: Expected end of text (at char 3), (line:1, col:4) |
| 2716 | |
| 2717 | # missing leading digit before '.' |
| 2718 | -.100 |
| 2719 | ^ |
| 2720 | FAIL: Expected {real number with scientific notation | real number | signed integer} (at char 0), (line:1, col:1) |
| 2721 | |
| 2722 | # too many '.' |
| 2723 | 3.14.159 |
| 2724 | ^ |
| 2725 | FAIL: Expected end of text (at char 4), (line:1, col:5) |
| 2726 | |
| 2727 | Success |
| 2728 | |
| 2729 | Each test string must be on a single line. If you want to test a string that spans multiple |
| 2730 | lines, create a test like this:: |
| 2731 | |
| 2732 | expr.runTest(r"this is a test\\n of strings that spans \\n 3 lines") |
| 2733 | |
| 2734 | (Note that this is a raw string literal, you must include the leading 'r'.) |
| 2735 | """ |
| 2736 | if isinstance(testsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(tests), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 2737 | testsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(tests) = listscip-python python python-stdlib 3.11 builtins/list#(mapscip-python python python-stdlib 3.11 builtins/map#(strscip-python python python-stdlib 3.11 builtins/str#.stripscip-python python python-stdlib 3.11 builtins/str#strip()., testsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(tests).rstripscip-python python python-stdlib 3.11 builtins/str#rstrip().().splitlinesscip-python python python-stdlib 3.11 builtins/str#splitlines().())) |
| 2738 | if isinstance(commentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(comment), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 2739 | commentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(comment) = Literalscip-python python python-stdlib 3.11 builtins/Literal#(commentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(comment)) |
| 2740 | if filescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(file) is None: |
| 2741 | filescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(file) = sysscip-python python python-stdlib 3.11 sys/__init__:.stdoutscip-python python python-stdlib 3.11 sys/stdout.stdout. |
| 2742 | print_ = filescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(file).writescip-python python python-stdlib 3.11 typing/IO#write(). |
| 2743 | |
| 2744 | allResults = [] |
| 2745 | comments = [] |
| 2746 | success = True |
| 2747 | NL = Literalscip-python python python-stdlib 3.11 builtins/Literal#(r'\n').addParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addParseAction().(replaceWithscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/replaceWith().('\n')).ignorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(quotedStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/quotedString.) |
| 2748 | BOM = u'\ufeff' |
| 2749 | for t in testsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(tests): |
| 2750 | if commentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(comment) is not None and commentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(comment).matchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#matches().(t, False) or comments and not t: |
| 2751 | comments.appendscip-python python python-stdlib 3.11 builtins/list#append().(t) |
| 2752 | continue |
| 2753 | if not t: |
| 2754 | continue |
| 2755 | out = ['\n' + '\n'.joinscip-python python python-stdlib 3.11 builtins/str#join().(comments) if comments else '', t] |
| 2756 | comments = [] |
| 2757 | try: |
| 2758 | # convert newline marks to actual newlines, and strip leading BOM if present |
| 2759 | t = NL.transformStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#transformString().(t.lstripscip-python python python-stdlib 3.11 builtins/str#lstrip().(BOM)) |
| 2760 | result = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(self).parseStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(t, parseAllscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseString().(parseAll)=parseAllscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(parseAll)) |
| 2761 | except ParseBaseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException# as pe: |
| 2762 | fatal = "(FATAL)" if isinstance(pe, ParseFatalExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseFatalException#) else "" |
| 2763 | if '\n' in t: |
| 2764 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().(linescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/line().(pe.locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#loc., t)) |
| 2765 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().(' ' * (colscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/col().(pe.locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#loc., t) - 1) + '^' + fatal) |
| 2766 | else: |
| 2767 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().(' ' * pe.locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#loc. + '^' + fatal) |
| 2768 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().("FAIL: " + strscip-python python python-stdlib 3.11 builtins/str#(pe)) |
| 2769 | success = success and failureTestsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(failureTests) |
| 2770 | result = pe |
| 2771 | except Exceptionscip-python python python-stdlib 3.11 builtins/Exception# as exc: |
| 2772 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().("FAIL-EXCEPTION: " + strscip-python python python-stdlib 3.11 builtins/str#(exc)) |
| 2773 | success = success and failureTestsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(failureTests) |
| 2774 | result = exc |
| 2775 | else: |
| 2776 | success = success and not failureTestsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(failureTests) |
| 2777 | if postParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(postParse) is not None: |
| 2778 | try: |
| 2779 | pp_value = postParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(postParse)(t, result) |
| 2780 | if pp_value is not None: |
| 2781 | if isinstance(pp_value, ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#): |
| 2782 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().(pp_value.dumpscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#dump().()) |
| 2783 | else: |
| 2784 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().(strscip-python python python-stdlib 3.11 builtins/str#(pp_value)) |
| 2785 | else: |
| 2786 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().(result.dump()) |
| 2787 | except Exceptionscip-python python python-stdlib 3.11 builtins/Exception# as e: |
| 2788 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().(result.dump(full=fullDumpscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(fullDump))) |
| 2789 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().("{0} failed: {1}: {2}".format(postParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(postParse).__name__, typescip-python python python-stdlib 3.11 builtins/type#(e).__name__scip-python python python-stdlib 3.11 builtins/__name__#, e)) |
| 2790 | else: |
| 2791 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().(result.dump(full=fullDumpscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(fullDump))) |
| 2792 | |
| 2793 | if printResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(printResults): |
| 2794 | if fullDumpscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(fullDump): |
| 2795 | out.appendscip-python python python-stdlib 3.11 builtins/list#append().('') |
| 2796 | print_('\n'.joinscip-python python python-stdlib 3.11 builtins/str#join().(out)) |
| 2797 | |
| 2798 | allResults.appendscip-python python python-stdlib 3.11 builtins/list#append().((t, result)) |
| 2799 | |
| 2800 | return success, allResults |
| 2801 | |
| 2802 | |
| 2803 | class _PendingSkipscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#(ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#): |
| 2804 | # internal placeholder class to hold a place were '...' is added to a parser element, |
| 2805 | # once another ParserElement is added, this placeholder will be replaced with a SkipTo |
| 2806 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__init__().(self), exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__init__().(expr), must_skipscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__init__().(must_skip)=False): |
| 2807 | superscip-python python python-stdlib 3.11 builtins/super#(_PendingSkipscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().() |
| 2808 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__init__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#strRepr. = strscip-python python python-stdlib 3.11 builtins/str#(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__init__().(expr) + Emptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#()).replacescip-python python python-stdlib 3.11 builtins/str#replace().('Empty', '...') |
| 2809 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#name. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__init__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#strRepr. |
| 2810 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__init__().(self).anchorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#anchor. = exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__init__().(expr) |
| 2811 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__init__().(self).must_skipscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#must_skip. = must_skipscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__init__().(must_skip) |
| 2812 | |
| 2813 | def __add__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__add__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__add__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__add__().(other)): |
| 2814 | skipper = SkipToscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__add__().(other)).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("...")("_skipped*") |
| 2815 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__add__().(self).must_skipscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#must_skip.: |
| 2816 | def must_skipscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#must_skip().(tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#must_skip().(t)): |
| 2817 | if not tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#must_skip().(t)._skipped or tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#must_skip().(t)._skipped.asList() == ['']: |
| 2818 | del tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#must_skip().(t)[0] |
| 2819 | tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#must_skip().(t).pop("_skipped", None) |
| 2820 | def show_skipscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#show_skip().(tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#show_skip().(t)): |
| 2821 | if tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#show_skip().(t)._skipped.asList()[-1:] == ['']: |
| 2822 | skipped = tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#show_skip().(t).pop('_skipped') |
| 2823 | tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#show_skip().(t)['_skipped'] = 'missing <' + repr(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__add__().(self).anchorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#anchor.) + '>' |
| 2824 | return (selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__add__().(self).anchorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#anchor. + skipper().addParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addParseAction().(must_skipscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#must_skip().) |
| 2825 | | skipper().addParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addParseAction().(show_skipscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#show_skip().)) + otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__add__().(other) |
| 2826 | |
| 2827 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__add__().(self).anchorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#anchor. + skipper + otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__add__().(other) |
| 2828 | |
| 2829 | def __repr__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__repr__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__repr__().(self)): |
| 2830 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#__repr__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#strRepr. |
| 2831 | |
| 2832 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#parseImpl().(self), *argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#parseImpl().(args)): |
| 2833 | raise Exceptionscip-python python python-stdlib 3.11 builtins/Exception#("use of `...` expression without following SkipTo target expression") |
| 2834 | |
| 2835 | |
| 2836 | class Tokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#(ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#): |
| 2837 | """Abstract :class:`ParserElement` subclass, for defining atomic |
| 2838 | matching patterns. |
| 2839 | """ |
| 2840 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#__init__().(self)): |
| 2841 | superscip-python python python-stdlib 3.11 builtins/super#(Tokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(savelistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(savelist)=False) |
| 2842 | |
| 2843 | |
| 2844 | class Emptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#(Tokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#): |
| 2845 | """An empty token, will always match. |
| 2846 | """ |
| 2847 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#__init__().(self)): |
| 2848 | superscip-python python python-stdlib 3.11 builtins/super#(Emptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#__init__().() |
| 2849 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#name. = "Empty" |
| 2850 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#mayReturnEmpty. = True |
| 2851 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#__init__().(self).mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#mayIndexError. = False |
| 2852 | |
| 2853 | |
| 2854 | class NoMatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#(Tokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#): |
| 2855 | """A token that will never match. |
| 2856 | """ |
| 2857 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#__init__().(self)): |
| 2858 | superscip-python python python-stdlib 3.11 builtins/super#(NoMatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#__init__().() |
| 2859 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#name. = "NoMatch" |
| 2860 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#mayReturnEmpty. = True |
| 2861 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#__init__().(self).mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#mayIndexError. = False |
| 2862 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#__init__().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#errmsg. = "Unmatchable token" |
| 2863 | |
| 2864 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#parseImpl().(doActions)=True): |
| 2865 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#parseImpl().(self)) |
| 2866 | |
| 2867 | |
| 2868 | class Literalscip-python python python-stdlib 3.11 builtins/Literal#(Tokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#): |
| 2869 | """Token to exactly match a specified string. |
| 2870 | |
| 2871 | Example:: |
| 2872 | |
| 2873 | Literal('blah').parseString('blah') # -> ['blah'] |
| 2874 | Literal('blah').parseString('blahfooblah') # -> ['blah'] |
| 2875 | Literal('blah').parseString('bla') # -> Exception: Expected "blah" |
| 2876 | |
| 2877 | For case-insensitive matching, use :class:`CaselessLiteral`. |
| 2878 | |
| 2879 | For keyword matching (force word break before and after the matched string), |
| 2880 | use :class:`Keyword` or :class:`CaselessKeyword`. |
| 2881 | """ |
| 2882 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#__init__().(self), matchStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#__init__().(matchString)): |
| 2883 | superscip-python python python-stdlib 3.11 builtins/super#(Literalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#__init__().() |
| 2884 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#__init__().(self).matchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#match. = matchStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#__init__().(matchString) |
| 2885 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#__init__().(self).matchLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#matchLen. = len(matchStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#__init__().(matchString)) |
| 2886 | try: |
| 2887 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#__init__().(self).firstMatchCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#firstMatchChar. = matchStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#__init__().(matchString)[0] |
| 2888 | except IndexErrorscip-python python python-stdlib 3.11 builtins/IndexError#: |
| 2889 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("null string passed to Literal; use Empty() instead", |
| 2890 | SyntaxWarningscip-python python python-stdlib 3.11 builtins/SyntaxWarning#, stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 2891 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#__init__().(self).__class__scip-python python python-stdlib 3.11 builtins/object#__class__(). = Emptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty# |
| 2892 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#name. = '"%s"' % _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#__init__().(self).matchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#match.) |
| 2893 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#__init__().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#errmsg. = "Expected " + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#name. |
| 2894 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#mayReturnEmpty. = False |
| 2895 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#__init__().(self).mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#mayIndexError. = False |
| 2896 | |
| 2897 | # Performance tuning: modify __class__ to select |
| 2898 | # a parseImpl optimized for single-character check |
| 2899 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#__init__().(self).matchLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#matchLen. == 1 and typescip-python python python-stdlib 3.11 builtins/type#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#__init__().(self)) is Literalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#: |
| 2900 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#__init__().(self).__class__scip-python python python-stdlib 3.11 builtins/object#__class__(). = _SingleCharLiteralscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_SingleCharLiteral# |
| 2901 | |
| 2902 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#parseImpl().(doActions)=True): |
| 2903 | if instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#parseImpl().(loc)] == selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#parseImpl().(self).firstMatchCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#firstMatchChar. and instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#parseImpl().(instring).startswith(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#parseImpl().(self).matchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#match., locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#parseImpl().(loc)): |
| 2904 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#parseImpl().(loc) + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#parseImpl().(self).matchLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#matchLen., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#parseImpl().(self).matchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#match. |
| 2905 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#parseImpl().(self)) |
| 2906 | |
| 2907 | class _SingleCharLiteralscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_SingleCharLiteral#(Literalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#): |
| 2908 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_SingleCharLiteral#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_SingleCharLiteral#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_SingleCharLiteral#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_SingleCharLiteral#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_SingleCharLiteral#parseImpl().(doActions)=True): |
| 2909 | if instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_SingleCharLiteral#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_SingleCharLiteral#parseImpl().(loc)] == selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_SingleCharLiteral#parseImpl().(self).firstMatchCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#firstMatchChar.: |
| 2910 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_SingleCharLiteral#parseImpl().(loc) + 1, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_SingleCharLiteral#parseImpl().(self).matchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#match. |
| 2911 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_SingleCharLiteral#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_SingleCharLiteral#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_SingleCharLiteral#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_SingleCharLiteral#parseImpl().(self)) |
| 2912 | |
| 2913 | _Lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_L. = Literalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal# |
| 2914 | ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#._literalStringClass = Literalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal# |
| 2915 | |
| 2916 | class Keywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#(Tokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#): |
| 2917 | """Token to exactly match a specified string as a keyword, that is, |
| 2918 | it must be immediately followed by a non-keyword character. Compare |
| 2919 | with :class:`Literal`: |
| 2920 | |
| 2921 | - ``Literal("if")`` will match the leading ``'if'`` in |
| 2922 | ``'ifAndOnlyIf'``. |
| 2923 | - ``Keyword("if")`` will not; it will only match the leading |
| 2924 | ``'if'`` in ``'if x=1'``, or ``'if(y==2)'`` |
| 2925 | |
| 2926 | Accepts two optional constructor arguments in addition to the |
| 2927 | keyword string: |
| 2928 | |
| 2929 | - ``identChars`` is a string of characters that would be valid |
| 2930 | identifier characters, defaulting to all alphanumerics + "_" and |
| 2931 | "$" |
| 2932 | - ``caseless`` allows case-insensitive matching, default is ``False``. |
| 2933 | |
| 2934 | Example:: |
| 2935 | |
| 2936 | Keyword("start").parseString("start") # -> ['start'] |
| 2937 | Keyword("start").parseString("starting") # -> Exception |
| 2938 | |
| 2939 | For case-insensitive matching, use :class:`CaselessKeyword`. |
| 2940 | """ |
| 2941 | DEFAULT_KEYWORD_CHARSscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#DEFAULT_KEYWORD_CHARS. = alphanumsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/alphanums. + "_$" |
| 2942 | |
| 2943 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(self), matchStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(matchString), identCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(identChars)=None, caselessscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(caseless)=False): |
| 2944 | superscip-python python python-stdlib 3.11 builtins/super#(Keywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#__init__().() |
| 2945 | if identCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(identChars) is None: |
| 2946 | identCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(identChars) = Keywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#.DEFAULT_KEYWORD_CHARSscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#DEFAULT_KEYWORD_CHARS. |
| 2947 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(self).matchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#match. = matchStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(matchString) |
| 2948 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(self).matchLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#matchLen. = len(matchStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(matchString)) |
| 2949 | try: |
| 2950 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(self).firstMatchCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#firstMatchChar. = matchStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(matchString)[0] |
| 2951 | except IndexErrorscip-python python python-stdlib 3.11 builtins/IndexError#: |
| 2952 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("null string passed to Keyword; use Empty() instead", |
| 2953 | SyntaxWarningscip-python python python-stdlib 3.11 builtins/SyntaxWarning#, stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 2954 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#name. = '"%s"' % selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(self).matchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#match. |
| 2955 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#errmsg. = "Expected " + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#name. |
| 2956 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#mayReturnEmpty. = False |
| 2957 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(self).mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#mayIndexError. = False |
| 2958 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(self).caselessscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#caseless. = caselessscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(caseless) |
| 2959 | if caselessscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(caseless): |
| 2960 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(self).caselessmatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#caselessmatch. = matchStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(matchString).upper() |
| 2961 | identCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(identChars) = identCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(identChars).upperscip-python python python-stdlib 3.11 builtins/str#upper().() |
| 2962 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(self).identCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#identChars. = setscip-python python python-stdlib 3.11 builtins/set#(identCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(identChars)) |
| 2963 | |
| 2964 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(doActions)=True): |
| 2965 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(self).caselessscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#caseless.: |
| 2966 | if ((instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(loc):locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(loc) + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(self).matchLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#matchLen.].upper() == selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(self).caselessmatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#caselessmatch.) |
| 2967 | and (locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(loc) >= len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(instring)) - selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(self).matchLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#matchLen. |
| 2968 | or instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(loc) + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(self).matchLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#matchLen.].upper() not in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(self).identCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#identChars.) |
| 2969 | and (locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(loc) == 0 |
| 2970 | or instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(loc) - 1].upper() not in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(self).identCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#identChars.)): |
| 2971 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(loc) + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(self).matchLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#matchLen., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(self).matchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#match. |
| 2972 | |
| 2973 | else: |
| 2974 | if instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(loc)] == selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(self).firstMatchCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#firstMatchChar.: |
| 2975 | if ((selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(self).matchLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#matchLen. == 1 or instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(instring).startswith(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(self).matchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#match., locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(loc))) |
| 2976 | and (locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(loc) >= len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(instring)) - selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(self).matchLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#matchLen. |
| 2977 | or instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(loc) + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(self).matchLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#matchLen.] not in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(self).identCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#identChars.) |
| 2978 | and (locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(loc) == 0 or instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(loc) - 1] not in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(self).identCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#identChars.)): |
| 2979 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(loc) + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(self).matchLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#matchLen., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(self).matchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#match. |
| 2980 | |
| 2981 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#parseImpl().(self)) |
| 2982 | |
| 2983 | def copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#copy().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#copy().(self)): |
| 2984 | c = superscip-python python python-stdlib 3.11 builtins/super#(Keywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#copy().(self)).copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().() |
| 2985 | c.identCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#identChars. = Keywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#.DEFAULT_KEYWORD_CHARSscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#DEFAULT_KEYWORD_CHARS. |
| 2986 | return c |
| 2987 | |
| 2988 | @staticmethodscip-python python python-stdlib 3.11 builtins/staticmethod# |
| 2989 | def setDefaultKeywordCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#setDefaultKeywordChars().(charsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#setDefaultKeywordChars().(chars)): |
| 2990 | """Overrides the default Keyword chars |
| 2991 | """ |
| 2992 | Keywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#.DEFAULT_KEYWORD_CHARSscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#DEFAULT_KEYWORD_CHARS. = charsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#setDefaultKeywordChars().(chars) |
| 2993 | |
| 2994 | class CaselessLiteralscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#(Literalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#): |
| 2995 | """Token to match a specified string, ignoring case of letters. |
| 2996 | Note: the matched results will always be in the case of the given |
| 2997 | match string, NOT the case of the input text. |
| 2998 | |
| 2999 | Example:: |
| 3000 | |
| 3001 | OneOrMore(CaselessLiteral("CMD")).parseString("cmd CMD Cmd10") # -> ['CMD', 'CMD', 'CMD'] |
| 3002 | |
| 3003 | (Contrast with example for :class:`CaselessKeyword`.) |
| 3004 | """ |
| 3005 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#__init__().(self), matchStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#__init__().(matchString)): |
| 3006 | superscip-python python python-stdlib 3.11 builtins/super#(CaselessLiteralscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#__init__().(matchStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#__init__().(matchString).upper()) |
| 3007 | # Preserve the defining literal. |
| 3008 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#__init__().(self).returnStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#returnString. = matchStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#__init__().(matchString) |
| 3009 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#name. = "'%s'" % selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#__init__().(self).returnStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#returnString. |
| 3010 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#__init__().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#errmsg. = "Expected " + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#name. |
| 3011 | |
| 3012 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#parseImpl().(doActions)=True): |
| 3013 | if instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#parseImpl().(loc):locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#parseImpl().(loc) + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#parseImpl().(self).matchLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#matchLen.].upper() == selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#parseImpl().(self).matchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#match.: |
| 3014 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#parseImpl().(loc) + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#parseImpl().(self).matchLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#matchLen., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#parseImpl().(self).returnStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#returnString. |
| 3015 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#parseImpl().(self)) |
| 3016 | |
| 3017 | class CaselessKeywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessKeyword#(Keywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#): |
| 3018 | """ |
| 3019 | Caseless version of :class:`Keyword`. |
| 3020 | |
| 3021 | Example:: |
| 3022 | |
| 3023 | OneOrMore(CaselessKeyword("CMD")).parseString("cmd CMD Cmd10") # -> ['CMD', 'CMD'] |
| 3024 | |
| 3025 | (Contrast with example for :class:`CaselessLiteral`.) |
| 3026 | """ |
| 3027 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessKeyword#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessKeyword#__init__().(self), matchStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessKeyword#__init__().(matchString), identCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessKeyword#__init__().(identChars)=None): |
| 3028 | superscip-python python python-stdlib 3.11 builtins/super#(CaselessKeywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessKeyword#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessKeyword#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(matchStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessKeyword#__init__().(matchString), identCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessKeyword#__init__().(identChars), caselessscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(caseless)=True) |
| 3029 | |
| 3030 | class CloseMatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#(Tokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#): |
| 3031 | """A variation on :class:`Literal` which matches "close" matches, |
| 3032 | that is, strings with at most 'n' mismatching characters. |
| 3033 | :class:`CloseMatch` takes parameters: |
| 3034 | |
| 3035 | - ``match_string`` - string to be matched |
| 3036 | - ``maxMismatches`` - (``default=1``) maximum number of |
| 3037 | mismatches allowed to count as a match |
| 3038 | |
| 3039 | The results from a successful parse will contain the matched text |
| 3040 | from the input string and the following named results: |
| 3041 | |
| 3042 | - ``mismatches`` - a list of the positions within the |
| 3043 | match_string where mismatches were found |
| 3044 | - ``original`` - the original match_string used to compare |
| 3045 | against the input string |
| 3046 | |
| 3047 | If ``mismatches`` is an empty list, then the match was an exact |
| 3048 | match. |
| 3049 | |
| 3050 | Example:: |
| 3051 | |
| 3052 | patt = CloseMatch("ATCATCGAATGGA") |
| 3053 | patt.parseString("ATCATCGAAXGGA") # -> (['ATCATCGAAXGGA'], {'mismatches': [[9]], 'original': ['ATCATCGAATGGA']}) |
| 3054 | patt.parseString("ATCAXCGAAXGGA") # -> Exception: Expected 'ATCATCGAATGGA' (with up to 1 mismatches) (at char 0), (line:1, col:1) |
| 3055 | |
| 3056 | # exact match |
| 3057 | patt.parseString("ATCATCGAATGGA") # -> (['ATCATCGAATGGA'], {'mismatches': [[]], 'original': ['ATCATCGAATGGA']}) |
| 3058 | |
| 3059 | # close match allowing up to 2 mismatches |
| 3060 | patt = CloseMatch("ATCATCGAATGGA", maxMismatches=2) |
| 3061 | patt.parseString("ATCAXCGAAXGGA") # -> (['ATCAXCGAAXGGA'], {'mismatches': [[4, 9]], 'original': ['ATCATCGAATGGA']}) |
| 3062 | """ |
| 3063 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#__init__().(self), match_stringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#__init__().(match_string), maxMismatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#__init__().(maxMismatches)=1): |
| 3064 | superscip-python python python-stdlib 3.11 builtins/super#(CloseMatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#__init__().() |
| 3065 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#name. = match_stringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#__init__().(match_string) |
| 3066 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#__init__().(self).match_stringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#match_string. = match_stringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#__init__().(match_string) |
| 3067 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#__init__().(self).maxMismatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#maxMismatches. = maxMismatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#__init__().(maxMismatches) |
| 3068 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#__init__().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#errmsg. = "Expected %r (with up to %d mismatches)" % (selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#__init__().(self).match_stringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#match_string., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#__init__().(self).maxMismatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#maxMismatches.) |
| 3069 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#__init__().(self).mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#mayIndexError. = False |
| 3070 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#mayReturnEmpty. = False |
| 3071 | |
| 3072 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#parseImpl().(doActions)=True): |
| 3073 | start = locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#parseImpl().(loc) |
| 3074 | instrlen = len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#parseImpl().(instring)) |
| 3075 | maxloc = start + len(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#parseImpl().(self).match_stringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#match_string.) |
| 3076 | |
| 3077 | if maxloc <= instrlen: |
| 3078 | match_string = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#parseImpl().(self).match_stringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#match_string. |
| 3079 | match_stringloc = 0 |
| 3080 | mismatches = [] |
| 3081 | maxMismatches = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#parseImpl().(self).maxMismatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#maxMismatches. |
| 3082 | |
| 3083 | for match_stringloc, s_m in enumeratescip-python python python-stdlib 3.11 builtins/enumerate#(zipscip-python python python-stdlib 3.11 builtins/zip#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#parseImpl().(loc):maxloc], match_string)): |
| 3084 | src, mat = s_m |
| 3085 | if src != mat: |
| 3086 | mismatches.appendscip-python python python-stdlib 3.11 builtins/list#append().(match_stringloc) |
| 3087 | if len(mismatches) > maxMismatches: |
| 3088 | break |
| 3089 | else: |
| 3090 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#parseImpl().(loc) = match_stringloc + 1 |
| 3091 | results = ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#([instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#parseImpl().(instring)[start:locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#parseImpl().(loc)]]) |
| 3092 | results['original'] = match_string |
| 3093 | results['mismatches'] = mismatches |
| 3094 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#parseImpl().(loc), results |
| 3095 | |
| 3096 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CloseMatch#parseImpl().(self)) |
| 3097 | |
| 3098 | |
| 3099 | class Wordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#(Tokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#): |
| 3100 | """Token for matching words composed of allowed character sets. |
| 3101 | Defined with string containing all allowed initial characters, an |
| 3102 | optional string containing allowed body characters (if omitted, |
| 3103 | defaults to the initial character set), and an optional minimum, |
| 3104 | maximum, and/or exact length. The default value for ``min`` is |
| 3105 | 1 (a minimum value < 1 is not valid); the default values for |
| 3106 | ``max`` and ``exact`` are 0, meaning no maximum or exact |
| 3107 | length restriction. An optional ``excludeChars`` parameter can |
| 3108 | list characters that might be found in the input ``bodyChars`` |
| 3109 | string; useful to define a word of all printables except for one or |
| 3110 | two characters, for instance. |
| 3111 | |
| 3112 | :class:`srange` is useful for defining custom character set strings |
| 3113 | for defining ``Word`` expressions, using range notation from |
| 3114 | regular expression character sets. |
| 3115 | |
| 3116 | A common mistake is to use :class:`Word` to match a specific literal |
| 3117 | string, as in ``Word("Address")``. Remember that :class:`Word` |
| 3118 | uses the string argument to define *sets* of matchable characters. |
| 3119 | This expression would match "Add", "AAA", "dAred", or any other word |
| 3120 | made up of the characters 'A', 'd', 'r', 'e', and 's'. To match an |
| 3121 | exact literal string, use :class:`Literal` or :class:`Keyword`. |
| 3122 | |
| 3123 | pyparsing includes helper strings for building Words: |
| 3124 | |
| 3125 | - :class:`alphas` |
| 3126 | - :class:`nums` |
| 3127 | - :class:`alphanums` |
| 3128 | - :class:`hexnums` |
| 3129 | - :class:`alphas8bit` (alphabetic characters in ASCII range 128-255 |
| 3130 | - accented, tilded, umlauted, etc.) |
| 3131 | - :class:`punc8bit` (non-alphabetic characters in ASCII range |
| 3132 | 128-255 - currency, symbols, superscripts, diacriticals, etc.) |
| 3133 | - :class:`printables` (any non-whitespace character) |
| 3134 | |
| 3135 | Example:: |
| 3136 | |
| 3137 | # a word composed of digits |
| 3138 | integer = Word(nums) # equivalent to Word("0123456789") or Word(srange("0-9")) |
| 3139 | |
| 3140 | # a word with a leading capital, and zero or more lowercase |
| 3141 | capital_word = Word(alphas.upper(), alphas.lower()) |
| 3142 | |
| 3143 | # hostnames are alphanumeric, with leading alpha, and '-' |
| 3144 | hostname = Word(alphas, alphanums + '-') |
| 3145 | |
| 3146 | # roman numeral (not a strict parser, accepts invalid mix of characters) |
| 3147 | roman = Word("IVXLCDM") |
| 3148 | |
| 3149 | # any string of non-whitespace characters, except for ',' |
| 3150 | csv_value = Word(printables, excludeChars=",") |
| 3151 | """ |
| 3152 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self), initCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(initChars), bodyCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(bodyChars)=None, minscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(min)=1, maxscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(max)=0, exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(exact)=0, asKeywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(asKeyword)=False, excludeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(excludeChars)=None): |
| 3153 | superscip-python python python-stdlib 3.11 builtins/super#(Wordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#__init__().() |
| 3154 | if excludeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(excludeChars): |
| 3155 | excludeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(excludeChars) = setscip-python python python-stdlib 3.11 builtins/set#(excludeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(excludeChars)) |
| 3156 | initCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(initChars) = ''.joinscip-python python python-stdlib 3.11 builtins/str#join().(c for c in initCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(initChars) if c not in excludeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(excludeChars)) |
| 3157 | if bodyCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(bodyChars): |
| 3158 | bodyCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(bodyChars) = ''.joinscip-python python python-stdlib 3.11 builtins/str#join().(c for c in bodyCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(bodyChars) if c not in excludeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(excludeChars)) |
| 3159 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).initCharsOrigscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#initCharsOrig. = initCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(initChars) |
| 3160 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).initCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#initChars. = setscip-python python python-stdlib 3.11 builtins/set#(initCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(initChars)) |
| 3161 | if bodyCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(bodyChars): |
| 3162 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).bodyCharsOrigscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#bodyCharsOrig. = bodyCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(bodyChars) |
| 3163 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).bodyCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#bodyChars. = setscip-python python python-stdlib 3.11 builtins/set#(bodyCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(bodyChars)) |
| 3164 | else: |
| 3165 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).bodyCharsOrigscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#bodyCharsOrig. = initCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(initChars) |
| 3166 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).bodyCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#bodyChars. = setscip-python python python-stdlib 3.11 builtins/set#(initCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(initChars)) |
| 3167 | |
| 3168 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).maxSpecifiedscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#maxSpecified. = maxscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(max) > 0 |
| 3169 | |
| 3170 | if minscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(min) < 1: |
| 3171 | raise ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#("cannot specify a minimum length < 1; use Optional(Word()) if zero-length word is permitted") |
| 3172 | |
| 3173 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).minLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#minLen. = minscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(min) |
| 3174 | |
| 3175 | if maxscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(max) > 0: |
| 3176 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).maxLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#maxLen. = maxscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(max) |
| 3177 | else: |
| 3178 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).maxLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#maxLen. = _MAX_INTscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MAX_INT. |
| 3179 | |
| 3180 | if exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(exact) > 0: |
| 3181 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).maxLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#maxLen. = exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(exact) |
| 3182 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).minLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#minLen. = exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(exact) |
| 3183 | |
| 3184 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#name. = _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self)) |
| 3185 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#errmsg. = "Expected " + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#name. |
| 3186 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#mayIndexError. = False |
| 3187 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).asKeywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#asKeyword. = asKeywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(asKeyword) |
| 3188 | |
| 3189 | if ' ' not in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).initCharsOrigscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#initCharsOrig. + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).bodyCharsOrigscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#bodyCharsOrig. and (minscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(min) == 1 and maxscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(max) == 0 and exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(exact) == 0): |
| 3190 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).bodyCharsOrigscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#bodyCharsOrig. == selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).initCharsOrigscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#initCharsOrig.: |
| 3191 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).reStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#reString. = "[%s]+" % _escapeRegexRangeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapeRegexRangeChars().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).initCharsOrigscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#initCharsOrig.) |
| 3192 | elif len(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).initCharsOrigscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#initCharsOrig.) == 1: |
| 3193 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).reStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#reString. = "%s[%s]*" % (rescip-python python python-stdlib 3.11 re/__init__:.escapescip-python python python-stdlib 3.11 re/escape().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).initCharsOrigscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#initCharsOrig.), |
| 3194 | _escapeRegexRangeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapeRegexRangeChars().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).bodyCharsOrigscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#bodyCharsOrig.),) |
| 3195 | else: |
| 3196 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).reStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#reString. = "[%s][%s]*" % (_escapeRegexRangeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapeRegexRangeChars().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).initCharsOrigscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#initCharsOrig.), |
| 3197 | _escapeRegexRangeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapeRegexRangeChars().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).bodyCharsOrigscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#bodyCharsOrig.),) |
| 3198 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).asKeywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#asKeyword.: |
| 3199 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).reStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#reString. = r"\b" + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).reStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#reString. + r"\b" |
| 3200 | |
| 3201 | try: |
| 3202 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).rescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#re. = rescip-python python python-stdlib 3.11 re/__init__:.compilescip-python python python-stdlib 3.11 re/compile().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).reStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#reString.) |
| 3203 | except Exceptionscip-python python python-stdlib 3.11 builtins/Exception#: |
| 3204 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).rescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#re. = None |
| 3205 | else: |
| 3206 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).re_matchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#re_match. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).rescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#re..matchscip-python python python-stdlib 3.11 re/Pattern#match(). |
| 3207 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(self).__class__scip-python python python-stdlib 3.11 builtins/object#__class__(). = _WordRegexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_WordRegex# |
| 3208 | |
| 3209 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(doActions)=True): |
| 3210 | if instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(loc)] not in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(self).initCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#initChars.: |
| 3211 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(self)) |
| 3212 | |
| 3213 | start = locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(loc) |
| 3214 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(loc) += 1 |
| 3215 | instrlen = len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(instring)) |
| 3216 | bodychars = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(self).bodyCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#bodyChars. |
| 3217 | maxloc = start + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(self).maxLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#maxLen. |
| 3218 | maxloc = minscip-python python python-stdlib 3.11 builtins/min().(maxloc, instrlen) |
| 3219 | while locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(loc) < maxloc and instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(loc)] in bodychars: |
| 3220 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(loc) += 1 |
| 3221 | |
| 3222 | throwException = False |
| 3223 | if locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(loc) - start < selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(self).minLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#minLen.: |
| 3224 | throwException = True |
| 3225 | elif selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(self).maxSpecifiedscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#maxSpecified. and locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(loc) < instrlen and instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(loc)] in bodychars: |
| 3226 | throwException = True |
| 3227 | elif selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(self).asKeywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#asKeyword.: |
| 3228 | if (start > 0 and instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(instring)[start - 1] in bodychars |
| 3229 | or locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(loc) < instrlen and instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(loc)] in bodychars): |
| 3230 | throwException = True |
| 3231 | |
| 3232 | if throwException: |
| 3233 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(self)) |
| 3234 | |
| 3235 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(loc), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(instring)[start:locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#parseImpl().(loc)] |
| 3236 | |
| 3237 | def __str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__str__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__str__().(self)): |
| 3238 | try: |
| 3239 | return superscip-python python python-stdlib 3.11 builtins/super#(Wordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__str__().(self)).__str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__str__().() |
| 3240 | except Exceptionscip-python python python-stdlib 3.11 builtins/Exception#: |
| 3241 | pass |
| 3242 | |
| 3243 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#strRepr. is None: |
| 3244 | |
| 3245 | def charsAsStrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#charsAsStr().(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#charsAsStr().(s)): |
| 3246 | if len(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#charsAsStr().(s)) > 4: |
| 3247 | return sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#charsAsStr().(s)[:4] + "..." |
| 3248 | else: |
| 3249 | return sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#charsAsStr().(s) |
| 3250 | |
| 3251 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__str__().(self).initCharsOrigscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#initCharsOrig. != selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__str__().(self).bodyCharsOrigscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#bodyCharsOrig.: |
| 3252 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#strRepr. = "W:(%s, %s)" % (charsAsStrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#charsAsStr().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__str__().(self).initCharsOrigscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#initCharsOrig.), charsAsStrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#charsAsStr().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__str__().(self).bodyCharsOrigscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#bodyCharsOrig.)) |
| 3253 | else: |
| 3254 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#strRepr. = "W:(%s)" % charsAsStrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#charsAsStr().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__str__().(self).initCharsOrigscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#initCharsOrig.) |
| 3255 | |
| 3256 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#strRepr. |
| 3257 | |
| 3258 | class _WordRegexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_WordRegex#(Wordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#): |
| 3259 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_WordRegex#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_WordRegex#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_WordRegex#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_WordRegex#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_WordRegex#parseImpl().(doActions)=True): |
| 3260 | result = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_WordRegex#parseImpl().(self).re_matchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#re_match.(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_WordRegex#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_WordRegex#parseImpl().(loc)) |
| 3261 | if not result: |
| 3262 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_WordRegex#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_WordRegex#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_WordRegex#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_WordRegex#parseImpl().(self)) |
| 3263 | |
| 3264 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_WordRegex#parseImpl().(loc) = result.endscip-python python python-stdlib 3.11 re/Match#end().() |
| 3265 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_WordRegex#parseImpl().(loc), result.groupscip-python python python-stdlib 3.11 re/Match#group().() |
| 3266 | |
| 3267 | |
| 3268 | class Charscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#(_WordRegexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_WordRegex#): |
| 3269 | """A short-cut class for defining ``Word(characters, exact=1)``, |
| 3270 | when defining a match of any single character in a string of |
| 3271 | characters. |
| 3272 | """ |
| 3273 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#__init__().(self), charsetscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#__init__().(charset), asKeywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#__init__().(asKeyword)=False, excludeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#__init__().(excludeChars)=None): |
| 3274 | superscip-python python python-stdlib 3.11 builtins/super#(Charscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(charsetscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#__init__().(charset), exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(exact)=1, asKeywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(asKeyword)=asKeywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#__init__().(asKeyword), excludeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(excludeChars)=excludeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#__init__().(excludeChars)) |
| 3275 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#__init__().(self).reStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#reString. = "[%s]" % _escapeRegexRangeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapeRegexRangeChars().(''.joinscip-python python python-stdlib 3.11 builtins/str#join().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#__init__().(self).initCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#initChars.)) |
| 3276 | if asKeywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#__init__().(asKeyword): |
| 3277 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#__init__().(self).reStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#reString. = r"\b%s\b" % selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#__init__().(self).reStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#reString. |
| 3278 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#__init__().(self).rescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#re. = rescip-python python python-stdlib 3.11 re/__init__:.compilescip-python python python-stdlib 3.11 re/compile().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#__init__().(self).reStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#reString.) |
| 3279 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#__init__().(self).re_matchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#re_match. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#__init__().(self).rescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Char#re..matchscip-python python python-stdlib 3.11 re/Pattern#match(). |
| 3280 | |
| 3281 | |
| 3282 | class Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(Tokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#): |
| 3283 | r"""Token for matching strings that match a given regular |
| 3284 | expression. Defined with string specifying the regular expression in |
| 3285 | a form recognized by the stdlib Python `re module <https://docs.python.org/3/library/re.html>`_. |
| 3286 | If the given regex contains named groups (defined using ``(?P<name>...)``), |
| 3287 | these will be preserved as named parse results. |
| 3288 | |
| 3289 | If instead of the Python stdlib re module you wish to use a different RE module |
| 3290 | (such as the `regex` module), you can replace it by either building your |
| 3291 | Regex object with a compiled RE that was compiled using regex: |
| 3292 | |
| 3293 | Example:: |
| 3294 | |
| 3295 | realnum = Regex(r"[+-]?\d+\.\d*") |
| 3296 | date = Regex(r'(?P<year>\d{4})-(?P<month>\d\d?)-(?P<day>\d\d?)') |
| 3297 | # ref: https://stackoverflow.com/questions/267399/how-do-you-match-only-valid-roman-numerals-with-a-regular-expression |
| 3298 | roman = Regex(r"M{0,4}(CM|CD|D?{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})") |
| 3299 | |
| 3300 | # use regex module instead of stdlib re module to construct a Regex using |
| 3301 | # a compiled regular expression |
| 3302 | import regex |
| 3303 | parser = pp.Regex(regex.compile(r'[0-9]')) |
| 3304 | |
| 3305 | """ |
| 3306 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self), patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(pattern), flagsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(flags)=0, asGroupListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(asGroupList)=False, asMatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(asMatch)=False): |
| 3307 | """The parameters ``pattern`` and ``flags`` are passed |
| 3308 | to the ``re.compile()`` function as-is. See the Python |
| 3309 | `re module <https://docs.python.org/3/library/re.html>`_ module for an |
| 3310 | explanation of the acceptable patterns and flags. |
| 3311 | """ |
| 3312 | superscip-python python python-stdlib 3.11 builtins/super#(Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#__init__().() |
| 3313 | |
| 3314 | if isinstance(patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(pattern), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 3315 | if not patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(pattern): |
| 3316 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("null string passed to Regex; use Empty() instead", |
| 3317 | SyntaxWarningscip-python python python-stdlib 3.11 builtins/SyntaxWarning#, stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 3318 | |
| 3319 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#pattern. = patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(pattern) |
| 3320 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).flagsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#flags. = flagsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(flags) |
| 3321 | |
| 3322 | try: |
| 3323 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).rescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#re. = rescip-python python python-stdlib 3.11 re/__init__:.compilescip-python python python-stdlib 3.11 re/compile().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#pattern., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).flagsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#flags.) |
| 3324 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).reStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#reString. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#pattern. |
| 3325 | except sre_constantsscip-python python python-stdlib 3.11 sre_constants/__init__:.errorscip-python python gavodachs 2.13 sre_constants/error#: |
| 3326 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("invalid pattern (%s) passed to Regex" % patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(pattern), |
| 3327 | SyntaxWarningscip-python python python-stdlib 3.11 builtins/SyntaxWarning#, stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 3328 | raise |
| 3329 | |
| 3330 | elif hasattr(patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(pattern), 'pattern') and hasattr(patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(pattern), 'match'): |
| 3331 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).rescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#re. = patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(pattern) |
| 3332 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#pattern. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).reStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#reString. = patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(pattern).pattern |
| 3333 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).flagsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#flags. = flagsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(flags) |
| 3334 | |
| 3335 | else: |
| 3336 | raise TypeErrorscip-python python python-stdlib 3.11 builtins/TypeError#("Regex may only be constructed with a string or a compiled RE object") |
| 3337 | |
| 3338 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).re_matchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#re_match. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).rescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#re..matchscip-python python python-stdlib 3.11 re/Pattern#match(). |
| 3339 | |
| 3340 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#name. = _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self)) |
| 3341 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#errmsg. = "Expected " + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#name. |
| 3342 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#mayIndexError. = False |
| 3343 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#mayReturnEmpty. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).re_matchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#re_match.("") is not None |
| 3344 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).asGroupListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#asGroupList. = asGroupListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(asGroupList) |
| 3345 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).asMatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#asMatch. = asMatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(asMatch) |
| 3346 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).asGroupListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#asGroupList.: |
| 3347 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImpl(). = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).parseImplAsGroupListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsGroupList(). |
| 3348 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).asMatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#asMatch.: |
| 3349 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImpl(). = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__init__().(self).parseImplAsMatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsMatch(). |
| 3350 | |
| 3351 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImpl().(doActions)=True): |
| 3352 | result = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImpl().(self).re_matchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#re_match.(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImpl().(loc)) |
| 3353 | if not result: |
| 3354 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImpl().(self)) |
| 3355 | |
| 3356 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImpl().(loc) = result.endscip-python python python-stdlib 3.11 re/Match#end().() |
| 3357 | ret = ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#(result.groupscip-python python python-stdlib 3.11 re/Match#group().()) |
| 3358 | d = result.groupdictscip-python python python-stdlib 3.11 re/Match#groupdict().() |
| 3359 | if d: |
| 3360 | for k, v in d.itemsscip-python python python-stdlib 3.11 builtins/dict#items().(): |
| 3361 | ret[k] = v |
| 3362 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImpl().(loc), ret |
| 3363 | |
| 3364 | def parseImplAsGroupListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsGroupList().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsGroupList().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsGroupList().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsGroupList().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsGroupList().(doActions)=True): |
| 3365 | result = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsGroupList().(self).re_matchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#re_match.(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsGroupList().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsGroupList().(loc)) |
| 3366 | if not result: |
| 3367 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsGroupList().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsGroupList().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsGroupList().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsGroupList().(self)) |
| 3368 | |
| 3369 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsGroupList().(loc) = result.endscip-python python python-stdlib 3.11 re/Match#end().() |
| 3370 | ret = result.groupsscip-python python python-stdlib 3.11 re/Match#groups().() |
| 3371 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsGroupList().(loc), ret |
| 3372 | |
| 3373 | def parseImplAsMatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsMatch().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsMatch().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsMatch().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsMatch().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsMatch().(doActions)=True): |
| 3374 | result = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsMatch().(self).re_matchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#re_match.(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsMatch().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsMatch().(loc)) |
| 3375 | if not result: |
| 3376 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsMatch().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsMatch().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsMatch().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsMatch().(self)) |
| 3377 | |
| 3378 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsMatch().(loc) = result.endscip-python python python-stdlib 3.11 re/Match#end().() |
| 3379 | ret = result |
| 3380 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#parseImplAsMatch().(loc), ret |
| 3381 | |
| 3382 | def __str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__str__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__str__().(self)): |
| 3383 | try: |
| 3384 | return superscip-python python python-stdlib 3.11 builtins/super#(Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__str__().(self)).__str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__str__().() |
| 3385 | except Exceptionscip-python python python-stdlib 3.11 builtins/Exception#: |
| 3386 | pass |
| 3387 | |
| 3388 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#strRepr. is None: |
| 3389 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#strRepr. = "Re:(%s)" % repr(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__str__().(self).patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#pattern.) |
| 3390 | |
| 3391 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#strRepr. |
| 3392 | |
| 3393 | def subscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#sub().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#sub().(self), replscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#sub().(repl)): |
| 3394 | r""" |
| 3395 | Return Regex with an attached parse action to transform the parsed |
| 3396 | result as if called using `re.sub(expr, repl, string) <https://docs.python.org/3/library/re.html#re.sub>`_. |
| 3397 | |
| 3398 | Example:: |
| 3399 | |
| 3400 | make_html = Regex(r"(\w+):(.*?):").sub(r"<\1>\2</\1>") |
| 3401 | print(make_html.transformString("h1:main title:")) |
| 3402 | # prints "<h1>main title</h1>" |
| 3403 | """ |
| 3404 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#sub().(self).asGroupListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#asGroupList.: |
| 3405 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("cannot use sub() with Regex(asGroupList=True)", |
| 3406 | SyntaxWarningscip-python python python-stdlib 3.11 builtins/SyntaxWarning#, stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 3407 | raise SyntaxErrorscip-python python python-stdlib 3.11 builtins/SyntaxError#() |
| 3408 | |
| 3409 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#sub().(self).asMatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#asMatch. and callable(replscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#sub().(repl)): |
| 3410 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("cannot use sub() with a callable with Regex(asMatch=True)", |
| 3411 | SyntaxWarningscip-python python python-stdlib 3.11 builtins/SyntaxWarning#, stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 3412 | raise SyntaxErrorscip-python python python-stdlib 3.11 builtins/SyntaxError#() |
| 3413 | |
| 3414 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#sub().(self).asMatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#asMatch.: |
| 3415 | def pascip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#pa().(tokensscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#pa().(tokens)): |
| 3416 | return tokensscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#pa().(tokens)[0].expand(replscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#sub().(repl)) |
| 3417 | else: |
| 3418 | def pascip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#pa().(tokensscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#pa().(tokens)): |
| 3419 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#sub().(self).rescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#re..subscip-python python python-stdlib 3.11 re/Pattern#sub().(replscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#sub().(repl), tokensscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#pa().(tokens)[0]) |
| 3420 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#sub().(self).addParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addParseAction().(pascip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#pa().) |
| 3421 | |
| 3422 | class QuotedStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#(Tokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#): |
| 3423 | r""" |
| 3424 | Token for matching strings that are delimited by quoting characters. |
| 3425 | |
| 3426 | Defined with the following parameters: |
| 3427 | |
| 3428 | - quoteChar - string of one or more characters defining the |
| 3429 | quote delimiting string |
| 3430 | - escChar - character to escape quotes, typically backslash |
| 3431 | (default= ``None``) |
| 3432 | - escQuote - special quote sequence to escape an embedded quote |
| 3433 | string (such as SQL's ``""`` to escape an embedded ``"``) |
| 3434 | (default= ``None``) |
| 3435 | - multiline - boolean indicating whether quotes can span |
| 3436 | multiple lines (default= ``False``) |
| 3437 | - unquoteResults - boolean indicating whether the matched text |
| 3438 | should be unquoted (default= ``True``) |
| 3439 | - endQuoteChar - string of one or more characters defining the |
| 3440 | end of the quote delimited string (default= ``None`` => same as |
| 3441 | quoteChar) |
| 3442 | - convertWhitespaceEscapes - convert escaped whitespace |
| 3443 | (``'\t'``, ``'\n'``, etc.) to actual whitespace |
| 3444 | (default= ``True``) |
| 3445 | |
| 3446 | Example:: |
| 3447 | |
| 3448 | qs = QuotedString('"') |
| 3449 | print(qs.searchString('lsjdf "This is the quote" sldjf')) |
| 3450 | complex_qs = QuotedString('{{', endQuoteChar='}}') |
| 3451 | print(complex_qs.searchString('lsjdf {{This is the "quote"}} sldjf')) |
| 3452 | sql_qs = QuotedString('"', escQuote='""') |
| 3453 | print(sql_qs.searchString('lsjdf "This is the quote with ""embedded"" quotes" sldjf')) |
| 3454 | |
| 3455 | prints:: |
| 3456 | |
| 3457 | [['This is the quote']] |
| 3458 | [['This is the "quote"']] |
| 3459 | [['This is the quote with "embedded" quotes']] |
| 3460 | """ |
| 3461 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self), quoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(quoteChar), escCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(escChar)=None, escQuotescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(escQuote)=None, multilinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(multiline)=False, |
| 3462 | unquoteResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(unquoteResults)=True, endQuoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(endQuoteChar)=None, convertWhitespaceEscapesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(convertWhitespaceEscapes)=True): |
| 3463 | superscip-python python python-stdlib 3.11 builtins/super#(QuotedStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#__init__().() |
| 3464 | |
| 3465 | # remove white space from quote chars - won't work anyway |
| 3466 | quoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(quoteChar) = quoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(quoteChar).strip() |
| 3467 | if not quoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(quoteChar): |
| 3468 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("quoteChar cannot be the empty string", SyntaxWarningscip-python python python-stdlib 3.11 builtins/SyntaxWarning#, stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 3469 | raise SyntaxErrorscip-python python python-stdlib 3.11 builtins/SyntaxError#() |
| 3470 | |
| 3471 | if endQuoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(endQuoteChar) is None: |
| 3472 | endQuoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(endQuoteChar) = quoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(quoteChar) |
| 3473 | else: |
| 3474 | endQuoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(endQuoteChar) = endQuoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(endQuoteChar).strip() |
| 3475 | if not endQuoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(endQuoteChar): |
| 3476 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("endQuoteChar cannot be the empty string", SyntaxWarningscip-python python python-stdlib 3.11 builtins/SyntaxWarning#, stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 3477 | raise SyntaxErrorscip-python python python-stdlib 3.11 builtins/SyntaxError#() |
| 3478 | |
| 3479 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).quoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#quoteChar. = quoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(quoteChar) |
| 3480 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).quoteCharLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#quoteCharLen. = len(quoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(quoteChar)) |
| 3481 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).firstQuoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#firstQuoteChar. = quoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(quoteChar)[0] |
| 3482 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).endQuoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#endQuoteChar. = endQuoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(endQuoteChar) |
| 3483 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).endQuoteCharLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#endQuoteCharLen. = len(endQuoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(endQuoteChar)) |
| 3484 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).escCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#escChar. = escCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(escChar) |
| 3485 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).escQuotescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#escQuote. = escQuotescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(escQuote) |
| 3486 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).unquoteResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#unquoteResults. = unquoteResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(unquoteResults) |
| 3487 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).convertWhitespaceEscapesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#convertWhitespaceEscapes. = convertWhitespaceEscapesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(convertWhitespaceEscapes) |
| 3488 | |
| 3489 | if multilinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(multiline): |
| 3490 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).flagsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#flags. = rescip-python python python-stdlib 3.11 re/__init__:.MULTILINEscip-python python python-stdlib 3.11 re/MULTILINE. | rescip-python python python-stdlib 3.11 re/__init__:.DOTALLscip-python python python-stdlib 3.11 re/DOTALL. |
| 3491 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#pattern. = r'%s(?:[^%s%s]' % (rescip-python python python-stdlib 3.11 re/__init__:.escapescip-python python python-stdlib 3.11 re/escape().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).quoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#quoteChar.), |
| 3492 | _escapeRegexRangeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapeRegexRangeChars().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).endQuoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#endQuoteChar.[0]), |
| 3493 | (escCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(escChar) is not None and _escapeRegexRangeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapeRegexRangeChars().(escCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(escChar)) or '')) |
| 3494 | else: |
| 3495 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).flagsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#flags. = 0 |
| 3496 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#pattern. = r'%s(?:[^%s\n\r%s]' % (rescip-python python python-stdlib 3.11 re/__init__:.escapescip-python python python-stdlib 3.11 re/escape().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).quoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#quoteChar.), |
| 3497 | _escapeRegexRangeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapeRegexRangeChars().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).endQuoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#endQuoteChar.[0]), |
| 3498 | (escCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(escChar) is not None and _escapeRegexRangeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapeRegexRangeChars().(escCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(escChar)) or '')) |
| 3499 | if len(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).endQuoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#endQuoteChar.) > 1: |
| 3500 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#pattern. += ( |
| 3501 | '|(?:' + ')|(?:'.joinscip-python python python-stdlib 3.11 builtins/str#join().("%s[^%s]" % (rescip-python python python-stdlib 3.11 re/__init__:.escapescip-python python python-stdlib 3.11 re/escape().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).endQuoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#endQuoteChar.[:i]), |
| 3502 | _escapeRegexRangeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapeRegexRangeChars().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).endQuoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#endQuoteChar.[i])) |
| 3503 | for i in rangescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/range.(len(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).endQuoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#endQuoteChar.) - 1, 0, -1)) + ')') |
| 3504 | |
| 3505 | if escQuotescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(escQuote): |
| 3506 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#pattern. += (r'|(?:%s)' % rescip-python python python-stdlib 3.11 re/__init__:.escapescip-python python python-stdlib 3.11 re/escape().(escQuotescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(escQuote))) |
| 3507 | if escCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(escChar): |
| 3508 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#pattern. += (r'|(?:%s.)' % rescip-python python python-stdlib 3.11 re/__init__:.escapescip-python python python-stdlib 3.11 re/escape().(escCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(escChar))) |
| 3509 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).escCharReplacePatternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#escCharReplacePattern. = rescip-python python python-stdlib 3.11 re/__init__:.escapescip-python python python-stdlib 3.11 re/escape().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).escCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#escChar.) + "(.)" |
| 3510 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#pattern. += (r')*%s' % rescip-python python python-stdlib 3.11 re/__init__:.escapescip-python python python-stdlib 3.11 re/escape().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).endQuoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#endQuoteChar.)) |
| 3511 | |
| 3512 | try: |
| 3513 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).rescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#re. = rescip-python python python-stdlib 3.11 re/__init__:.compilescip-python python python-stdlib 3.11 re/compile().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#pattern., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).flagsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#flags.) |
| 3514 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).reStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#reString. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#pattern. |
| 3515 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).re_matchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#re_match. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).rescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#re..matchscip-python python python-stdlib 3.11 re/Pattern#match(). |
| 3516 | except sre_constantsscip-python python python-stdlib 3.11 sre_constants/__init__:.errorscip-python python gavodachs 2.13 sre_constants/error#: |
| 3517 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("invalid pattern (%s) passed to Regex" % selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).patternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#pattern., |
| 3518 | SyntaxWarningscip-python python python-stdlib 3.11 builtins/SyntaxWarning#, stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 3519 | raise |
| 3520 | |
| 3521 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#name. = _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self)) |
| 3522 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#errmsg. = "Expected " + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#name. |
| 3523 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#mayIndexError. = False |
| 3524 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#mayReturnEmpty. = True |
| 3525 | |
| 3526 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(doActions)=True): |
| 3527 | result = instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(loc)] == selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(self).firstQuoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#firstQuoteChar. and selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(self).re_matchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#re_match.(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(loc)) or None |
| 3528 | if not result: |
| 3529 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(self)) |
| 3530 | |
| 3531 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(loc) = result.end() |
| 3532 | ret = result.group() |
| 3533 | |
| 3534 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(self).unquoteResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#unquoteResults.: |
| 3535 | |
| 3536 | # strip off quotes |
| 3537 | ret = ret[selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(self).quoteCharLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#quoteCharLen.: -selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(self).endQuoteCharLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#endQuoteCharLen.] |
| 3538 | |
| 3539 | if isinstance(ret, basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 3540 | # replace escaped whitespace |
| 3541 | if '\\' in ret and selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(self).convertWhitespaceEscapesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#convertWhitespaceEscapes.: |
| 3542 | ws_map = { |
| 3543 | r'\t': '\t', |
| 3544 | r'\n': '\n', |
| 3545 | r'\f': '\f', |
| 3546 | r'\r': '\r', |
| 3547 | } |
| 3548 | for wslit, wschar in ws_map.itemsscip-python python python-stdlib 3.11 builtins/dict#items().(): |
| 3549 | ret = ret.replacescip-python python python-stdlib 3.11 builtins/str#replace().(wslit, wschar) |
| 3550 | |
| 3551 | # replace escaped characters |
| 3552 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(self).escCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#escChar.: |
| 3553 | ret = rescip-python python python-stdlib 3.11 re/__init__:.subscip-python python python-stdlib 3.11 re/sub().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(self).escCharReplacePatternscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#escCharReplacePattern., r"\g<1>", ret) |
| 3554 | |
| 3555 | # replace escaped quotes |
| 3556 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(self).escQuotescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#escQuote.: |
| 3557 | ret = ret.replacescip-python python python-stdlib 3.11 builtins/str#replace().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(self).escQuotescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#escQuote., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(self).endQuoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#endQuoteChar.) |
| 3558 | |
| 3559 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#parseImpl().(loc), ret |
| 3560 | |
| 3561 | def __str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__str__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__str__().(self)): |
| 3562 | try: |
| 3563 | return superscip-python python python-stdlib 3.11 builtins/super#(QuotedStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__str__().(self)).__str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__str__().() |
| 3564 | except Exceptionscip-python python python-stdlib 3.11 builtins/Exception#: |
| 3565 | pass |
| 3566 | |
| 3567 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#strRepr. is None: |
| 3568 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#strRepr. = "quoted string, starting with %s ending with %s" % (selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__str__().(self).quoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#quoteChar., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__str__().(self).endQuoteCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#endQuoteChar.) |
| 3569 | |
| 3570 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/QuotedString#strRepr. |
| 3571 | |
| 3572 | |
| 3573 | class CharsNotInscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#(Tokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#): |
| 3574 | """Token for matching words composed of characters *not* in a given |
| 3575 | set (will include whitespace in matched characters if not listed in |
| 3576 | the provided exclusion set - see example). Defined with string |
| 3577 | containing all disallowed characters, and an optional minimum, |
| 3578 | maximum, and/or exact length. The default value for ``min`` is |
| 3579 | 1 (a minimum value < 1 is not valid); the default values for |
| 3580 | ``max`` and ``exact`` are 0, meaning no maximum or exact |
| 3581 | length restriction. |
| 3582 | |
| 3583 | Example:: |
| 3584 | |
| 3585 | # define a comma-separated-value as anything that is not a ',' |
| 3586 | csv_value = CharsNotIn(',') |
| 3587 | print(delimitedList(csv_value).parseString("dkls,lsdkjf,s12 34,@!#,213")) |
| 3588 | |
| 3589 | prints:: |
| 3590 | |
| 3591 | ['dkls', 'lsdkjf', 's12 34', '@!#', '213'] |
| 3592 | """ |
| 3593 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(self), notCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(notChars), minscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(min)=1, maxscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(max)=0, exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(exact)=0): |
| 3594 | superscip-python python python-stdlib 3.11 builtins/super#(CharsNotInscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#__init__().() |
| 3595 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(self).skipWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#skipWhitespace. = False |
| 3596 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(self).notCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#notChars. = notCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(notChars) |
| 3597 | |
| 3598 | if minscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(min) < 1: |
| 3599 | raise ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#("cannot specify a minimum length < 1; use " |
| 3600 | "Optional(CharsNotIn()) if zero-length char group is permitted") |
| 3601 | |
| 3602 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(self).minLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#minLen. = minscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(min) |
| 3603 | |
| 3604 | if maxscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(max) > 0: |
| 3605 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(self).maxLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#maxLen. = maxscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(max) |
| 3606 | else: |
| 3607 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(self).maxLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#maxLen. = _MAX_INTscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MAX_INT. |
| 3608 | |
| 3609 | if exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(exact) > 0: |
| 3610 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(self).maxLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#maxLen. = exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(exact) |
| 3611 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(self).minLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#minLen. = exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(exact) |
| 3612 | |
| 3613 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#name. = _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(self)) |
| 3614 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#errmsg. = "Expected " + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#name. |
| 3615 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#mayReturnEmpty. = (selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(self).minLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#minLen. == 0) |
| 3616 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(self).mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#mayIndexError. = False |
| 3617 | |
| 3618 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(doActions)=True): |
| 3619 | if instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(loc)] in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(self).notCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#notChars.: |
| 3620 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(self)) |
| 3621 | |
| 3622 | start = locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(loc) |
| 3623 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(loc) += 1 |
| 3624 | notchars = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(self).notCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#notChars. |
| 3625 | maxlen = minscip-python python python-stdlib 3.11 builtins/min().(start + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(self).maxLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#maxLen., len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(instring))) |
| 3626 | while locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(loc) < maxlen and instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(loc)] not in notchars: |
| 3627 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(loc) += 1 |
| 3628 | |
| 3629 | if locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(loc) - start < selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(self).minLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#minLen.: |
| 3630 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(self)) |
| 3631 | |
| 3632 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(loc), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(instring)[start:locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#parseImpl().(loc)] |
| 3633 | |
| 3634 | def __str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__str__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__str__().(self)): |
| 3635 | try: |
| 3636 | return superscip-python python python-stdlib 3.11 builtins/super#(CharsNotInscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__str__().(self)).__str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__str__().() |
| 3637 | except Exceptionscip-python python python-stdlib 3.11 builtins/Exception#: |
| 3638 | pass |
| 3639 | |
| 3640 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#strRepr. is None: |
| 3641 | if len(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__str__().(self).notCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#notChars.) > 4: |
| 3642 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#strRepr. = "!W:(%s...)" % selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__str__().(self).notCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#notChars.[:4] |
| 3643 | else: |
| 3644 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#strRepr. = "!W:(%s)" % selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__str__().(self).notCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#notChars. |
| 3645 | |
| 3646 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#strRepr. |
| 3647 | |
| 3648 | class Whitescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#(Tokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#): |
| 3649 | """Special matching class for matching whitespace. Normally, |
| 3650 | whitespace is ignored by pyparsing grammars. This class is included |
| 3651 | when some whitespace structures are significant. Define with |
| 3652 | a string containing the whitespace characters to be matched; default |
| 3653 | is ``" \\t\\r\\n"``. Also takes optional ``min``, |
| 3654 | ``max``, and ``exact`` arguments, as defined for the |
| 3655 | :class:`Word` class. |
| 3656 | """ |
| 3657 | whiteStrsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#whiteStrs. = { |
| 3658 | ' ' : '<SP>', |
| 3659 | '\t': '<TAB>', |
| 3660 | '\n': '<LF>', |
| 3661 | '\r': '<CR>', |
| 3662 | '\f': '<FF>', |
| 3663 | u'\u00A0': '<NBSP>', |
| 3664 | u'\u1680': '<OGHAM_SPACE_MARK>', |
| 3665 | u'\u180E': '<MONGOLIAN_VOWEL_SEPARATOR>', |
| 3666 | u'\u2000': '<EN_QUAD>', |
| 3667 | u'\u2001': '<EM_QUAD>', |
| 3668 | u'\u2002': '<EN_SPACE>', |
| 3669 | u'\u2003': '<EM_SPACE>', |
| 3670 | u'\u2004': '<THREE-PER-EM_SPACE>', |
| 3671 | u'\u2005': '<FOUR-PER-EM_SPACE>', |
| 3672 | u'\u2006': '<SIX-PER-EM_SPACE>', |
| 3673 | u'\u2007': '<FIGURE_SPACE>', |
| 3674 | u'\u2008': '<PUNCTUATION_SPACE>', |
| 3675 | u'\u2009': '<THIN_SPACE>', |
| 3676 | u'\u200A': '<HAIR_SPACE>', |
| 3677 | u'\u200B': '<ZERO_WIDTH_SPACE>', |
| 3678 | u'\u202F': '<NNBSP>', |
| 3679 | u'\u205F': '<MMSP>', |
| 3680 | u'\u3000': '<IDEOGRAPHIC_SPACE>', |
| 3681 | } |
| 3682 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(self), wsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(ws)=" \t\r\n", minscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(min)=1, maxscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(max)=0, exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(exact)=0): |
| 3683 | superscip-python python python-stdlib 3.11 builtins/super#(Whitescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#__init__().() |
| 3684 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(self).matchWhitescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#matchWhite. = wsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(ws) |
| 3685 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(self).setWhitespaceCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setWhitespaceChars().("".joinscip-python python python-stdlib 3.11 builtins/str#join().(c for c in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(self).whiteCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#whiteChars. if c not in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(self).matchWhitescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#matchWhite.)) |
| 3686 | # ~ self.leaveWhitespace() |
| 3687 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#name. = ("".joinscip-python python python-stdlib 3.11 builtins/str#join().(Whitescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#.whiteStrsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#whiteStrs.[c] for c in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(self).matchWhitescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#matchWhite.)) |
| 3688 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#mayReturnEmpty. = True |
| 3689 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#errmsg. = "Expected " + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#name. |
| 3690 | |
| 3691 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(self).minLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#minLen. = minscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(min) |
| 3692 | |
| 3693 | if maxscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(max) > 0: |
| 3694 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(self).maxLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#maxLen. = maxscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(max) |
| 3695 | else: |
| 3696 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(self).maxLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#maxLen. = _MAX_INTscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MAX_INT. |
| 3697 | |
| 3698 | if exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(exact) > 0: |
| 3699 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(self).maxLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#maxLen. = exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(exact) |
| 3700 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(self).minLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#minLen. = exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#__init__().(exact) |
| 3701 | |
| 3702 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(doActions)=True): |
| 3703 | if instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(loc)] not in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(self).matchWhitescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#matchWhite.: |
| 3704 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(self)) |
| 3705 | start = locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(loc) |
| 3706 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(loc) += 1 |
| 3707 | maxloc = start + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(self).maxLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#maxLen. |
| 3708 | maxloc = minscip-python python python-stdlib 3.11 builtins/min().(maxloc, len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(instring))) |
| 3709 | while locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(loc) < maxloc and instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(loc)] in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(self).matchWhitescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#matchWhite.: |
| 3710 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(loc) += 1 |
| 3711 | |
| 3712 | if locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(loc) - start < selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(self).minLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#minLen.: |
| 3713 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(self)) |
| 3714 | |
| 3715 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(loc), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(instring)[start:locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#parseImpl().(loc)] |
| 3716 | |
| 3717 | |
| 3718 | class _PositionTokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#(Tokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#): |
| 3719 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#__init__().(self)): |
| 3720 | superscip-python python python-stdlib 3.11 builtins/super#(_PositionTokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#__init__().() |
| 3721 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#name. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#__init__().(self).__class__scip-python python python-stdlib 3.11 builtins/object#__class__()..__name__scip-python python python-stdlib 3.11 builtins/__name__# |
| 3722 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#mayReturnEmpty. = True |
| 3723 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#__init__().(self).mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#mayIndexError. = False |
| 3724 | |
| 3725 | class GoToColumnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#(_PositionTokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#): |
| 3726 | """Token to advance to a specific column of input text; useful for |
| 3727 | tabular report scraping. |
| 3728 | """ |
| 3729 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#__init__().(self), colnoscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#__init__().(colno)): |
| 3730 | superscip-python python python-stdlib 3.11 builtins/super#(GoToColumnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#__init__().() |
| 3731 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#__init__().(self).colscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#col. = colnoscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#__init__().(colno) |
| 3732 | |
| 3733 | def preParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#preParse().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#preParse().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#preParse().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#preParse().(loc)): |
| 3734 | if colscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/col().(locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#preParse().(loc), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#preParse().(instring)) != selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#preParse().(self).colscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#col.: |
| 3735 | instrlen = len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#preParse().(instring)) |
| 3736 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#preParse().(self).ignoreExprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignoreExprs.: |
| 3737 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#preParse().(loc) = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#preParse().(self)._skipIgnorablesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_skipIgnorables().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#preParse().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#preParse().(loc)) |
| 3738 | while locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#preParse().(loc) < instrlen and instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#preParse().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#preParse().(loc)].isspace() and colscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/col().(locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#preParse().(loc), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#preParse().(instring)) != selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#preParse().(self).colscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#col.: |
| 3739 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#preParse().(loc) += 1 |
| 3740 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#preParse().(loc) |
| 3741 | |
| 3742 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#parseImpl().(doActions)=True): |
| 3743 | thiscol = colscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/col().(locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#parseImpl().(loc), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#parseImpl().(instring)) |
| 3744 | if thiscol > selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#parseImpl().(self).colscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#col.: |
| 3745 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#parseImpl().(loc), "Text not in expected column", selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#parseImpl().(self)) |
| 3746 | newloc = locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#parseImpl().(loc) + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#parseImpl().(self).colscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#col. - thiscol |
| 3747 | ret = instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/GoToColumn#parseImpl().(loc): newloc] |
| 3748 | return newloc, ret |
| 3749 | |
| 3750 | |
| 3751 | class LineStartscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineStart#(_PositionTokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#): |
| 3752 | r"""Matches if current position is at the beginning of a line within |
| 3753 | the parse string |
| 3754 | |
| 3755 | Example:: |
| 3756 | |
| 3757 | test = '''\ |
| 3758 | AAA this line |
| 3759 | AAA and this line |
| 3760 | AAA but not this one |
| 3761 | B AAA and definitely not this one |
| 3762 | ''' |
| 3763 | |
| 3764 | for t in (LineStart() + 'AAA' + restOfLine).searchString(test): |
| 3765 | print(t) |
| 3766 | |
| 3767 | prints:: |
| 3768 | |
| 3769 | ['AAA', ' this line'] |
| 3770 | ['AAA', ' and this line'] |
| 3771 | |
| 3772 | """ |
| 3773 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineStart#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineStart#__init__().(self)): |
| 3774 | superscip-python python python-stdlib 3.11 builtins/super#(LineStartscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineStart#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineStart#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#__init__().() |
| 3775 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineStart#__init__().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineStart#errmsg. = "Expected start of line" |
| 3776 | |
| 3777 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineStart#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineStart#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineStart#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineStart#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineStart#parseImpl().(doActions)=True): |
| 3778 | if colscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/col().(locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineStart#parseImpl().(loc), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineStart#parseImpl().(instring)) == 1: |
| 3779 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineStart#parseImpl().(loc), [] |
| 3780 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineStart#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineStart#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineStart#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineStart#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineStart#parseImpl().(self)) |
| 3781 | |
| 3782 | class LineEndscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#(_PositionTokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#): |
| 3783 | """Matches if current position is at the end of a line within the |
| 3784 | parse string |
| 3785 | """ |
| 3786 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#__init__().(self)): |
| 3787 | superscip-python python python-stdlib 3.11 builtins/super#(LineEndscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#__init__().() |
| 3788 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#__init__().(self).setWhitespaceCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setWhitespaceChars().(ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.DEFAULT_WHITE_CHARSscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#DEFAULT_WHITE_CHARS..replacescip-python python python-stdlib 3.11 builtins/str#replace().("\n", "")) |
| 3789 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#__init__().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#errmsg. = "Expected end of line" |
| 3790 | |
| 3791 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#parseImpl().(doActions)=True): |
| 3792 | if locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#parseImpl().(loc) < len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#parseImpl().(instring)): |
| 3793 | if instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#parseImpl().(loc)] == "\n": |
| 3794 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#parseImpl().(loc) + 1, "\n" |
| 3795 | else: |
| 3796 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#parseImpl().(self)) |
| 3797 | elif locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#parseImpl().(loc) == len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#parseImpl().(instring)): |
| 3798 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#parseImpl().(loc) + 1, [] |
| 3799 | else: |
| 3800 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#parseImpl().(self)) |
| 3801 | |
| 3802 | class StringStartscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#(_PositionTokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#): |
| 3803 | """Matches if current position is at the beginning of the parse |
| 3804 | string |
| 3805 | """ |
| 3806 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#__init__().(self)): |
| 3807 | superscip-python python python-stdlib 3.11 builtins/super#(StringStartscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#__init__().() |
| 3808 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#__init__().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#errmsg. = "Expected start of text" |
| 3809 | |
| 3810 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#parseImpl().(doActions)=True): |
| 3811 | if locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#parseImpl().(loc) != 0: |
| 3812 | # see if entire string up to here is just whitespace and ignoreables |
| 3813 | if locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#parseImpl().(loc) != selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#parseImpl().(self).preParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#preParse().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#parseImpl().(instring), 0): |
| 3814 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#parseImpl().(self)) |
| 3815 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#parseImpl().(loc), [] |
| 3816 | |
| 3817 | class StringEndscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#(_PositionTokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#): |
| 3818 | """Matches if current position is at the end of the parse string |
| 3819 | """ |
| 3820 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#__init__().(self)): |
| 3821 | superscip-python python python-stdlib 3.11 builtins/super#(StringEndscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#__init__().() |
| 3822 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#__init__().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#errmsg. = "Expected end of text" |
| 3823 | |
| 3824 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#parseImpl().(doActions)=True): |
| 3825 | if locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#parseImpl().(loc) < len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#parseImpl().(instring)): |
| 3826 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#parseImpl().(self)) |
| 3827 | elif locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#parseImpl().(loc) == len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#parseImpl().(instring)): |
| 3828 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#parseImpl().(loc) + 1, [] |
| 3829 | elif locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#parseImpl().(loc) > len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#parseImpl().(instring)): |
| 3830 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#parseImpl().(loc), [] |
| 3831 | else: |
| 3832 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#parseImpl().(self)) |
| 3833 | |
| 3834 | class WordStartscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#(_PositionTokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#): |
| 3835 | """Matches if the current position is at the beginning of a Word, |
| 3836 | and is not preceded by any character in a given set of |
| 3837 | ``wordChars`` (default= ``printables``). To emulate the |
| 3838 | ``\b`` behavior of regular expressions, use |
| 3839 | ``WordStart(alphanums)``. ``WordStart`` will also match at |
| 3840 | the beginning of the string being parsed, or at the beginning of |
| 3841 | a line. |
| 3842 | """ |
| 3843 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#__init__().(self), wordCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#__init__().(wordChars)=printablesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/printables.): |
| 3844 | superscip-python python python-stdlib 3.11 builtins/super#(WordStartscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#__init__().() |
| 3845 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#__init__().(self).wordCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#wordChars. = setscip-python python python-stdlib 3.11 builtins/set#(wordCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#__init__().(wordChars)) |
| 3846 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#__init__().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#errmsg. = "Not at the start of a word" |
| 3847 | |
| 3848 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#parseImpl().(doActions)=True): |
| 3849 | if locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#parseImpl().(loc) != 0: |
| 3850 | if (instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#parseImpl().(loc) - 1] in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#parseImpl().(self).wordCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#wordChars. |
| 3851 | or instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#parseImpl().(loc)] not in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#parseImpl().(self).wordCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#wordChars.): |
| 3852 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#parseImpl().(self)) |
| 3853 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordStart#parseImpl().(loc), [] |
| 3854 | |
| 3855 | class WordEndscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#(_PositionTokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#): |
| 3856 | """Matches if the current position is at the end of a Word, and is |
| 3857 | not followed by any character in a given set of ``wordChars`` |
| 3858 | (default= ``printables``). To emulate the ``\b`` behavior of |
| 3859 | regular expressions, use ``WordEnd(alphanums)``. ``WordEnd`` |
| 3860 | will also match at the end of the string being parsed, or at the end |
| 3861 | of a line. |
| 3862 | """ |
| 3863 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#__init__().(self), wordCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#__init__().(wordChars)=printablesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/printables.): |
| 3864 | superscip-python python python-stdlib 3.11 builtins/super#(WordEndscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#__init__().() |
| 3865 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#__init__().(self).wordCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#wordChars. = setscip-python python python-stdlib 3.11 builtins/set#(wordCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#__init__().(wordChars)) |
| 3866 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#__init__().(self).skipWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#skipWhitespace. = False |
| 3867 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#__init__().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#errmsg. = "Not at the end of a word" |
| 3868 | |
| 3869 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#parseImpl().(doActions)=True): |
| 3870 | instrlen = len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#parseImpl().(instring)) |
| 3871 | if instrlen > 0 and locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#parseImpl().(loc) < instrlen: |
| 3872 | if (instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#parseImpl().(loc)] in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#parseImpl().(self).wordCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#wordChars. or |
| 3873 | instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#parseImpl().(instring)[locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#parseImpl().(loc) - 1] not in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#parseImpl().(self).wordCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#wordChars.): |
| 3874 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#parseImpl().(self)) |
| 3875 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/WordEnd#parseImpl().(loc), [] |
| 3876 | |
| 3877 | |
| 3878 | class ParseExpressionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#(ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#): |
| 3879 | """Abstract subclass of ParserElement, for combining and |
| 3880 | post-processing parsed tokens. |
| 3881 | """ |
| 3882 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(self), exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(exprs), savelistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(savelist)=False): |
| 3883 | superscip-python python python-stdlib 3.11 builtins/super#(ParseExpressionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(savelistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(savelist)) |
| 3884 | if isinstance(exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(exprs), _generatorTypescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_generatorType.): |
| 3885 | exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(exprs) = listscip-python python python-stdlib 3.11 builtins/list#(exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(exprs)) |
| 3886 | |
| 3887 | if isinstance(exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(exprs), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 3888 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs. = [selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(self)._literalStringClass(exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(exprs))] |
| 3889 | elif isinstance(exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(exprs), ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#): |
| 3890 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs. = [exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(exprs)] |
| 3891 | elif isinstance(exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(exprs), Iterablescip-python python python-stdlib 3.11 typing/Iterable#): |
| 3892 | exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(exprs) = listscip-python python python-stdlib 3.11 builtins/list#(exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(exprs)) |
| 3893 | # if sequence of strings provided, wrap with Literal |
| 3894 | if any(isinstance(expr, basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.) for expr in exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(exprs)): |
| 3895 | exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(exprs) = (selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(self)._literalStringClass(e) if isinstance(e, basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.) else e for e in exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(exprs)) |
| 3896 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs. = listscip-python python python-stdlib 3.11 builtins/list#(exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(exprs)) |
| 3897 | else: |
| 3898 | try: |
| 3899 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs. = listscip-python python python-stdlib 3.11 builtins/list#(exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(exprs)) |
| 3900 | except TypeErrorscip-python python python-stdlib 3.11 builtins/TypeError#: |
| 3901 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs. = [exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(exprs)] |
| 3902 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(self).callPreparsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#callPreparse. = False |
| 3903 | |
| 3904 | def appendscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#append().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#append().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#append().(other)): |
| 3905 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#append().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs..appendscip-python python python-stdlib 3.11 builtins/list#append().(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#append().(other)) |
| 3906 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#append().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#strRepr. = None |
| 3907 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#append().(self) |
| 3908 | |
| 3909 | def leaveWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#leaveWhitespace().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#leaveWhitespace().(self)): |
| 3910 | """Extends ``leaveWhitespace`` defined in base class, and also invokes ``leaveWhitespace`` on |
| 3911 | all contained expressions.""" |
| 3912 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#leaveWhitespace().(self).skipWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#skipWhitespace. = False |
| 3913 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#leaveWhitespace().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs. = [e.copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().() for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#leaveWhitespace().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.] |
| 3914 | for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#leaveWhitespace().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.: |
| 3915 | e.leaveWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#leaveWhitespace().() |
| 3916 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#leaveWhitespace().(self) |
| 3917 | |
| 3918 | def ignorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#ignore().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#ignore().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#ignore().(other)): |
| 3919 | if isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#ignore().(other), Suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#): |
| 3920 | if otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#ignore().(other) not in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#ignore().(self).ignoreExprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignoreExprs.: |
| 3921 | superscip-python python python-stdlib 3.11 builtins/super#(ParseExpressionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#ignore().(self)).ignorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#ignore().(other)) |
| 3922 | for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#ignore().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.: |
| 3923 | e.ignorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#ignore().(self).ignoreExprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignoreExprs.[-1]) |
| 3924 | else: |
| 3925 | superscip-python python python-stdlib 3.11 builtins/super#(ParseExpressionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#ignore().(self)).ignorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#ignore().(other)) |
| 3926 | for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#ignore().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.: |
| 3927 | e.ignorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#ignore().(self).ignoreExprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignoreExprs.[-1]) |
| 3928 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#ignore().(self) |
| 3929 | |
| 3930 | def __str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__str__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__str__().(self)): |
| 3931 | try: |
| 3932 | return superscip-python python python-stdlib 3.11 builtins/super#(ParseExpressionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__str__().(self)).__str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__str__().() |
| 3933 | except Exceptionscip-python python python-stdlib 3.11 builtins/Exception#: |
| 3934 | pass |
| 3935 | |
| 3936 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#strRepr. is None: |
| 3937 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#strRepr. = "%s:(%s)" % (selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__str__().(self).__class__scip-python python python-stdlib 3.11 builtins/object#__class__()..__name__scip-python python python-stdlib 3.11 builtins/__name__#, _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__str__().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.)) |
| 3938 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#strRepr. |
| 3939 | |
| 3940 | def streamlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(self)): |
| 3941 | superscip-python python python-stdlib 3.11 builtins/super#(ParseExpressionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(self)).streamlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#streamline().() |
| 3942 | |
| 3943 | for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.: |
| 3944 | e.streamlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#streamline().() |
| 3945 | |
| 3946 | # collapse nested And's of the form And(And(And(a, b), c), d) to And(a, b, c, d) |
| 3947 | # but only if there are no parse actions or resultsNames on the nested And's |
| 3948 | # (likewise for Or's and MatchFirst's) |
| 3949 | if len(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.) == 2: |
| 3950 | other = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.[0] |
| 3951 | if (isinstance(other, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(self).__class__scip-python python python-stdlib 3.11 builtins/object#__class__().) |
| 3952 | and not other.parseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseAction. |
| 3953 | and other.resultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#resultsName. is None |
| 3954 | and not other.debugscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#debug.): |
| 3955 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs. = other.exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.[:] + [selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.[1]] |
| 3956 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#strRepr. = None |
| 3957 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayReturnEmpty. |= other.mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayReturnEmpty. |
| 3958 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(self).mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayIndexError. |= other.mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayIndexError. |
| 3959 | |
| 3960 | other = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.[-1] |
| 3961 | if (isinstance(other, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(self).__class__scip-python python python-stdlib 3.11 builtins/object#__class__().) |
| 3962 | and not other.parseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseAction. |
| 3963 | and other.resultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#resultsName. is None |
| 3964 | and not other.debugscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#debug.): |
| 3965 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.[:-1] + other.exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.[:] |
| 3966 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#strRepr. = None |
| 3967 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayReturnEmpty. |= other.mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayReturnEmpty. |
| 3968 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(self).mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayIndexError. |= other.mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayIndexError. |
| 3969 | |
| 3970 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#errmsg. = "Expected " + _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(self)) |
| 3971 | |
| 3972 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().(self) |
| 3973 | |
| 3974 | def validatescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#validate().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#validate().(self), validateTracescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#validate().(validateTrace)=None): |
| 3975 | tmp = (validateTracescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#validate().(validateTrace) if validateTracescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#validate().(validateTrace) is not None else [])[:] + [selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#validate().(self)] |
| 3976 | for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#validate().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.: |
| 3977 | e.validatescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#validate().(tmp) |
| 3978 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#validate().(self).checkRecursionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#checkRecursion().([]) |
| 3979 | |
| 3980 | def copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#copy().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#copy().(self)): |
| 3981 | ret = superscip-python python python-stdlib 3.11 builtins/super#(ParseExpressionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#copy().(self)).copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().() |
| 3982 | ret.exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs. = [e.copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().() for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#copy().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.] |
| 3983 | return ret |
| 3984 | |
| 3985 | def _setResultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#_setResultsName().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#_setResultsName().(self), namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#_setResultsName().(name), listAllMatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#_setResultsName().(listAllMatches)=False): |
| 3986 | if __diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__..warn_ungrouped_named_tokens_in_collection: |
| 3987 | for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#_setResultsName().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.: |
| 3988 | if isinstance(e, ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#) and e.resultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#resultsName.: |
| 3989 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("{0}: setting results name {1!r} on {2} expression " |
| 3990 | "collides with {3!r} on contained expression".format("warn_ungrouped_named_tokens_in_collection", |
| 3991 | namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#_setResultsName().(name), |
| 3992 | typescip-python python python-stdlib 3.11 builtins/type#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#_setResultsName().(self)).__name__scip-python python python-stdlib 3.11 builtins/__name__#, |
| 3993 | e.resultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#resultsName.), |
| 3994 | stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=3) |
| 3995 | |
| 3996 | return superscip-python python python-stdlib 3.11 builtins/super#(ParseExpressionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#_setResultsName().(self))._setResultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_setResultsName().(namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#_setResultsName().(name), listAllMatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#_setResultsName().(listAllMatches)) |
| 3997 | |
| 3998 | |
| 3999 | class Andscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#(ParseExpressionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#): |
| 4000 | """ |
| 4001 | Requires all given :class:`ParseExpression` s to be found in the given order. |
| 4002 | Expressions may be separated by whitespace. |
| 4003 | May be constructed using the ``'+'`` operator. |
| 4004 | May also be constructed using the ``'-'`` operator, which will |
| 4005 | suppress backtracking. |
| 4006 | |
| 4007 | Example:: |
| 4008 | |
| 4009 | integer = Word(nums) |
| 4010 | name_expr = OneOrMore(Word(alphas)) |
| 4011 | |
| 4012 | expr = And([integer("id"), name_expr("name"), integer("age")]) |
| 4013 | # more easily written as: |
| 4014 | expr = integer("id") + name_expr("name") + integer("age") |
| 4015 | """ |
| 4016 | |
| 4017 | class _ErrorStopscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#_ErrorStop#(Emptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#): |
| 4018 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#_ErrorStop#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#_ErrorStop#__init__().(self), *argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#_ErrorStop#__init__().(args), **kwargsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#_ErrorStop#__init__().(kwargs)): |
| 4019 | superscip-python python python-stdlib 3.11 builtins/super#(Andscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#._ErrorStopscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#_ErrorStop#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#_ErrorStop#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#__init__().(*argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#_ErrorStop#__init__().(args), **kwargsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#_ErrorStop#__init__().(kwargs)) |
| 4020 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#_ErrorStop#__init__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ErrorStop#name. = '-' |
| 4021 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#_ErrorStop#__init__().(self).leaveWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#leaveWhitespace().() |
| 4022 | |
| 4023 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(self), exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(exprs), savelistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(savelist)=True): |
| 4024 | exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(exprs) = listscip-python python python-stdlib 3.11 builtins/list#(exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(exprs)) |
| 4025 | if exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(exprs) and Ellipsisscip-python python python-stdlib 3.11 builtins/Ellipsis# in exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(exprs): |
| 4026 | tmp = [] |
| 4027 | for i, expr in enumeratescip-python python python-stdlib 3.11 builtins/enumerate#(exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(exprs)): |
| 4028 | if expr is Ellipsisscip-python python python-stdlib 3.11 builtins/Ellipsis#: |
| 4029 | if i < len(exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(exprs)) - 1: |
| 4030 | skipto_arg = (Emptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#() + exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(exprs)[i + 1]).exprs[-1] |
| 4031 | tmp.appendscip-python python python-stdlib 3.11 builtins/list#append().(SkipToscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#(skipto_arg)("_skipped*")) |
| 4032 | else: |
| 4033 | raise Exceptionscip-python python python-stdlib 3.11 builtins/Exception#("cannot construct And with sequence ending in ...") |
| 4034 | else: |
| 4035 | tmp.appendscip-python python python-stdlib 3.11 builtins/list#append().(expr) |
| 4036 | exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(exprs)[:] = tmp |
| 4037 | superscip-python python python-stdlib 3.11 builtins/super#(Andscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(exprs), savelistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(savelist)) |
| 4038 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#mayReturnEmpty. = all(e.mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayReturnEmpty. for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#exprs.) |
| 4039 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(self).setWhitespaceCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setWhitespaceChars().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#exprs.[0].whiteCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#whiteChars.) |
| 4040 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(self).skipWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#skipWhitespace. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#exprs.[0].skipWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#skipWhitespace. |
| 4041 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__init__().(self).callPreparsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#callPreparse. = True |
| 4042 | |
| 4043 | def streamlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#streamline().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#streamline().(self)): |
| 4044 | # collapse any _PendingSkip's |
| 4045 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#streamline().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#exprs.: |
| 4046 | if any(isinstance(e, ParseExpressionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#) and e.exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs. and isinstance(e.exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.[-1], _PendingSkipscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#) |
| 4047 | for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#streamline().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#exprs.[:-1]): |
| 4048 | for i, e in enumeratescip-python python python-stdlib 3.11 builtins/enumerate#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#streamline().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#exprs.[:-1]): |
| 4049 | if e is None: |
| 4050 | continue |
| 4051 | if (isinstance(e, ParseExpressionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#) |
| 4052 | and e.exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs. and isinstance(e.exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.[-1], _PendingSkipscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PendingSkip#)): |
| 4053 | e.exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.[-1] = e.exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.[-1] + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#streamline().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#exprs.[i + 1] |
| 4054 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#streamline().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#exprs.[i + 1] = None |
| 4055 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#streamline().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#exprs. = [e for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#streamline().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#exprs. if e is not None] |
| 4056 | |
| 4057 | superscip-python python python-stdlib 3.11 builtins/super#(Andscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#streamline().(self)).streamlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().() |
| 4058 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#streamline().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#mayReturnEmpty. = all(e.mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayReturnEmpty. for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#streamline().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#exprs.) |
| 4059 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#streamline().(self) |
| 4060 | |
| 4061 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(doActions)=True): |
| 4062 | # pass False as last arg to _parse for first element, since we already |
| 4063 | # pre-parsed the string as part of our And pre-parsing |
| 4064 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(loc), resultlist = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#exprs.[0]._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse.(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(doActions), callPreParse=False) |
| 4065 | errorStop = False |
| 4066 | for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#exprs.[1:]: |
| 4067 | if isinstance(e, Andscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#._ErrorStopscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#_ErrorStop#): |
| 4068 | errorStop = True |
| 4069 | continue |
| 4070 | if errorStop: |
| 4071 | try: |
| 4072 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(loc), exprtokens = e._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse.(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(doActions)) |
| 4073 | except ParseSyntaxExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseSyntaxException#: |
| 4074 | raise |
| 4075 | except ParseBaseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException# as pe: |
| 4076 | pe.__traceback__scip-python python python-stdlib 3.11 builtins/BaseException#__traceback__. = None |
| 4077 | raise ParseSyntaxExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseSyntaxException#._from_exceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#_from_exception().(pe) |
| 4078 | except IndexErrorscip-python python python-stdlib 3.11 builtins/IndexError#: |
| 4079 | raise ParseSyntaxExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseSyntaxException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(instring), len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(instring)), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(self)) |
| 4080 | else: |
| 4081 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(loc), exprtokens = e._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse.(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(doActions)) |
| 4082 | if exprtokens or exprtokens.haskeys(): |
| 4083 | resultlist += exprtokens |
| 4084 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#parseImpl().(loc), resultlist |
| 4085 | |
| 4086 | def __iadd__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__iadd__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__iadd__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__iadd__().(other)): |
| 4087 | if isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__iadd__().(other), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 4088 | otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__iadd__().(other) = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__iadd__().(self)._literalStringClass(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__iadd__().(other)) |
| 4089 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__iadd__().(self).appendscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#append().(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__iadd__().(other)) # And([self, other]) |
| 4090 | |
| 4091 | def checkRecursionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#checkRecursion().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#checkRecursion().(self), parseElementListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#checkRecursion().(parseElementList)): |
| 4092 | subRecCheckList = parseElementListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#checkRecursion().(parseElementList)[:] + [selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#checkRecursion().(self)] |
| 4093 | for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#checkRecursion().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#exprs.: |
| 4094 | e.checkRecursionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#checkRecursion().(subRecCheckList) |
| 4095 | if not e.mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayReturnEmpty.: |
| 4096 | break |
| 4097 | |
| 4098 | def __str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__str__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__str__().(self)): |
| 4099 | if hasattr(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__str__().(self), "name"): |
| 4100 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__str__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#name. |
| 4101 | |
| 4102 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#strRepr. is None: |
| 4103 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#strRepr. = "{" + " ".joinscip-python python python-stdlib 3.11 builtins/str#join().(_ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(e) for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__str__().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#exprs.) + "}" |
| 4104 | |
| 4105 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#strRepr. |
| 4106 | |
| 4107 | |
| 4108 | class Orscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#(ParseExpressionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#): |
| 4109 | """Requires that at least one :class:`ParseExpression` is found. If |
| 4110 | two expressions match, the expression that matches the longest |
| 4111 | string will be used. May be constructed using the ``'^'`` |
| 4112 | operator. |
| 4113 | |
| 4114 | Example:: |
| 4115 | |
| 4116 | # construct Or using '^' operator |
| 4117 | |
| 4118 | number = Word(nums) ^ Combine(Word(nums) + '.' + Word(nums)) |
| 4119 | print(number.searchString("123 3.1416 789")) |
| 4120 | |
| 4121 | prints:: |
| 4122 | |
| 4123 | [['123'], ['3.1416'], ['789']] |
| 4124 | """ |
| 4125 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__init__().(self), exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__init__().(exprs), savelistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__init__().(savelist)=False): |
| 4126 | superscip-python python python-stdlib 3.11 builtins/super#(Orscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__init__().(exprs), savelistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__init__().(savelist)) |
| 4127 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__init__().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.: |
| 4128 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#mayReturnEmpty. = any(e.mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayReturnEmpty. for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__init__().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.) |
| 4129 | else: |
| 4130 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#mayReturnEmpty. = True |
| 4131 | |
| 4132 | def streamlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#streamline().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#streamline().(self)): |
| 4133 | superscip-python python python-stdlib 3.11 builtins/super#(Orscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#streamline().(self)).streamlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().() |
| 4134 | if __compat__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__compat__..collect_all_And_tokens: |
| 4135 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#streamline().(self).saveAsListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#saveAsList. = any(e.saveAsListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#saveAsList. for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#streamline().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.) |
| 4136 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#streamline().(self) |
| 4137 | |
| 4138 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(doActions)=True): |
| 4139 | maxExcLoc = -1 |
| 4140 | maxException = None |
| 4141 | matches = [] |
| 4142 | for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.: |
| 4143 | try: |
| 4144 | loc2 = e.tryParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#tryParse().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(loc)) |
| 4145 | except ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException# as err: |
| 4146 | err.__traceback__scip-python python python-stdlib 3.11 builtins/BaseException#__traceback__. = None |
| 4147 | if err.locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#loc. > maxExcLoc: |
| 4148 | maxException = err |
| 4149 | maxExcLoc = err.locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#loc. |
| 4150 | except IndexErrorscip-python python python-stdlib 3.11 builtins/IndexError#: |
| 4151 | if len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(instring)) > maxExcLoc: |
| 4152 | maxException = ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(instring), len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(instring)), e.errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(self)) |
| 4153 | maxExcLoc = len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(instring)) |
| 4154 | else: |
| 4155 | # save match among all matches, to retry longest to shortest |
| 4156 | matches.appendscip-python python python-stdlib 3.11 builtins/list#append().((loc2, e)) |
| 4157 | |
| 4158 | if matches: |
| 4159 | # re-evaluate all matches in descending order of length of match, in case attached actions |
| 4160 | # might change whether or how much they match of the input. |
| 4161 | matches.sortscip-python python python-stdlib 3.11 builtins/list#sort().(keyscip-python python python-stdlib 3.11 builtins/list#sort().(key)=itemgetterscip-python python python-stdlib 3.11 _operator/itemgetter#(0), reversescip-python python python-stdlib 3.11 builtins/list#sort().(reverse)=True) |
| 4162 | |
| 4163 | if not doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(doActions): |
| 4164 | # no further conditions or parse actions to change the selection of |
| 4165 | # alternative, so the first match will be the best match |
| 4166 | best_expr = matches[0][1] |
| 4167 | return best_expr._parse(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(doActions)) |
| 4168 | |
| 4169 | longest = -1, None |
| 4170 | for loc1, expr1 in matches: |
| 4171 | if loc1 <= longest[0]: |
| 4172 | # already have a longer match than this one will deliver, we are done |
| 4173 | return longest |
| 4174 | |
| 4175 | try: |
| 4176 | loc2, toks = expr1._parse(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(doActions)) |
| 4177 | except ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException# as err: |
| 4178 | err.__traceback__scip-python python python-stdlib 3.11 builtins/BaseException#__traceback__. = None |
| 4179 | if err.locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#loc. > maxExcLoc: |
| 4180 | maxException = err |
| 4181 | maxExcLoc = err.locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#loc. |
| 4182 | else: |
| 4183 | if loc2 >= loc1: |
| 4184 | return loc2, toks |
| 4185 | # didn't match as much as before |
| 4186 | elif loc2 > longest[0]: |
| 4187 | longest = loc2, toks |
| 4188 | |
| 4189 | if longest != (-1, None): |
| 4190 | return longest |
| 4191 | |
| 4192 | if maxException is not None: |
| 4193 | maxException.msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#msg. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#errmsg. |
| 4194 | raise maxException |
| 4195 | else: |
| 4196 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(loc), "no defined alternatives to match", selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#parseImpl().(self)) |
| 4197 | |
| 4198 | |
| 4199 | def __ixor__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__ixor__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__ixor__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__ixor__().(other)): |
| 4200 | if isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__ixor__().(other), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 4201 | otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__ixor__().(other) = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__ixor__().(self)._literalStringClass(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__ixor__().(other)) |
| 4202 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__ixor__().(self).appendscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#append().(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__ixor__().(other)) # Or([self, other]) |
| 4203 | |
| 4204 | def __str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__str__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__str__().(self)): |
| 4205 | if hasattr(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__str__().(self), "name"): |
| 4206 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__str__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#name. |
| 4207 | |
| 4208 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#strRepr. is None: |
| 4209 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#strRepr. = "{" + " ^ ".joinscip-python python python-stdlib 3.11 builtins/str#join().(_ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(e) for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__str__().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.) + "}" |
| 4210 | |
| 4211 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#strRepr. |
| 4212 | |
| 4213 | def checkRecursionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#checkRecursion().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#checkRecursion().(self), parseElementListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#checkRecursion().(parseElementList)): |
| 4214 | subRecCheckList = parseElementListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#checkRecursion().(parseElementList)[:] + [selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#checkRecursion().(self)] |
| 4215 | for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#checkRecursion().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.: |
| 4216 | e.checkRecursionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#checkRecursion().(subRecCheckList) |
| 4217 | |
| 4218 | def _setResultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#_setResultsName().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#_setResultsName().(self), namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#_setResultsName().(name), listAllMatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#_setResultsName().(listAllMatches)=False): |
| 4219 | if (not __compat__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__compat__..collect_all_And_tokens |
| 4220 | and __diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__..warn_multiple_tokens_in_named_alternation): |
| 4221 | if any(isinstance(e, Andscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#) for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#_setResultsName().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.): |
| 4222 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("{0}: setting results name {1!r} on {2} expression " |
| 4223 | "may only return a single token for an And alternative, " |
| 4224 | "in future will return the full list of tokens".format( |
| 4225 | "warn_multiple_tokens_in_named_alternation", namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#_setResultsName().(name), typescip-python python python-stdlib 3.11 builtins/type#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#_setResultsName().(self)).__name__scip-python python python-stdlib 3.11 builtins/__name__#), |
| 4226 | stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=3) |
| 4227 | |
| 4228 | return superscip-python python python-stdlib 3.11 builtins/super#(Orscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#_setResultsName().(self))._setResultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#_setResultsName().(namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#_setResultsName().(name), listAllMatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Or#_setResultsName().(listAllMatches)) |
| 4229 | |
| 4230 | |
| 4231 | class MatchFirstscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#(ParseExpressionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#): |
| 4232 | """Requires that at least one :class:`ParseExpression` is found. If |
| 4233 | two expressions match, the first one listed is the one that will |
| 4234 | match. May be constructed using the ``'|'`` operator. |
| 4235 | |
| 4236 | Example:: |
| 4237 | |
| 4238 | # construct MatchFirst using '|' operator |
| 4239 | |
| 4240 | # watch the order of expressions to match |
| 4241 | number = Word(nums) | Combine(Word(nums) + '.' + Word(nums)) |
| 4242 | print(number.searchString("123 3.1416 789")) # Fail! -> [['123'], ['3'], ['1416'], ['789']] |
| 4243 | |
| 4244 | # put more selective expression first |
| 4245 | number = Combine(Word(nums) + '.' + Word(nums)) | Word(nums) |
| 4246 | print(number.searchString("123 3.1416 789")) # Better -> [['123'], ['3.1416'], ['789']] |
| 4247 | """ |
| 4248 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__init__().(self), exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__init__().(exprs), savelistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__init__().(savelist)=False): |
| 4249 | superscip-python python python-stdlib 3.11 builtins/super#(MatchFirstscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__init__().(exprs), savelistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__init__().(savelist)) |
| 4250 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__init__().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.: |
| 4251 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#mayReturnEmpty. = any(e.mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayReturnEmpty. for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__init__().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.) |
| 4252 | else: |
| 4253 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#mayReturnEmpty. = True |
| 4254 | |
| 4255 | def streamlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#streamline().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#streamline().(self)): |
| 4256 | superscip-python python python-stdlib 3.11 builtins/super#(MatchFirstscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#streamline().(self)).streamlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().() |
| 4257 | if __compat__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__compat__..collect_all_And_tokens: |
| 4258 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#streamline().(self).saveAsListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#saveAsList. = any(e.saveAsListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#saveAsList. for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#streamline().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.) |
| 4259 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#streamline().(self) |
| 4260 | |
| 4261 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#parseImpl().(doActions)=True): |
| 4262 | maxExcLoc = -1 |
| 4263 | maxException = None |
| 4264 | for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#parseImpl().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.: |
| 4265 | try: |
| 4266 | ret = e._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse.(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#parseImpl().(doActions)) |
| 4267 | return ret |
| 4268 | except ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException# as err: |
| 4269 | if err.locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#loc. > maxExcLoc: |
| 4270 | maxException = err |
| 4271 | maxExcLoc = err.locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#loc. |
| 4272 | except IndexErrorscip-python python python-stdlib 3.11 builtins/IndexError#: |
| 4273 | if len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#parseImpl().(instring)) > maxExcLoc: |
| 4274 | maxException = ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#parseImpl().(instring), len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#parseImpl().(instring)), e.errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#parseImpl().(self)) |
| 4275 | maxExcLoc = len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#parseImpl().(instring)) |
| 4276 | |
| 4277 | # only got here if no expression matched, raise exception for match that made it the furthest |
| 4278 | else: |
| 4279 | if maxException is not None: |
| 4280 | maxException.msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#msg. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#errmsg. |
| 4281 | raise maxException |
| 4282 | else: |
| 4283 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#parseImpl().(loc), "no defined alternatives to match", selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#parseImpl().(self)) |
| 4284 | |
| 4285 | def __ior__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__ior__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__ior__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__ior__().(other)): |
| 4286 | if isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__ior__().(other), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 4287 | otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__ior__().(other) = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__ior__().(self)._literalStringClass(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__ior__().(other)) |
| 4288 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__ior__().(self).appendscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#append().(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__ior__().(other)) # MatchFirst([self, other]) |
| 4289 | |
| 4290 | def __str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__str__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__str__().(self)): |
| 4291 | if hasattr(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__str__().(self), "name"): |
| 4292 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__str__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#name. |
| 4293 | |
| 4294 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#strRepr. is None: |
| 4295 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#strRepr. = "{" + " | ".joinscip-python python python-stdlib 3.11 builtins/str#join().(_ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(e) for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__str__().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.) + "}" |
| 4296 | |
| 4297 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#strRepr. |
| 4298 | |
| 4299 | def checkRecursionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#checkRecursion().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#checkRecursion().(self), parseElementListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#checkRecursion().(parseElementList)): |
| 4300 | subRecCheckList = parseElementListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#checkRecursion().(parseElementList)[:] + [selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#checkRecursion().(self)] |
| 4301 | for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#checkRecursion().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.: |
| 4302 | e.checkRecursionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#checkRecursion().(subRecCheckList) |
| 4303 | |
| 4304 | def _setResultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#_setResultsName().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#_setResultsName().(self), namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#_setResultsName().(name), listAllMatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#_setResultsName().(listAllMatches)=False): |
| 4305 | if (not __compat__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__compat__..collect_all_And_tokens |
| 4306 | and __diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__..warn_multiple_tokens_in_named_alternation): |
| 4307 | if any(isinstance(e, Andscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#) for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#_setResultsName().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.): |
| 4308 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("{0}: setting results name {1!r} on {2} expression " |
| 4309 | "may only return a single token for an And alternative, " |
| 4310 | "in future will return the full list of tokens".format( |
| 4311 | "warn_multiple_tokens_in_named_alternation", namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#_setResultsName().(name), typescip-python python python-stdlib 3.11 builtins/type#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#_setResultsName().(self)).__name__scip-python python python-stdlib 3.11 builtins/__name__#), |
| 4312 | stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=3) |
| 4313 | |
| 4314 | return superscip-python python python-stdlib 3.11 builtins/super#(MatchFirstscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#_setResultsName().(self))._setResultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#_setResultsName().(namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#_setResultsName().(name), listAllMatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#_setResultsName().(listAllMatches)) |
| 4315 | |
| 4316 | |
| 4317 | class Eachscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#(ParseExpressionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#): |
| 4318 | """Requires all given :class:`ParseExpression` s to be found, but in |
| 4319 | any order. Expressions may be separated by whitespace. |
| 4320 | |
| 4321 | May be constructed using the ``'&'`` operator. |
| 4322 | |
| 4323 | Example:: |
| 4324 | |
| 4325 | color = oneOf("RED ORANGE YELLOW GREEN BLUE PURPLE BLACK WHITE BROWN") |
| 4326 | shape_type = oneOf("SQUARE CIRCLE TRIANGLE STAR HEXAGON OCTAGON") |
| 4327 | integer = Word(nums) |
| 4328 | shape_attr = "shape:" + shape_type("shape") |
| 4329 | posn_attr = "posn:" + Group(integer("x") + ',' + integer("y"))("posn") |
| 4330 | color_attr = "color:" + color("color") |
| 4331 | size_attr = "size:" + integer("size") |
| 4332 | |
| 4333 | # use Each (using operator '&') to accept attributes in any order |
| 4334 | # (shape and posn are required, color and size are optional) |
| 4335 | shape_spec = shape_attr & posn_attr & Optional(color_attr) & Optional(size_attr) |
| 4336 | |
| 4337 | shape_spec.runTests(''' |
| 4338 | shape: SQUARE color: BLACK posn: 100, 120 |
| 4339 | shape: CIRCLE size: 50 color: BLUE posn: 50,80 |
| 4340 | color:GREEN size:20 shape:TRIANGLE posn:20,40 |
| 4341 | ''' |
| 4342 | ) |
| 4343 | |
| 4344 | prints:: |
| 4345 | |
| 4346 | shape: SQUARE color: BLACK posn: 100, 120 |
| 4347 | ['shape:', 'SQUARE', 'color:', 'BLACK', 'posn:', ['100', ',', '120']] |
| 4348 | - color: BLACK |
| 4349 | - posn: ['100', ',', '120'] |
| 4350 | - x: 100 |
| 4351 | - y: 120 |
| 4352 | - shape: SQUARE |
| 4353 | |
| 4354 | |
| 4355 | shape: CIRCLE size: 50 color: BLUE posn: 50,80 |
| 4356 | ['shape:', 'CIRCLE', 'size:', '50', 'color:', 'BLUE', 'posn:', ['50', ',', '80']] |
| 4357 | - color: BLUE |
| 4358 | - posn: ['50', ',', '80'] |
| 4359 | - x: 50 |
| 4360 | - y: 80 |
| 4361 | - shape: CIRCLE |
| 4362 | - size: 50 |
| 4363 | |
| 4364 | |
| 4365 | color: GREEN size: 20 shape: TRIANGLE posn: 20,40 |
| 4366 | ['color:', 'GREEN', 'size:', '20', 'shape:', 'TRIANGLE', 'posn:', ['20', ',', '40']] |
| 4367 | - color: GREEN |
| 4368 | - posn: ['20', ',', '40'] |
| 4369 | - x: 20 |
| 4370 | - y: 40 |
| 4371 | - shape: TRIANGLE |
| 4372 | - size: 20 |
| 4373 | """ |
| 4374 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#__init__().(self), exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#__init__().(exprs), savelistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#__init__().(savelist)=True): |
| 4375 | superscip-python python python-stdlib 3.11 builtins/super#(Eachscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#__init__().(exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#__init__().(exprs), savelistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#__init__().(savelist)) |
| 4376 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#mayReturnEmpty. = all(e.mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayReturnEmpty. for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#__init__().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.) |
| 4377 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#__init__().(self).skipWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#skipWhitespace. = True |
| 4378 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#__init__().(self).initExprGroupsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#initExprGroups. = True |
| 4379 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#__init__().(self).saveAsListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#saveAsList. = True |
| 4380 | |
| 4381 | def streamlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#streamline().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#streamline().(self)): |
| 4382 | superscip-python python python-stdlib 3.11 builtins/super#(Eachscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#streamline().(self)).streamlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#streamline().() |
| 4383 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#streamline().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#mayReturnEmpty. = all(e.mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayReturnEmpty. for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#streamline().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.) |
| 4384 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#streamline().(self) |
| 4385 | |
| 4386 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(doActions)=True): |
| 4387 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self).initExprGroupsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#initExprGroups.: |
| 4388 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self).opt1mapscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#opt1map. = dictscip-python python python-stdlib 3.11 builtins/dict#((id(e.exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr.), e) for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs. if isinstance(e, Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#)) |
| 4389 | opt1 = [e.exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr. for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs. if isinstance(e, Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#)] |
| 4390 | opt2 = [e for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs. if e.mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayReturnEmpty. and not isinstance(e, (Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#, Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#))] |
| 4391 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self).optionalsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#optionals. = opt1 + opt2 |
| 4392 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self).multioptionalsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#multioptionals. = [e.exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr. for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs. if isinstance(e, ZeroOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#)] |
| 4393 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self).multirequiredscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#multirequired. = [e.exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr. for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs. if isinstance(e, OneOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#)] |
| 4394 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self).requiredscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#required. = [e for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs. if not isinstance(e, (Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#, ZeroOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#, OneOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#))] |
| 4395 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self).requiredscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#required. += selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self).multirequiredscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#multirequired. |
| 4396 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self).initExprGroupsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#initExprGroups. = False |
| 4397 | tmpLoc = locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(loc) |
| 4398 | tmpReqd = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self).requiredscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#required.[:] |
| 4399 | tmpOpt = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self).optionalsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#optionals.[:] |
| 4400 | matchOrder = [] |
| 4401 | |
| 4402 | keepMatching = True |
| 4403 | while keepMatching: |
| 4404 | tmpExprs = tmpReqd + tmpOpt + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self).multioptionalsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#multioptionals. + selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self).multirequiredscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#multirequired. |
| 4405 | failed = [] |
| 4406 | for e in tmpExprs: |
| 4407 | try: |
| 4408 | tmpLoc = e.tryParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#tryParse().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(instring), tmpLoc) |
| 4409 | except ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#: |
| 4410 | failed.appendscip-python python python-stdlib 3.11 builtins/list#append().(e) |
| 4411 | else: |
| 4412 | matchOrder.appendscip-python python python-stdlib 3.11 builtins/list#append().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self).opt1mapscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#opt1map..getscip-python python python-stdlib 3.11 builtins/dict#get().(id(e), e)) |
| 4413 | if e in tmpReqd: |
| 4414 | tmpReqd.removescip-python python python-stdlib 3.11 builtins/list#remove().(e) |
| 4415 | elif e in tmpOpt: |
| 4416 | tmpOpt.removescip-python python python-stdlib 3.11 builtins/list#remove().(e) |
| 4417 | if len(failed) == len(tmpExprs): |
| 4418 | keepMatching = False |
| 4419 | |
| 4420 | if tmpReqd: |
| 4421 | missing = ", ".joinscip-python python python-stdlib 3.11 builtins/str#join().(_ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(e) for e in tmpReqd) |
| 4422 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(loc), "Missing one or more required elements (%s)" % missing) |
| 4423 | |
| 4424 | # add any unmatched Optionals, in case they have default values defined |
| 4425 | matchOrder += [e for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs. if isinstance(e, Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#) and e.exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr. in tmpOpt] |
| 4426 | |
| 4427 | resultlist = [] |
| 4428 | for e in matchOrder: |
| 4429 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(loc), results = e._parse(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(doActions)) |
| 4430 | resultlist.appendscip-python python python-stdlib 3.11 builtins/list#append().(results) |
| 4431 | |
| 4432 | finalResults = sumscip-python python python-stdlib 3.11 builtins/sum().(resultlist, ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#([])) |
| 4433 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#parseImpl().(loc), finalResults |
| 4434 | |
| 4435 | def __str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#__str__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#__str__().(self)): |
| 4436 | if hasattr(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#__str__().(self), "name"): |
| 4437 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#__str__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#name. |
| 4438 | |
| 4439 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#strRepr. is None: |
| 4440 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#strRepr. = "{" + " & ".joinscip-python python python-stdlib 3.11 builtins/str#join().(_ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(e) for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#__str__().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.) + "}" |
| 4441 | |
| 4442 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#strRepr. |
| 4443 | |
| 4444 | def checkRecursionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#checkRecursion().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#checkRecursion().(self), parseElementListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#checkRecursion().(parseElementList)): |
| 4445 | subRecCheckList = parseElementListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#checkRecursion().(parseElementList)[:] + [selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#checkRecursion().(self)] |
| 4446 | for e in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Each#checkRecursion().(self).exprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseExpression#exprs.: |
| 4447 | e.checkRecursionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#checkRecursion().(subRecCheckList) |
| 4448 | |
| 4449 | |
| 4450 | class ParseElementEnhancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#(ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#): |
| 4451 | """Abstract subclass of :class:`ParserElement`, for combining and |
| 4452 | post-processing parsed tokens. |
| 4453 | """ |
| 4454 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(self), exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(expr), savelistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(savelist)=False): |
| 4455 | superscip-python python python-stdlib 3.11 builtins/super#(ParseElementEnhancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__init__().(savelistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(savelist)) |
| 4456 | if isinstance(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(expr), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 4457 | if issubclass(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(self)._literalStringClass, Tokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Token#): |
| 4458 | exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(expr) = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(self)._literalStringClass(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(expr)) |
| 4459 | else: |
| 4460 | exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(expr) = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(self)._literalStringClass(Literalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(expr))) |
| 4461 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr. = exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(expr) |
| 4462 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#strRepr. = None |
| 4463 | if exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(expr) is not None: |
| 4464 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(self).mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#mayIndexError. = exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(expr).mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayIndexError. |
| 4465 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#mayReturnEmpty. = exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(expr).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#mayReturnEmpty. |
| 4466 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(self).setWhitespaceCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setWhitespaceChars().(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(expr).whiteCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#whiteChars.) |
| 4467 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(self).skipWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#skipWhitespace. = exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(expr).skipWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#skipWhitespace. |
| 4468 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(self).saveAsListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#saveAsList. = exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(expr).saveAsListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#saveAsList. |
| 4469 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(self).callPreparsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#callPreparse. = exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(expr).callPreparsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#callPreparse. |
| 4470 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(self).ignoreExprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignoreExprs..extendscip-python python python-stdlib 3.11 builtins/list#extend().(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(expr).ignoreExprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignoreExprs.) |
| 4471 | |
| 4472 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#parseImpl().(doActions)=True): |
| 4473 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#parseImpl().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr. is not None: |
| 4474 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#parseImpl().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr.._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse.(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#parseImpl().(doActions), callPreParse=False) |
| 4475 | else: |
| 4476 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#("", locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#parseImpl().(self)) |
| 4477 | |
| 4478 | def leaveWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#leaveWhitespace().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#leaveWhitespace().(self)): |
| 4479 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#leaveWhitespace().(self).skipWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#skipWhitespace. = False |
| 4480 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#leaveWhitespace().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#leaveWhitespace().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr..copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().() |
| 4481 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#leaveWhitespace().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr. is not None: |
| 4482 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#leaveWhitespace().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr..leaveWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#leaveWhitespace().() |
| 4483 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#leaveWhitespace().(self) |
| 4484 | |
| 4485 | def ignorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#ignore().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#ignore().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#ignore().(other)): |
| 4486 | if isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#ignore().(other), Suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#): |
| 4487 | if otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#ignore().(other) not in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#ignore().(self).ignoreExprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignoreExprs.: |
| 4488 | superscip-python python python-stdlib 3.11 builtins/super#(ParseElementEnhancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#ignore().(self)).ignorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#ignore().(other)) |
| 4489 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#ignore().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr. is not None: |
| 4490 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#ignore().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr..ignorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#ignore().(self).ignoreExprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignoreExprs.[-1]) |
| 4491 | else: |
| 4492 | superscip-python python python-stdlib 3.11 builtins/super#(ParseElementEnhancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#ignore().(self)).ignorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#ignore().(other)) |
| 4493 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#ignore().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr. is not None: |
| 4494 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#ignore().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr..ignorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#ignore().(self).ignoreExprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignoreExprs.[-1]) |
| 4495 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#ignore().(self) |
| 4496 | |
| 4497 | def streamlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#streamline().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#streamline().(self)): |
| 4498 | superscip-python python python-stdlib 3.11 builtins/super#(ParseElementEnhancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#streamline().(self)).streamlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#streamline().() |
| 4499 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#streamline().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr. is not None: |
| 4500 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#streamline().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr..streamlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#streamline().() |
| 4501 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#streamline().(self) |
| 4502 | |
| 4503 | def checkRecursionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#checkRecursion().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#checkRecursion().(self), parseElementListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#checkRecursion().(parseElementList)): |
| 4504 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#checkRecursion().(self) in parseElementListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#checkRecursion().(parseElementList): |
| 4505 | raise RecursiveGrammarExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/RecursiveGrammarException#(parseElementListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#checkRecursion().(parseElementList) + [selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#checkRecursion().(self)]) |
| 4506 | subRecCheckList = parseElementListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#checkRecursion().(parseElementList)[:] + [selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#checkRecursion().(self)] |
| 4507 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#checkRecursion().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr. is not None: |
| 4508 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#checkRecursion().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr..checkRecursionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#checkRecursion().(subRecCheckList) |
| 4509 | |
| 4510 | def validatescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#validate().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#validate().(self), validateTracescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#validate().(validateTrace)=None): |
| 4511 | if validateTracescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#validate().(validateTrace) is None: |
| 4512 | validateTracescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#validate().(validateTrace) = [] |
| 4513 | tmp = validateTracescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#validate().(validateTrace)[:] + [selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#validate().(self)] |
| 4514 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#validate().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr. is not None: |
| 4515 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#validate().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr..validatescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#validate().(tmp) |
| 4516 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#validate().(self).checkRecursionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#checkRecursion().([]) |
| 4517 | |
| 4518 | def __str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__str__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__str__().(self)): |
| 4519 | try: |
| 4520 | return superscip-python python python-stdlib 3.11 builtins/super#(ParseElementEnhancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__str__().(self)).__str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#__str__().() |
| 4521 | except Exceptionscip-python python python-stdlib 3.11 builtins/Exception#: |
| 4522 | pass |
| 4523 | |
| 4524 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#strRepr. is None and selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__str__().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr. is not None: |
| 4525 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#strRepr. = "%s:(%s)" % (selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__str__().(self).__class__scip-python python python-stdlib 3.11 builtins/object#__class__()..__name__scip-python python python-stdlib 3.11 builtins/__name__#, _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__str__().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr.)) |
| 4526 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#strRepr. |
| 4527 | |
| 4528 | |
| 4529 | class FollowedByscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/FollowedBy#(ParseElementEnhancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#): |
| 4530 | """Lookahead matching of the given parse expression. |
| 4531 | ``FollowedBy`` does *not* advance the parsing position within |
| 4532 | the input string, it only verifies that the specified parse |
| 4533 | expression matches at the current position. ``FollowedBy`` |
| 4534 | always returns a null token list. If any results names are defined |
| 4535 | in the lookahead expression, those *will* be returned for access by |
| 4536 | name. |
| 4537 | |
| 4538 | Example:: |
| 4539 | |
| 4540 | # use FollowedBy to match a label only if it is followed by a ':' |
| 4541 | data_word = Word(alphas) |
| 4542 | label = data_word + FollowedBy(':') |
| 4543 | attr_expr = Group(label + Suppress(':') + OneOrMore(data_word, stopOn=label).setParseAction(' '.join)) |
| 4544 | |
| 4545 | OneOrMore(attr_expr).parseString("shape: SQUARE color: BLACK posn: upper left").pprint() |
| 4546 | |
| 4547 | prints:: |
| 4548 | |
| 4549 | [['shape', 'SQUARE'], ['color', 'BLACK'], ['posn', 'upper left']] |
| 4550 | """ |
| 4551 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/FollowedBy#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/FollowedBy#__init__().(self), exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/FollowedBy#__init__().(expr)): |
| 4552 | superscip-python python python-stdlib 3.11 builtins/super#(FollowedByscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/FollowedBy#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/FollowedBy#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/FollowedBy#__init__().(expr)) |
| 4553 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/FollowedBy#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/FollowedBy#mayReturnEmpty. = True |
| 4554 | |
| 4555 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/FollowedBy#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/FollowedBy#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/FollowedBy#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/FollowedBy#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/FollowedBy#parseImpl().(doActions)=True): |
| 4556 | # by using self._expr.parse and deleting the contents of the returned ParseResults list |
| 4557 | # we keep any named results that were defined in the FollowedBy expression |
| 4558 | _, ret = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/FollowedBy#parseImpl().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr.._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse.(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/FollowedBy#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/FollowedBy#parseImpl().(loc), doActions=doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/FollowedBy#parseImpl().(doActions)) |
| 4559 | del ret[:] |
| 4560 | |
| 4561 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/FollowedBy#parseImpl().(loc), ret |
| 4562 | |
| 4563 | |
| 4564 | class PrecededByscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#(ParseElementEnhancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#): |
| 4565 | """Lookbehind matching of the given parse expression. |
| 4566 | ``PrecededBy`` does not advance the parsing position within the |
| 4567 | input string, it only verifies that the specified parse expression |
| 4568 | matches prior to the current position. ``PrecededBy`` always |
| 4569 | returns a null token list, but if a results name is defined on the |
| 4570 | given expression, it is returned. |
| 4571 | |
| 4572 | Parameters: |
| 4573 | |
| 4574 | - expr - expression that must match prior to the current parse |
| 4575 | location |
| 4576 | - retreat - (default= ``None``) - (int) maximum number of characters |
| 4577 | to lookbehind prior to the current parse location |
| 4578 | |
| 4579 | If the lookbehind expression is a string, Literal, Keyword, or |
| 4580 | a Word or CharsNotIn with a specified exact or maximum length, then |
| 4581 | the retreat parameter is not required. Otherwise, retreat must be |
| 4582 | specified to give a maximum number of characters to look back from |
| 4583 | the current parse position for a lookbehind match. |
| 4584 | |
| 4585 | Example:: |
| 4586 | |
| 4587 | # VB-style variable names with type prefixes |
| 4588 | int_var = PrecededBy("#") + pyparsing_common.identifier |
| 4589 | str_var = PrecededBy("$") + pyparsing_common.identifier |
| 4590 | |
| 4591 | """ |
| 4592 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(self), exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(expr), retreatscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(retreat)=None): |
| 4593 | superscip-python python python-stdlib 3.11 builtins/super#(PrecededByscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(expr)) |
| 4594 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#expr. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#expr.().leaveWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#leaveWhitespace().() |
| 4595 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#mayReturnEmpty. = True |
| 4596 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(self).mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#mayIndexError. = False |
| 4597 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(self).exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#exact. = False |
| 4598 | if isinstance(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(expr), strscip-python python python-stdlib 3.11 builtins/str#): |
| 4599 | retreatscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(retreat) = len(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(expr)) |
| 4600 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(self).exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#exact. = True |
| 4601 | elif isinstance(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(expr), (Literalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#, Keywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#)): |
| 4602 | retreatscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(retreat) = exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(expr).matchLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#matchLen. |
| 4603 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(self).exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#exact. = True |
| 4604 | elif isinstance(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(expr), (Wordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#, CharsNotInscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#)) and exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(expr).maxLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#maxLen. != _MAX_INTscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MAX_INT.: |
| 4605 | retreatscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(retreat) = exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(expr).maxLenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#maxLen. |
| 4606 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(self).exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#exact. = True |
| 4607 | elif isinstance(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(expr), _PositionTokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_PositionToken#): |
| 4608 | retreatscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(retreat) = 0 |
| 4609 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(self).exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#exact. = True |
| 4610 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(self).retreatscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#retreat. = retreatscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(retreat) |
| 4611 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#errmsg. = "not preceded by " + strscip-python python python-stdlib 3.11 builtins/str#(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(expr)) |
| 4612 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(self).skipWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#skipWhitespace. = False |
| 4613 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#__init__().(self).parseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#parseAction..appendscip-python python python-stdlib 3.11 builtins/list#append().(lambda s, l, t: t.__delitem__(slicescip-python python python-stdlib 3.11 builtins/slice#(None, None))) |
| 4614 | |
| 4615 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(loc)=0, doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(doActions)=True): |
| 4616 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(self).exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#exact.: |
| 4617 | if locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(loc) < selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(self).retreatscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#retreat.: |
| 4618 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#errmsg.) |
| 4619 | start = locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(loc) - selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(self).retreatscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#retreat. |
| 4620 | _, ret = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#expr.._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse.(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(instring), start) |
| 4621 | else: |
| 4622 | # retreat specified a maximum lookbehind window, iterate |
| 4623 | test_expr = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#expr. + StringEndscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#() |
| 4624 | instring_slice = instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(instring)[maxscip-python python python-stdlib 3.11 builtins/max().(0, locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(loc) - selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(self).retreatscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#retreat.):locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(loc)] |
| 4625 | last_expr = ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#errmsg.) |
| 4626 | for offset in rangescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/range.(1, minscip-python python python-stdlib 3.11 builtins/min().(locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(self).retreatscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#retreat. + 1)+1): |
| 4627 | try: |
| 4628 | # print('trying', offset, instring_slice, repr(instring_slice[loc - offset:])) |
| 4629 | _, ret = test_expr._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse.(instring_slice, len(instring_slice) - offset) |
| 4630 | except ParseBaseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException# as pbe: |
| 4631 | last_expr = pbe |
| 4632 | else: |
| 4633 | break |
| 4634 | else: |
| 4635 | raise last_expr |
| 4636 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PrecededBy#parseImpl().(loc), ret |
| 4637 | |
| 4638 | |
| 4639 | class NotAnyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#(ParseElementEnhancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#): |
| 4640 | """Lookahead to disallow matching with the given parse expression. |
| 4641 | ``NotAny`` does *not* advance the parsing position within the |
| 4642 | input string, it only verifies that the specified parse expression |
| 4643 | does *not* match at the current position. Also, ``NotAny`` does |
| 4644 | *not* skip over leading whitespace. ``NotAny`` always returns |
| 4645 | a null token list. May be constructed using the '~' operator. |
| 4646 | |
| 4647 | Example:: |
| 4648 | |
| 4649 | AND, OR, NOT = map(CaselessKeyword, "AND OR NOT".split()) |
| 4650 | |
| 4651 | # take care not to mistake keywords for identifiers |
| 4652 | ident = ~(AND | OR | NOT) + Word(alphas) |
| 4653 | boolean_term = Optional(NOT) + ident |
| 4654 | |
| 4655 | # very crude boolean expression - to support parenthesis groups and |
| 4656 | # operation hierarchy, use infixNotation |
| 4657 | boolean_expr = boolean_term + ZeroOrMore((AND | OR) + boolean_term) |
| 4658 | |
| 4659 | # integers that are followed by "." are actually floats |
| 4660 | integer = Word(nums) + ~Char(".") |
| 4661 | """ |
| 4662 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#__init__().(self), exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#__init__().(expr)): |
| 4663 | superscip-python python python-stdlib 3.11 builtins/super#(NotAnyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#__init__().(expr)) |
| 4664 | # ~ self.leaveWhitespace() |
| 4665 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#__init__().(self).skipWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#skipWhitespace. = False # do NOT use self.leaveWhitespace(), don't want to propagate to exprs |
| 4666 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#mayReturnEmpty. = True |
| 4667 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#__init__().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#errmsg. = "Found unwanted token, " + _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#__init__().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr.) |
| 4668 | |
| 4669 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#parseImpl().(doActions)=True): |
| 4670 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#parseImpl().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr..canParseNextscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#canParseNext().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#parseImpl().(loc)): |
| 4671 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#parseImpl().(self)) |
| 4672 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#parseImpl().(loc), [] |
| 4673 | |
| 4674 | def __str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#__str__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#__str__().(self)): |
| 4675 | if hasattr(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#__str__().(self), "name"): |
| 4676 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#__str__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#name. |
| 4677 | |
| 4678 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#strRepr. is None: |
| 4679 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#strRepr. = "~{" + _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#__str__().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr.) + "}" |
| 4680 | |
| 4681 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NotAny#strRepr. |
| 4682 | |
| 4683 | class _MultipleMatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#(ParseElementEnhancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#): |
| 4684 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#__init__().(self), exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#__init__().(expr), stopOnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#__init__().(stopOn)=None): |
| 4685 | superscip-python python python-stdlib 3.11 builtins/super#(_MultipleMatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#__init__().(expr)) |
| 4686 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#__init__().(self).saveAsListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#saveAsList. = True |
| 4687 | ender = stopOnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#__init__().(stopOn) |
| 4688 | if isinstance(ender, basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 4689 | ender = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#__init__().(self)._literalStringClass(ender) |
| 4690 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#__init__().(self).stopOnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#stopOn().(ender) |
| 4691 | |
| 4692 | def stopOnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#stopOn().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#stopOn().(self), enderscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#stopOn().(ender)): |
| 4693 | if isinstance(enderscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#stopOn().(ender), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 4694 | enderscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#stopOn().(ender) = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#stopOn().(self)._literalStringClass(enderscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#stopOn().(ender)) |
| 4695 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#stopOn().(self).not_enderscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#not_ender. = ~enderscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#stopOn().(ender) if enderscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#stopOn().(ender) is not None else None |
| 4696 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#stopOn().(self) |
| 4697 | |
| 4698 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(doActions)=True): |
| 4699 | self_expr_parse = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr.._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse. |
| 4700 | self_skip_ignorables = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(self)._skipIgnorablesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_skipIgnorables(). |
| 4701 | check_ender = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(self).not_enderscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#not_ender. is not None |
| 4702 | if check_ender: |
| 4703 | try_not_ender = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(self).not_enderscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#not_ender..tryParse |
| 4704 | |
| 4705 | # must be at least one (but first see if we are the stopOn sentinel; |
| 4706 | # if so, fail) |
| 4707 | if check_ender: |
| 4708 | try_not_ender(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(loc)) |
| 4709 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(loc), tokens = self_expr_parse(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(doActions), callPreParse=False) |
| 4710 | try: |
| 4711 | hasIgnoreExprs = (not not selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(self).ignoreExprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignoreExprs.) |
| 4712 | while 1: |
| 4713 | if check_ender: |
| 4714 | try_not_ender(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(loc)) |
| 4715 | if hasIgnoreExprs: |
| 4716 | preloc = self_skip_ignorables(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(loc)) |
| 4717 | else: |
| 4718 | preloc = locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(loc) |
| 4719 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(loc), tmptokens = self_expr_parse(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(instring), preloc, doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(doActions)) |
| 4720 | if tmptokens or tmptokens.haskeys(): |
| 4721 | tokens += tmptokens |
| 4722 | except (ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#, IndexErrorscip-python python python-stdlib 3.11 builtins/IndexError#): |
| 4723 | pass |
| 4724 | |
| 4725 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(loc), tokens |
| 4726 | |
| 4727 | def _setResultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#_setResultsName().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#_setResultsName().(self), namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#_setResultsName().(name), listAllMatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#_setResultsName().(listAllMatches)=False): |
| 4728 | if __diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__..warn_ungrouped_named_tokens_in_collection: |
| 4729 | for e in [selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#_setResultsName().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr.] + getattrscip-python python python-stdlib 3.11 builtins/getattr().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#_setResultsName().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr., 'exprs', []): |
| 4730 | if isinstance(e, ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#) and e.resultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#resultsName.: |
| 4731 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("{0}: setting results name {1!r} on {2} expression " |
| 4732 | "collides with {3!r} on contained expression".format("warn_ungrouped_named_tokens_in_collection", |
| 4733 | namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#_setResultsName().(name), |
| 4734 | typescip-python python python-stdlib 3.11 builtins/type#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#_setResultsName().(self)).__name__scip-python python python-stdlib 3.11 builtins/__name__#, |
| 4735 | e.resultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#resultsName.), |
| 4736 | stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=3) |
| 4737 | |
| 4738 | return superscip-python python python-stdlib 3.11 builtins/super#(_MultipleMatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#_setResultsName().(self))._setResultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_setResultsName().(namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#_setResultsName().(name), listAllMatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#_setResultsName().(listAllMatches)) |
| 4739 | |
| 4740 | |
| 4741 | class OneOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#(_MultipleMatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#): |
| 4742 | """Repetition of one or more of the given expression. |
| 4743 | |
| 4744 | Parameters: |
| 4745 | - expr - expression that must match one or more times |
| 4746 | - stopOn - (default= ``None``) - expression for a terminating sentinel |
| 4747 | (only required if the sentinel would ordinarily match the repetition |
| 4748 | expression) |
| 4749 | |
| 4750 | Example:: |
| 4751 | |
| 4752 | data_word = Word(alphas) |
| 4753 | label = data_word + FollowedBy(':') |
| 4754 | attr_expr = Group(label + Suppress(':') + OneOrMore(data_word).setParseAction(' '.join)) |
| 4755 | |
| 4756 | text = "shape: SQUARE posn: upper left color: BLACK" |
| 4757 | OneOrMore(attr_expr).parseString(text).pprint() # Fail! read 'color' as data instead of next label -> [['shape', 'SQUARE color']] |
| 4758 | |
| 4759 | # use stopOn attribute for OneOrMore to avoid reading label string as part of the data |
| 4760 | attr_expr = Group(label + Suppress(':') + OneOrMore(data_word, stopOn=label).setParseAction(' '.join)) |
| 4761 | OneOrMore(attr_expr).parseString(text).pprint() # Better -> [['shape', 'SQUARE'], ['posn', 'upper left'], ['color', 'BLACK']] |
| 4762 | |
| 4763 | # could also be written as |
| 4764 | (attr_expr * (1,)).parseString(text).pprint() |
| 4765 | """ |
| 4766 | |
| 4767 | def __str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#__str__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#__str__().(self)): |
| 4768 | if hasattr(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#__str__().(self), "name"): |
| 4769 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#__str__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#name. |
| 4770 | |
| 4771 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#strRepr. is None: |
| 4772 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#strRepr. = "{" + _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#__str__().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr.) + "}..." |
| 4773 | |
| 4774 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#strRepr. |
| 4775 | |
| 4776 | class ZeroOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#(_MultipleMatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#): |
| 4777 | """Optional repetition of zero or more of the given expression. |
| 4778 | |
| 4779 | Parameters: |
| 4780 | - expr - expression that must match zero or more times |
| 4781 | - stopOn - (default= ``None``) - expression for a terminating sentinel |
| 4782 | (only required if the sentinel would ordinarily match the repetition |
| 4783 | expression) |
| 4784 | |
| 4785 | Example: similar to :class:`OneOrMore` |
| 4786 | """ |
| 4787 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#__init__().(self), exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#__init__().(expr), stopOnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#__init__().(stopOn)=None): |
| 4788 | superscip-python python python-stdlib 3.11 builtins/super#(ZeroOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#__init__().(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#__init__().(expr), stopOnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#__init__().(stopOn)=stopOnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#__init__().(stopOn)) |
| 4789 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#mayReturnEmpty. = True |
| 4790 | |
| 4791 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#parseImpl().(doActions)=True): |
| 4792 | try: |
| 4793 | return superscip-python python python-stdlib 3.11 builtins/super#(ZeroOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#parseImpl().(self)).parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#parseImpl().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#parseImpl().(doActions)) |
| 4794 | except (ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#, IndexErrorscip-python python python-stdlib 3.11 builtins/IndexError#): |
| 4795 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#parseImpl().(loc), [] |
| 4796 | |
| 4797 | def __str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#__str__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#__str__().(self)): |
| 4798 | if hasattr(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#__str__().(self), "name"): |
| 4799 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#__str__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#name. |
| 4800 | |
| 4801 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#strRepr. is None: |
| 4802 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#strRepr. = "[" + _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#__str__().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr.) + "]..." |
| 4803 | |
| 4804 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#strRepr. |
| 4805 | |
| 4806 | |
| 4807 | class _NullTokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_NullToken#(objectscip-python python python-stdlib 3.11 builtins/object#): |
| 4808 | def __bool__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_NullToken#__bool__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_NullToken#__bool__().(self)): |
| 4809 | return False |
| 4810 | __nonzero__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_NullToken#__nonzero__. = __bool__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_NullToken#__bool__(). |
| 4811 | def __str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_NullToken#__str__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_NullToken#__str__().(self)): |
| 4812 | return "" |
| 4813 | |
| 4814 | class Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#(ParseElementEnhancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#): |
| 4815 | """Optional matching of the given expression. |
| 4816 | |
| 4817 | Parameters: |
| 4818 | - expr - expression that must match zero or more times |
| 4819 | - default (optional) - value to be returned if the optional expression is not found. |
| 4820 | |
| 4821 | Example:: |
| 4822 | |
| 4823 | # US postal code can be a 5-digit zip, plus optional 4-digit qualifier |
| 4824 | zip = Combine(Word(nums, exact=5) + Optional('-' + Word(nums, exact=4))) |
| 4825 | zip.runTests(''' |
| 4826 | # traditional ZIP code |
| 4827 | 12345 |
| 4828 | |
| 4829 | # ZIP+4 form |
| 4830 | 12101-0001 |
| 4831 | |
| 4832 | # invalid ZIP |
| 4833 | 98765- |
| 4834 | ''') |
| 4835 | |
| 4836 | prints:: |
| 4837 | |
| 4838 | # traditional ZIP code |
| 4839 | 12345 |
| 4840 | ['12345'] |
| 4841 | |
| 4842 | # ZIP+4 form |
| 4843 | 12101-0001 |
| 4844 | ['12101-0001'] |
| 4845 | |
| 4846 | # invalid ZIP |
| 4847 | 98765- |
| 4848 | ^ |
| 4849 | FAIL: Expected end of text (at char 5), (line:1, col:6) |
| 4850 | """ |
| 4851 | __optionalNotMatchedscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__optionalNotMatched. = _NullTokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_NullToken#() |
| 4852 | |
| 4853 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__init__().(self), exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__init__().(expr), defaultscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__init__().(default)=__optionalNotMatchedscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__optionalNotMatched.): |
| 4854 | superscip-python python python-stdlib 3.11 builtins/super#(Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__init__().(expr), savelistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(savelist)=False) |
| 4855 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__init__().(self).saveAsListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#saveAsList. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__init__().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr..saveAsListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#saveAsList. |
| 4856 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__init__().(self).defaultValuescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#defaultValue. = defaultscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__init__().(default) |
| 4857 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#mayReturnEmpty. = True |
| 4858 | |
| 4859 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#parseImpl().(doActions)=True): |
| 4860 | try: |
| 4861 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#parseImpl().(loc), tokens = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#parseImpl().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr.._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse.(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#parseImpl().(doActions), callPreParse=False) |
| 4862 | except (ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#, IndexErrorscip-python python python-stdlib 3.11 builtins/IndexError#): |
| 4863 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#parseImpl().(self).defaultValuescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#defaultValue. is not selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#parseImpl().(self).__optionalNotMatchedscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__optionalNotMatched.: |
| 4864 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#parseImpl().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr..resultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#resultsName.: |
| 4865 | tokens = ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#([selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#parseImpl().(self).defaultValuescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#defaultValue.]) |
| 4866 | tokens[selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#parseImpl().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr..resultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#resultsName.] = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#parseImpl().(self).defaultValuescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#defaultValue. |
| 4867 | else: |
| 4868 | tokens = [selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#parseImpl().(self).defaultValuescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#defaultValue.] |
| 4869 | else: |
| 4870 | tokens = [] |
| 4871 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#parseImpl().(loc), tokens |
| 4872 | |
| 4873 | def __str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__str__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__str__().(self)): |
| 4874 | if hasattr(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__str__().(self), "name"): |
| 4875 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__str__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#name. |
| 4876 | |
| 4877 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#strRepr. is None: |
| 4878 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#strRepr. = "[" + _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__str__().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr.) + "]" |
| 4879 | |
| 4880 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#strRepr. |
| 4881 | |
| 4882 | class SkipToscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#(ParseElementEnhancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#): |
| 4883 | """Token for skipping over all undefined text until the matched |
| 4884 | expression is found. |
| 4885 | |
| 4886 | Parameters: |
| 4887 | - expr - target expression marking the end of the data to be skipped |
| 4888 | - include - (default= ``False``) if True, the target expression is also parsed |
| 4889 | (the skipped text and target expression are returned as a 2-element list). |
| 4890 | - ignore - (default= ``None``) used to define grammars (typically quoted strings and |
| 4891 | comments) that might contain false matches to the target expression |
| 4892 | - failOn - (default= ``None``) define expressions that are not allowed to be |
| 4893 | included in the skipped test; if found before the target expression is found, |
| 4894 | the SkipTo is not a match |
| 4895 | |
| 4896 | Example:: |
| 4897 | |
| 4898 | report = ''' |
| 4899 | Outstanding Issues Report - 1 Jan 2000 |
| 4900 | |
| 4901 | # | Severity | Description | Days Open |
| 4902 | -----+----------+-------------------------------------------+----------- |
| 4903 | 101 | Critical | Intermittent system crash | 6 |
| 4904 | 94 | Cosmetic | Spelling error on Login ('log|n') | 14 |
| 4905 | 79 | Minor | System slow when running too many reports | 47 |
| 4906 | ''' |
| 4907 | integer = Word(nums) |
| 4908 | SEP = Suppress('|') |
| 4909 | # use SkipTo to simply match everything up until the next SEP |
| 4910 | # - ignore quoted strings, so that a '|' character inside a quoted string does not match |
| 4911 | # - parse action will call token.strip() for each matched token, i.e., the description body |
| 4912 | string_data = SkipTo(SEP, ignore=quotedString) |
| 4913 | string_data.setParseAction(tokenMap(str.strip)) |
| 4914 | ticket_expr = (integer("issue_num") + SEP |
| 4915 | + string_data("sev") + SEP |
| 4916 | + string_data("desc") + SEP |
| 4917 | + integer("days_open")) |
| 4918 | |
| 4919 | for tkt in ticket_expr.searchString(report): |
| 4920 | print tkt.dump() |
| 4921 | |
| 4922 | prints:: |
| 4923 | |
| 4924 | ['101', 'Critical', 'Intermittent system crash', '6'] |
| 4925 | - days_open: 6 |
| 4926 | - desc: Intermittent system crash |
| 4927 | - issue_num: 101 |
| 4928 | - sev: Critical |
| 4929 | ['94', 'Cosmetic', "Spelling error on Login ('log|n')", '14'] |
| 4930 | - days_open: 14 |
| 4931 | - desc: Spelling error on Login ('log|n') |
| 4932 | - issue_num: 94 |
| 4933 | - sev: Cosmetic |
| 4934 | ['79', 'Minor', 'System slow when running too many reports', '47'] |
| 4935 | - days_open: 47 |
| 4936 | - desc: System slow when running too many reports |
| 4937 | - issue_num: 79 |
| 4938 | - sev: Minor |
| 4939 | """ |
| 4940 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(other), includescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(include)=False, ignorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(ignore)=None, failOnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(failOn)=None): |
| 4941 | superscip-python python python-stdlib 3.11 builtins/super#(SkipToscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(other)) |
| 4942 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(self).ignoreExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#ignoreExpr. = ignorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(ignore) |
| 4943 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#mayReturnEmpty. = True |
| 4944 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(self).mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#mayIndexError. = False |
| 4945 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(self).includeMatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#includeMatch. = includescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(include) |
| 4946 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(self).saveAsListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#saveAsList. = False |
| 4947 | if isinstance(failOnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(failOn), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 4948 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(self).failOnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#failOn. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(self)._literalStringClass(failOnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(failOn)) |
| 4949 | else: |
| 4950 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(self).failOnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#failOn. = failOnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(failOn) |
| 4951 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#errmsg. = "No match found for " + _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#__init__().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr.) |
| 4952 | |
| 4953 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(doActions)=True): |
| 4954 | startloc = locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(loc) |
| 4955 | instrlen = len(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(instring)) |
| 4956 | expr = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr. |
| 4957 | expr_parse = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr.._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse. |
| 4958 | self_failOn_canParseNext = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(self).failOnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#failOn..canParseNext if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(self).failOnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#failOn. is not None else None |
| 4959 | self_ignoreExpr_tryParse = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(self).ignoreExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#ignoreExpr..tryParse if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(self).ignoreExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#ignoreExpr. is not None else None |
| 4960 | |
| 4961 | tmploc = locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(loc) |
| 4962 | while tmploc <= instrlen: |
| 4963 | if self_failOn_canParseNext is not None: |
| 4964 | # break if failOn expression matches |
| 4965 | if self_failOn_canParseNext(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(instring), tmploc): |
| 4966 | break |
| 4967 | |
| 4968 | if self_ignoreExpr_tryParse is not None: |
| 4969 | # advance past ignore expressions |
| 4970 | while 1: |
| 4971 | try: |
| 4972 | tmploc = self_ignoreExpr_tryParse(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(instring), tmploc) |
| 4973 | except ParseBaseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseBaseException#: |
| 4974 | break |
| 4975 | |
| 4976 | try: |
| 4977 | expr_parse(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(instring), tmploc, doActions=False, callPreParse=False) |
| 4978 | except (ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#, IndexErrorscip-python python python-stdlib 3.11 builtins/IndexError#): |
| 4979 | # no match, advance loc in string |
| 4980 | tmploc += 1 |
| 4981 | else: |
| 4982 | # matched skipto expr, done |
| 4983 | break |
| 4984 | |
| 4985 | else: |
| 4986 | # ran off the end of the input string without matching skipto expr, fail |
| 4987 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(loc), selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(self).errmsgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#errmsg., selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(self)) |
| 4988 | |
| 4989 | # build up return values |
| 4990 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(loc) = tmploc |
| 4991 | skiptext = instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(instring)[startloc:locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(loc)] |
| 4992 | skipresult = ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#(skiptext) |
| 4993 | |
| 4994 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(self).includeMatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#includeMatch.: |
| 4995 | locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(loc), mat = expr_parse(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(doActions), callPreParse=False) |
| 4996 | skipresult += mat |
| 4997 | |
| 4998 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#parseImpl().(loc), skipresult |
| 4999 | |
| 5000 | class Forwardscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#(ParseElementEnhancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#): |
| 5001 | """Forward declaration of an expression to be defined later - |
| 5002 | used for recursive grammars, such as algebraic infix notation. |
| 5003 | When the expression is known, it is assigned to the ``Forward`` |
| 5004 | variable using the '<<' operator. |
| 5005 | |
| 5006 | Note: take care when assigning to ``Forward`` not to overlook |
| 5007 | precedence of operators. |
| 5008 | |
| 5009 | Specifically, '|' has a lower precedence than '<<', so that:: |
| 5010 | |
| 5011 | fwdExpr << a | b | c |
| 5012 | |
| 5013 | will actually be evaluated as:: |
| 5014 | |
| 5015 | (fwdExpr << a) | b | c |
| 5016 | |
| 5017 | thereby leaving b and c out as parseable alternatives. It is recommended that you |
| 5018 | explicitly group the values inserted into the ``Forward``:: |
| 5019 | |
| 5020 | fwdExpr << (a | b | c) |
| 5021 | |
| 5022 | Converting to use the '<<=' operator instead will avoid this problem. |
| 5023 | |
| 5024 | See :class:`ParseResults.pprint` for an example of a recursive |
| 5025 | parser created using ``Forward``. |
| 5026 | """ |
| 5027 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__init__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__init__().(other)=None): |
| 5028 | superscip-python python python-stdlib 3.11 builtins/super#(Forwardscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__init__().(other), savelistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(savelist)=False) |
| 5029 | |
| 5030 | def __lshift__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(other)): |
| 5031 | if isinstance(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(other), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 5032 | otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(other) = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(self)._literalStringClass(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(other)) |
| 5033 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#expr. = otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(other) |
| 5034 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#strRepr. = None |
| 5035 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(self).mayIndexErrorscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#mayIndexError. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#expr..mayIndexError |
| 5036 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(self).mayReturnEmptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#mayReturnEmpty. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#expr..mayReturnEmpty |
| 5037 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(self).setWhitespaceCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setWhitespaceChars().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#expr..whiteChars) |
| 5038 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(self).skipWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#skipWhitespace. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#expr..skipWhitespace |
| 5039 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(self).saveAsListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#saveAsList. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#expr..saveAsList |
| 5040 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(self).ignoreExprsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignoreExprs..extendscip-python python python-stdlib 3.11 builtins/list#extend().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#expr..ignoreExprs) |
| 5041 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__lshift__().(self) |
| 5042 | |
| 5043 | def __ilshift__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__ilshift__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__ilshift__().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__ilshift__().(other)): |
| 5044 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__ilshift__().(self) << otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__ilshift__().(other) |
| 5045 | |
| 5046 | def leaveWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#leaveWhitespace().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#leaveWhitespace().(self)): |
| 5047 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#leaveWhitespace().(self).skipWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#skipWhitespace. = False |
| 5048 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#leaveWhitespace().(self) |
| 5049 | |
| 5050 | def streamlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#streamline().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#streamline().(self)): |
| 5051 | if not selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#streamline().(self).streamlinedscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#streamlined.: |
| 5052 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#streamline().(self).streamlinedscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#streamlined. = True |
| 5053 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#streamline().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#expr. is not None: |
| 5054 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#streamline().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#expr..streamline() |
| 5055 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#streamline().(self) |
| 5056 | |
| 5057 | def validatescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#validate().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#validate().(self), validateTracescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#validate().(validateTrace)=None): |
| 5058 | if validateTracescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#validate().(validateTrace) is None: |
| 5059 | validateTracescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#validate().(validateTrace) = [] |
| 5060 | |
| 5061 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#validate().(self) not in validateTracescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#validate().(validateTrace): |
| 5062 | tmp = validateTracescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#validate().(validateTrace)[:] + [selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#validate().(self)] |
| 5063 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#validate().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#expr. is not None: |
| 5064 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#validate().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#expr..validate(tmp) |
| 5065 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#validate().(self).checkRecursionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#checkRecursion().([]) |
| 5066 | |
| 5067 | def __str__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__str__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__str__().(self)): |
| 5068 | if hasattr(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__str__().(self), "name"): |
| 5069 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__str__().(self).namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#name. |
| 5070 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#strRepr. is not None: |
| 5071 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#strRepr. |
| 5072 | |
| 5073 | # Avoid infinite recursion by setting a temporary strRepr |
| 5074 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#strRepr. = ": ..." |
| 5075 | |
| 5076 | # Use the string representation of main expression. |
| 5077 | retString = '...' |
| 5078 | try: |
| 5079 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__str__().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#expr. is not None: |
| 5080 | retString = _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__str__().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#expr.)[:1000] |
| 5081 | else: |
| 5082 | retString = "None" |
| 5083 | finally: |
| 5084 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#strRepr. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__str__().(self).__class__scip-python python python-stdlib 3.11 builtins/object#__class__()..__name__scip-python python python-stdlib 3.11 builtins/__name__# + ": " + retString |
| 5085 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#__str__().(self).strReprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#strRepr. |
| 5086 | |
| 5087 | def copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#copy().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#copy().(self)): |
| 5088 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#copy().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#expr. is not None: |
| 5089 | return superscip-python python python-stdlib 3.11 builtins/super#(Forwardscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#copy().(self)).copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().() |
| 5090 | else: |
| 5091 | ret = Forwardscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#() |
| 5092 | ret <<= selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#copy().(self) |
| 5093 | return ret |
| 5094 | |
| 5095 | def _setResultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#_setResultsName().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#_setResultsName().(self), namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#_setResultsName().(name), listAllMatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#_setResultsName().(listAllMatches)=False): |
| 5096 | if __diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__..warn_name_set_on_empty_Forward: |
| 5097 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#_setResultsName().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#expr. is None: |
| 5098 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("{0}: setting results name {0!r} on {1} expression " |
| 5099 | "that has no contained expression".format("warn_name_set_on_empty_Forward", |
| 5100 | namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#_setResultsName().(name), |
| 5101 | typescip-python python python-stdlib 3.11 builtins/type#(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#_setResultsName().(self)).__name__scip-python python python-stdlib 3.11 builtins/__name__#), |
| 5102 | stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=3) |
| 5103 | |
| 5104 | return superscip-python python python-stdlib 3.11 builtins/super#(Forwardscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#_setResultsName().(self))._setResultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_setResultsName().(namescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#_setResultsName().(name), listAllMatchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#_setResultsName().(listAllMatches)) |
| 5105 | |
| 5106 | class TokenConverterscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/TokenConverter#(ParseElementEnhancescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#): |
| 5107 | """ |
| 5108 | Abstract subclass of :class:`ParseExpression`, for converting parsed results. |
| 5109 | """ |
| 5110 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/TokenConverter#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/TokenConverter#__init__().(self), exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/TokenConverter#__init__().(expr), savelistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/TokenConverter#__init__().(savelist)=False): |
| 5111 | superscip-python python python-stdlib 3.11 builtins/super#(TokenConverterscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/TokenConverter#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/TokenConverter#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#__init__().(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/TokenConverter#__init__().(expr)) # , savelist) |
| 5112 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/TokenConverter#__init__().(self).saveAsListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/TokenConverter#saveAsList. = False |
| 5113 | |
| 5114 | class Combinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#(TokenConverterscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/TokenConverter#): |
| 5115 | """Converter to concatenate all matching tokens to a single string. |
| 5116 | By default, the matching patterns must also be contiguous in the |
| 5117 | input string; this can be disabled by specifying |
| 5118 | ``'adjacent=False'`` in the constructor. |
| 5119 | |
| 5120 | Example:: |
| 5121 | |
| 5122 | real = Word(nums) + '.' + Word(nums) |
| 5123 | print(real.parseString('3.1416')) # -> ['3', '.', '1416'] |
| 5124 | # will also erroneously match the following |
| 5125 | print(real.parseString('3. 1416')) # -> ['3', '.', '1416'] |
| 5126 | |
| 5127 | real = Combine(Word(nums) + '.' + Word(nums)) |
| 5128 | print(real.parseString('3.1416')) # -> ['3.1416'] |
| 5129 | # no match when there are internal spaces |
| 5130 | print(real.parseString('3. 1416')) # -> Exception: Expected W:(0123...) |
| 5131 | """ |
| 5132 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#__init__().(self), exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#__init__().(expr), joinStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#__init__().(joinString)="", adjacentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#__init__().(adjacent)=True): |
| 5133 | superscip-python python python-stdlib 3.11 builtins/super#(Combinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/TokenConverter#__init__().(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#__init__().(expr)) |
| 5134 | # suppress whitespace-stripping in contained parse expressions, but re-enable it on the Combine itself |
| 5135 | if adjacentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#__init__().(adjacent): |
| 5136 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#__init__().(self).leaveWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#leaveWhitespace().() |
| 5137 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#__init__().(self).adjacentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#adjacent. = adjacentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#__init__().(adjacent) |
| 5138 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#__init__().(self).skipWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#skipWhitespace. = True |
| 5139 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#__init__().(self).joinStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#joinString. = joinStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#__init__().(joinString) |
| 5140 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#__init__().(self).callPreparsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#callPreparse. = True |
| 5141 | |
| 5142 | def ignorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#ignore().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#ignore().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#ignore().(other)): |
| 5143 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#ignore().(self).adjacentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#adjacent.: |
| 5144 | ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.ignorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#ignore().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#ignore().(self), otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#ignore().(other)) |
| 5145 | else: |
| 5146 | superscip-python python python-stdlib 3.11 builtins/super#(Combinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#ignore().(self)).ignorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#ignore().(otherscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#ignore().(other)) |
| 5147 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#ignore().(self) |
| 5148 | |
| 5149 | def postParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#postParse().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#postParse().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#postParse().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#postParse().(loc), tokenlistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#postParse().(tokenlist)): |
| 5150 | retToks = tokenlistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#postParse().(tokenlist).copy() |
| 5151 | del retToks[:] |
| 5152 | retToks += ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#(["".joinscip-python python python-stdlib 3.11 builtins/str#join().(tokenlistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#postParse().(tokenlist)._asStringList(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#postParse().(self).joinStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#joinString.))], modalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#__init__().(modal)=selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#postParse().(self).modalResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#modalResults.) |
| 5153 | |
| 5154 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#postParse().(self).resultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#resultsName. and retToks.haskeys(): |
| 5155 | return [retToks] |
| 5156 | else: |
| 5157 | return retToks |
| 5158 | |
| 5159 | class Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(TokenConverterscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/TokenConverter#): |
| 5160 | """Converter to return the matched tokens as a list - useful for |
| 5161 | returning tokens of :class:`ZeroOrMore` and :class:`OneOrMore` expressions. |
| 5162 | |
| 5163 | Example:: |
| 5164 | |
| 5165 | ident = Word(alphas) |
| 5166 | num = Word(nums) |
| 5167 | term = ident | num |
| 5168 | func = ident + Optional(delimitedList(term)) |
| 5169 | print(func.parseString("fn a, b, 100")) # -> ['fn', 'a', 'b', '100'] |
| 5170 | |
| 5171 | func = ident + Group(Optional(delimitedList(term))) |
| 5172 | print(func.parseString("fn a, b, 100")) # -> ['fn', ['a', 'b', '100']] |
| 5173 | """ |
| 5174 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#__init__().(self), exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#__init__().(expr)): |
| 5175 | superscip-python python python-stdlib 3.11 builtins/super#(Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/TokenConverter#__init__().(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#__init__().(expr)) |
| 5176 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#__init__().(self).saveAsListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#saveAsList. = True |
| 5177 | |
| 5178 | def postParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#postParse().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#postParse().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#postParse().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#postParse().(loc), tokenlistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#postParse().(tokenlist)): |
| 5179 | return [tokenlistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#postParse().(tokenlist)] |
| 5180 | |
| 5181 | class Dictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#(TokenConverterscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/TokenConverter#): |
| 5182 | """Converter to return a repetitive expression as a list, but also |
| 5183 | as a dictionary. Each element can also be referenced using the first |
| 5184 | token in the expression as its key. Useful for tabular report |
| 5185 | scraping when the first column can be used as a item key. |
| 5186 | |
| 5187 | Example:: |
| 5188 | |
| 5189 | data_word = Word(alphas) |
| 5190 | label = data_word + FollowedBy(':') |
| 5191 | attr_expr = Group(label + Suppress(':') + OneOrMore(data_word).setParseAction(' '.join)) |
| 5192 | |
| 5193 | text = "shape: SQUARE posn: upper left color: light blue texture: burlap" |
| 5194 | attr_expr = (label + Suppress(':') + OneOrMore(data_word, stopOn=label).setParseAction(' '.join)) |
| 5195 | |
| 5196 | # print attributes as plain groups |
| 5197 | print(OneOrMore(attr_expr).parseString(text).dump()) |
| 5198 | |
| 5199 | # instead of OneOrMore(expr), parse using Dict(OneOrMore(Group(expr))) - Dict will auto-assign names |
| 5200 | result = Dict(OneOrMore(Group(attr_expr))).parseString(text) |
| 5201 | print(result.dump()) |
| 5202 | |
| 5203 | # access named fields as dict entries, or output as dict |
| 5204 | print(result['shape']) |
| 5205 | print(result.asDict()) |
| 5206 | |
| 5207 | prints:: |
| 5208 | |
| 5209 | ['shape', 'SQUARE', 'posn', 'upper left', 'color', 'light blue', 'texture', 'burlap'] |
| 5210 | [['shape', 'SQUARE'], ['posn', 'upper left'], ['color', 'light blue'], ['texture', 'burlap']] |
| 5211 | - color: light blue |
| 5212 | - posn: upper left |
| 5213 | - shape: SQUARE |
| 5214 | - texture: burlap |
| 5215 | SQUARE |
| 5216 | {'color': 'light blue', 'posn': 'upper left', 'texture': 'burlap', 'shape': 'SQUARE'} |
| 5217 | |
| 5218 | See more examples at :class:`ParseResults` of accessing fields by results name. |
| 5219 | """ |
| 5220 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#__init__().(self), exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#__init__().(expr)): |
| 5221 | superscip-python python python-stdlib 3.11 builtins/super#(Dictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#, selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#__init__().(self)).__init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/TokenConverter#__init__().(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#__init__().(expr)) |
| 5222 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#__init__().(self).saveAsListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#saveAsList. = True |
| 5223 | |
| 5224 | def postParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#postParse().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#postParse().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#postParse().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#postParse().(loc), tokenlistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#postParse().(tokenlist)): |
| 5225 | for i, tok in enumeratescip-python python python-stdlib 3.11 builtins/enumerate#(tokenlistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#postParse().(tokenlist)): |
| 5226 | if len(tok) == 0: |
| 5227 | continue |
| 5228 | ikey = tok[0] |
| 5229 | if isinstance(ikey, intscip-python python python-stdlib 3.11 builtins/int#): |
| 5230 | ikey = _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(tok[0]).stripscip-python python python-stdlib 3.11 builtins/str#strip().() |
| 5231 | if len(tok) == 1: |
| 5232 | tokenlistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#postParse().(tokenlist)[ikey] = _ParseResultsWithOffsetscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#("", i) |
| 5233 | elif len(tok) == 2 and not isinstance(tok[1], ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#): |
| 5234 | tokenlistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#postParse().(tokenlist)[ikey] = _ParseResultsWithOffsetscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#(tok[1], i) |
| 5235 | else: |
| 5236 | dictvalue = tok.copy() # ParseResults(i) |
| 5237 | del dictvalue[0] |
| 5238 | if len(dictvalue) != 1 or (isinstance(dictvalue, ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#) and dictvalue.haskeysscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#haskeys().()): |
| 5239 | tokenlistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#postParse().(tokenlist)[ikey] = _ParseResultsWithOffsetscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#(dictvalue, i) |
| 5240 | else: |
| 5241 | tokenlistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#postParse().(tokenlist)[ikey] = _ParseResultsWithOffsetscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ParseResultsWithOffset#(dictvalue[0], i) |
| 5242 | |
| 5243 | if selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#postParse().(self).resultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#resultsName.: |
| 5244 | return [tokenlistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#postParse().(tokenlist)] |
| 5245 | else: |
| 5246 | return tokenlistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#postParse().(tokenlist) |
| 5247 | |
| 5248 | |
| 5249 | class Suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#(TokenConverterscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/TokenConverter#): |
| 5250 | """Converter for ignoring the results of a parsed expression. |
| 5251 | |
| 5252 | Example:: |
| 5253 | |
| 5254 | source = "a, b, c,d" |
| 5255 | wd = Word(alphas) |
| 5256 | wd_list1 = wd + ZeroOrMore(',' + wd) |
| 5257 | print(wd_list1.parseString(source)) |
| 5258 | |
| 5259 | # often, delimiters that are useful during parsing are just in the |
| 5260 | # way afterward - use Suppress to keep them out of the parsed output |
| 5261 | wd_list2 = wd + ZeroOrMore(Suppress(',') + wd) |
| 5262 | print(wd_list2.parseString(source)) |
| 5263 | |
| 5264 | prints:: |
| 5265 | |
| 5266 | ['a', ',', 'b', ',', 'c', ',', 'd'] |
| 5267 | ['a', 'b', 'c', 'd'] |
| 5268 | |
| 5269 | (See also :class:`delimitedList`.) |
| 5270 | """ |
| 5271 | def postParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#postParse().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#postParse().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#postParse().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#postParse().(loc), tokenlistscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#postParse().(tokenlist)): |
| 5272 | return [] |
| 5273 | |
| 5274 | def suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#suppress().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#suppress().(self)): |
| 5275 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#suppress().(self) |
| 5276 | |
| 5277 | |
| 5278 | class OnlyOncescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#(objectscip-python python python-stdlib 3.11 builtins/object#): |
| 5279 | """Wrapper for parse actions, to ensure they are only called once. |
| 5280 | """ |
| 5281 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#__init__().(self), methodCallscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#__init__().(methodCall)): |
| 5282 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#__init__().(self).callablescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#callable. = _trim_arityscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().(methodCallscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#__init__().(methodCall)) |
| 5283 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#__init__().(self).calledscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#called. = False |
| 5284 | def __call__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#__call__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#__call__().(self), sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#__call__().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#__call__().(l), tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#__call__().(t)): |
| 5285 | if not selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#__call__().(self).calledscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#called.: |
| 5286 | results = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#__call__().(self).callablescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#callable.(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#__call__().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#__call__().(l), tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#__call__().(t)) |
| 5287 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#__call__().(self).calledscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#called. = True |
| 5288 | return results |
| 5289 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#__call__().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#__call__().(l), "") |
| 5290 | def resetscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#reset().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#reset().(self)): |
| 5291 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#reset().(self).calledscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OnlyOnce#called. = False |
| 5292 | |
| 5293 | def traceParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/traceParseAction().(fscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/traceParseAction().(f)): |
| 5294 | """Decorator for debugging parse actions. |
| 5295 | |
| 5296 | When the parse action is called, this decorator will print |
| 5297 | ``">> entering method-name(line:<current_source_line>, <parse_location>, <matched_tokens>)"``. |
| 5298 | When the parse action completes, the decorator will print |
| 5299 | ``"<<"`` followed by the returned value, or any exception that the parse action raised. |
| 5300 | |
| 5301 | Example:: |
| 5302 | |
| 5303 | wd = Word(alphas) |
| 5304 | |
| 5305 | @traceParseAction |
| 5306 | def remove_duplicate_chars(tokens): |
| 5307 | return ''.join(sorted(set(''.join(tokens)))) |
| 5308 | |
| 5309 | wds = OneOrMore(wd).setParseAction(remove_duplicate_chars) |
| 5310 | print(wds.parseString("slkdjs sld sldd sdlf sdljf")) |
| 5311 | |
| 5312 | prints:: |
| 5313 | |
| 5314 | >>entering remove_duplicate_chars(line: 'slkdjs sld sldd sdlf sdljf', 0, (['slkdjs', 'sld', 'sldd', 'sdlf', 'sdljf'], {})) |
| 5315 | <<leaving remove_duplicate_chars (ret: 'dfjkls') |
| 5316 | ['dfjkls'] |
| 5317 | """ |
| 5318 | fscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/traceParseAction().(f) = _trim_arityscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_trim_arity().(fscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/traceParseAction().(f)) |
| 5319 | def zscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/traceParseAction().z().(*paArgsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/traceParseAction().z().(paArgs)): |
| 5320 | thisFunc = fscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/traceParseAction().(f).__name__ |
| 5321 | s, l, t = paArgsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/traceParseAction().z().(paArgs)[-3:] |
| 5322 | if len(paArgsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/traceParseAction().z().(paArgs)) > 3: |
| 5323 | thisFunc = paArgsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/traceParseAction().z().(paArgs)[0].__class__.__name__ + '.' + thisFunc |
| 5324 | sysscip-python python python-stdlib 3.11 sys/__init__:.stderrscip-python python python-stdlib 3.11 sys/stderr.stderr..writescip-python python python-stdlib 3.11 typing/IO#write().(">>entering %s(line: '%s', %d, %r)\n" % (thisFunc, linescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/line().(l, s), l, t)) |
| 5325 | try: |
| 5326 | ret = fscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/traceParseAction().(f)(*paArgsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/traceParseAction().z().(paArgs)) |
| 5327 | except Exceptionscip-python python python-stdlib 3.11 builtins/Exception# as exc: |
| 5328 | sysscip-python python python-stdlib 3.11 sys/__init__:.stderrscip-python python python-stdlib 3.11 sys/stderr.stderr..writescip-python python python-stdlib 3.11 typing/IO#write().("<<leaving %s (exception: %s)\n" % (thisFunc, exc)) |
| 5329 | raise |
| 5330 | sysscip-python python python-stdlib 3.11 sys/__init__:.stderrscip-python python python-stdlib 3.11 sys/stderr.stderr..writescip-python python python-stdlib 3.11 typing/IO#write().("<<leaving %s (ret: %r)\n" % (thisFunc, ret)) |
| 5331 | return ret |
| 5332 | try: |
| 5333 | zscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/traceParseAction().z()..__name__ = fscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/traceParseAction().(f).__name__ |
| 5334 | except AttributeErrorscip-python python python-stdlib 3.11 builtins/AttributeError#: |
| 5335 | pass |
| 5336 | return zscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/traceParseAction().z(). |
| 5337 | |
| 5338 | # |
| 5339 | # global helpers |
| 5340 | # |
| 5341 | def delimitedListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(expr), delimscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(delim)=",", combinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(combine)=False): |
| 5342 | """Helper to define a delimited list of expressions - the delimiter |
| 5343 | defaults to ','. By default, the list elements and delimiters can |
| 5344 | have intervening whitespace, and comments, but this can be |
| 5345 | overridden by passing ``combine=True`` in the constructor. If |
| 5346 | ``combine`` is set to ``True``, the matching tokens are |
| 5347 | returned as a single token string, with the delimiters included; |
| 5348 | otherwise, the matching tokens are returned as a list of tokens, |
| 5349 | with the delimiters suppressed. |
| 5350 | |
| 5351 | Example:: |
| 5352 | |
| 5353 | delimitedList(Word(alphas)).parseString("aa,bb,cc") # -> ['aa', 'bb', 'cc'] |
| 5354 | delimitedList(Word(hexnums), delim=':', combine=True).parseString("AA:BB:CC:DD:EE") # -> ['AA:BB:CC:DD:EE'] |
| 5355 | """ |
| 5356 | dlName = _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(expr)) + " [" + _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(delimscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(delim)) + " " + _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(expr)) + "]..." |
| 5357 | if combinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(combine): |
| 5358 | return Combinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(expr) + ZeroOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#(delimscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(delim) + exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(expr))).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().(dlName) |
| 5359 | else: |
| 5360 | return (exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(expr) + ZeroOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#(Suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#(delimscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(delim)) + exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(expr))).setName(dlName) |
| 5361 | |
| 5362 | def countedArrayscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/countedArray().(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/countedArray().(expr), intExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/countedArray().(intExpr)=None): |
| 5363 | """Helper to define a counted list of expressions. |
| 5364 | |
| 5365 | This helper defines a pattern of the form:: |
| 5366 | |
| 5367 | integer expr expr expr... |
| 5368 | |
| 5369 | where the leading integer tells how many expr expressions follow. |
| 5370 | The matched tokens returns the array of expr tokens as a list - the |
| 5371 | leading count token is suppressed. |
| 5372 | |
| 5373 | If ``intExpr`` is specified, it should be a pyparsing expression |
| 5374 | that produces an integer value. |
| 5375 | |
| 5376 | Example:: |
| 5377 | |
| 5378 | countedArray(Word(alphas)).parseString('2 ab cd ef') # -> ['ab', 'cd'] |
| 5379 | |
| 5380 | # in this parser, the leading integer value is given in binary, |
| 5381 | # '10' indicating that 2 values are in the array |
| 5382 | binaryConstant = Word('01').setParseAction(lambda t: int(t[0], 2)) |
| 5383 | countedArray(Word(alphas), intExpr=binaryConstant).parseString('10 ab cd ef') # -> ['ab', 'cd'] |
| 5384 | """ |
| 5385 | arrayExpr = Forwardscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#() |
| 5386 | def countFieldParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/countedArray().countFieldParseAction().(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/countedArray().countFieldParseAction().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/countedArray().countFieldParseAction().(l), tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/countedArray().countFieldParseAction().(t)): |
| 5387 | n = tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/countedArray().countFieldParseAction().(t)[0] |
| 5388 | arrayExpr << (n and Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(Andscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#([exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/countedArray().(expr)] * n)) or Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(emptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/empty.)) |
| 5389 | return [] |
| 5390 | if intExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/countedArray().(intExpr) is None: |
| 5391 | intExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/countedArray().(intExpr) = Wordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#(numsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nums.).setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(lambda t: intscip-python python python-stdlib 3.11 builtins/int#(t[0])) |
| 5392 | else: |
| 5393 | intExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/countedArray().(intExpr) = intExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/countedArray().(intExpr).copy() |
| 5394 | intExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/countedArray().(intExpr).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("arrayLen") |
| 5395 | intExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/countedArray().(intExpr).addParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addParseAction().(countFieldParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/countedArray().countFieldParseAction()., callDuringTry=True) |
| 5396 | return (intExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/countedArray().(intExpr) + arrayExpr).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().('(len) ' + _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/countedArray().(expr)) + '...') |
| 5397 | |
| 5398 | def _flattenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_flatten().(Lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_flatten().(L)): |
| 5399 | ret = [] |
| 5400 | for i in Lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_flatten().(L): |
| 5401 | if isinstance(i, listscip-python python python-stdlib 3.11 builtins/list#): |
| 5402 | ret.extendscip-python python python-stdlib 3.11 builtins/list#extend().(_flattenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_flatten().(i)) |
| 5403 | else: |
| 5404 | ret.appendscip-python python python-stdlib 3.11 builtins/list#append().(i) |
| 5405 | return ret |
| 5406 | |
| 5407 | def matchPreviousLiteralscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousLiteral().(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousLiteral().(expr)): |
| 5408 | """Helper to define an expression that is indirectly defined from |
| 5409 | the tokens matched in a previous expression, that is, it looks for |
| 5410 | a 'repeat' of a previous expression. For example:: |
| 5411 | |
| 5412 | first = Word(nums) |
| 5413 | second = matchPreviousLiteral(first) |
| 5414 | matchExpr = first + ":" + second |
| 5415 | |
| 5416 | will match ``"1:1"``, but not ``"1:2"``. Because this |
| 5417 | matches a previous literal, will also match the leading |
| 5418 | ``"1:1"`` in ``"1:10"``. If this is not desired, use |
| 5419 | :class:`matchPreviousExpr`. Do *not* use with packrat parsing |
| 5420 | enabled. |
| 5421 | """ |
| 5422 | rep = Forwardscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#() |
| 5423 | def copyTokenToRepeaterscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousLiteral().copyTokenToRepeater().(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousLiteral().copyTokenToRepeater().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousLiteral().copyTokenToRepeater().(l), tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousLiteral().copyTokenToRepeater().(t)): |
| 5424 | if tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousLiteral().copyTokenToRepeater().(t): |
| 5425 | if len(tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousLiteral().copyTokenToRepeater().(t)) == 1: |
| 5426 | rep << tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousLiteral().copyTokenToRepeater().(t)[0] |
| 5427 | else: |
| 5428 | # flatten t tokens |
| 5429 | tflat = _flattenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_flatten().(tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousLiteral().copyTokenToRepeater().(t).asList()) |
| 5430 | rep << Andscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/And#(Literalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#(tt) for tt in tflat) |
| 5431 | else: |
| 5432 | rep << Emptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#() |
| 5433 | exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousLiteral().(expr).addParseAction(copyTokenToRepeaterscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousLiteral().copyTokenToRepeater()., callDuringTry=True) |
| 5434 | rep.setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().('(prev) ' + _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousLiteral().(expr))) |
| 5435 | return rep |
| 5436 | |
| 5437 | def matchPreviousExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousExpr().(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousExpr().(expr)): |
| 5438 | """Helper to define an expression that is indirectly defined from |
| 5439 | the tokens matched in a previous expression, that is, it looks for |
| 5440 | a 'repeat' of a previous expression. For example:: |
| 5441 | |
| 5442 | first = Word(nums) |
| 5443 | second = matchPreviousExpr(first) |
| 5444 | matchExpr = first + ":" + second |
| 5445 | |
| 5446 | will match ``"1:1"``, but not ``"1:2"``. Because this |
| 5447 | matches by expressions, will *not* match the leading ``"1:1"`` |
| 5448 | in ``"1:10"``; the expressions are evaluated first, and then |
| 5449 | compared, so ``"1"`` is compared with ``"10"``. Do *not* use |
| 5450 | with packrat parsing enabled. |
| 5451 | """ |
| 5452 | rep = Forwardscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#() |
| 5453 | e2 = exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousExpr().(expr).copy() |
| 5454 | rep <<= e2 |
| 5455 | def copyTokenToRepeaterscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousExpr().copyTokenToRepeater().(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousExpr().copyTokenToRepeater().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousExpr().copyTokenToRepeater().(l), tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousExpr().copyTokenToRepeater().(t)): |
| 5456 | matchTokens = _flattenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_flatten().(tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousExpr().copyTokenToRepeater().(t).asList()) |
| 5457 | def mustMatchTheseTokensscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousExpr().copyTokenToRepeater().mustMatchTheseTokens().(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousExpr().copyTokenToRepeater().mustMatchTheseTokens().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousExpr().copyTokenToRepeater().mustMatchTheseTokens().(l), tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousExpr().copyTokenToRepeater().mustMatchTheseTokens().(t)): |
| 5458 | theseTokens = _flattenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_flatten().(tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousExpr().copyTokenToRepeater().mustMatchTheseTokens().(t).asList()) |
| 5459 | if theseTokens != matchTokens: |
| 5460 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#('', 0, '') |
| 5461 | rep.setParseAction(mustMatchTheseTokensscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousExpr().copyTokenToRepeater().mustMatchTheseTokens()., callDuringTry=True) |
| 5462 | exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousExpr().(expr).addParseAction(copyTokenToRepeaterscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousExpr().copyTokenToRepeater()., callDuringTry=True) |
| 5463 | rep.setName('(prev) ' + _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchPreviousExpr().(expr))) |
| 5464 | return rep |
| 5465 | |
| 5466 | def _escapeRegexRangeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapeRegexRangeChars().(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapeRegexRangeChars().(s)): |
| 5467 | # ~ escape these chars: ^-[] |
| 5468 | for c in r"\^-[]": |
| 5469 | sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapeRegexRangeChars().(s) = sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapeRegexRangeChars().(s).replace(c, _bslashscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_bslash. + c) |
| 5470 | sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapeRegexRangeChars().(s) = sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapeRegexRangeChars().(s).replace("\n", r"\n") |
| 5471 | sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapeRegexRangeChars().(s) = sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapeRegexRangeChars().(s).replace("\t", r"\t") |
| 5472 | return _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapeRegexRangeChars().(s)) |
| 5473 | |
| 5474 | def oneOfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/oneOf().(strsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/oneOf().(strs), caselessscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/oneOf().(caseless)=False, useRegexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/oneOf().(useRegex)=True, asKeywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/oneOf().(asKeyword)=False): |
| 5475 | """Helper to quickly define a set of alternative Literals, and makes |
| 5476 | sure to do longest-first testing when there is a conflict, |
| 5477 | regardless of the input order, but returns |
| 5478 | a :class:`MatchFirst` for best performance. |
| 5479 | |
| 5480 | Parameters: |
| 5481 | |
| 5482 | - strs - a string of space-delimited literals, or a collection of |
| 5483 | string literals |
| 5484 | - caseless - (default= ``False``) - treat all literals as |
| 5485 | caseless |
| 5486 | - useRegex - (default= ``True``) - as an optimization, will |
| 5487 | generate a Regex object; otherwise, will generate |
| 5488 | a :class:`MatchFirst` object (if ``caseless=True`` or ``asKeyword=True``, or if |
| 5489 | creating a :class:`Regex` raises an exception) |
| 5490 | - asKeyword - (default=``False``) - enforce Keyword-style matching on the |
| 5491 | generated expressions |
| 5492 | |
| 5493 | Example:: |
| 5494 | |
| 5495 | comp_oper = oneOf("< = > <= >= !=") |
| 5496 | var = Word(alphas) |
| 5497 | number = Word(nums) |
| 5498 | term = var | number |
| 5499 | comparison_expr = term + comp_oper + term |
| 5500 | print(comparison_expr.searchString("B = 12 AA=23 B<=AA AA>12")) |
| 5501 | |
| 5502 | prints:: |
| 5503 | |
| 5504 | [['B', '=', '12'], ['AA', '=', '23'], ['B', '<=', 'AA'], ['AA', '>', '12']] |
| 5505 | """ |
| 5506 | if isinstance(caselessscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/oneOf().(caseless), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 5507 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("More than one string argument passed to oneOf, pass " |
| 5508 | "choices as a list or space-delimited string", stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 5509 | |
| 5510 | if caselessscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/oneOf().(caseless): |
| 5511 | isequal = (lambda a, b: a.upper() == b.upper()) |
| 5512 | masks = (lambda a, b: b.upper().startswith(a.upper())) |
| 5513 | parseElementClass = CaselessKeywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessKeyword# if asKeywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/oneOf().(asKeyword) else CaselessLiteralscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral# |
| 5514 | else: |
| 5515 | isequal = (lambda a, b: a == b) |
| 5516 | masks = (lambda a, b: b.startswith(a)) |
| 5517 | parseElementClass = Keywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword# if asKeywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/oneOf().(asKeyword) else Literalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal# |
| 5518 | |
| 5519 | symbols = [] |
| 5520 | if isinstance(strsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/oneOf().(strs), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 5521 | symbols = strsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/oneOf().(strs).splitscip-python python python-stdlib 3.11 builtins/str#split().() |
| 5522 | elif isinstance(strsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/oneOf().(strs), Iterablescip-python python python-stdlib 3.11 typing/Iterable#): |
| 5523 | symbols = listscip-python python python-stdlib 3.11 builtins/list#(strsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/oneOf().(strs)) |
| 5524 | else: |
| 5525 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("Invalid argument to oneOf, expected string or iterable", |
| 5526 | SyntaxWarningscip-python python python-stdlib 3.11 builtins/SyntaxWarning#, stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 5527 | if not symbols: |
| 5528 | return NoMatchscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/NoMatch#() |
| 5529 | |
| 5530 | if not asKeywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/oneOf().(asKeyword): |
| 5531 | # if not producing keywords, need to reorder to take care to avoid masking |
| 5532 | # longer choices with shorter ones |
| 5533 | i = 0 |
| 5534 | while i < len(symbols) - 1: |
| 5535 | cur = symbols[i] |
| 5536 | for j, other in enumeratescip-python python python-stdlib 3.11 builtins/enumerate#(symbols[i + 1:]): |
| 5537 | if isequal(other, cur): |
| 5538 | del symbols[i + j + 1] |
| 5539 | break |
| 5540 | elif masks(cur, other): |
| 5541 | del symbols[i + j + 1] |
| 5542 | symbols.insertscip-python python python-stdlib 3.11 builtins/list#insert().(i, other) |
| 5543 | break |
| 5544 | else: |
| 5545 | i += 1 |
| 5546 | |
| 5547 | if not (caselessscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/oneOf().(caseless) or asKeywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/oneOf().(asKeyword)) and useRegexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/oneOf().(useRegex): |
| 5548 | # ~ print (strs, "->", "|".join([_escapeRegexChars(sym) for sym in symbols])) |
| 5549 | try: |
| 5550 | if len(symbols) == len("".joinscip-python python python-stdlib 3.11 builtins/str#join().(symbols)): |
| 5551 | return Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#("[%s]" % "".joinscip-python python python-stdlib 3.11 builtins/str#join().(_escapeRegexRangeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapeRegexRangeChars().(sym) for sym in symbols)).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().(' | '.joinscip-python python python-stdlib 3.11 builtins/str#join().(symbols)) |
| 5552 | else: |
| 5553 | return Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#("|".joinscip-python python python-stdlib 3.11 builtins/str#join().(rescip-python python python-stdlib 3.11 re/__init__:.escapescip-python python python-stdlib 3.11 re/escape().(sym) for sym in symbols)).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().(' | '.joinscip-python python python-stdlib 3.11 builtins/str#join().(symbols)) |
| 5554 | except Exceptionscip-python python python-stdlib 3.11 builtins/Exception#: |
| 5555 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().("Exception creating Regex for oneOf, building MatchFirst", |
| 5556 | SyntaxWarningscip-python python python-stdlib 3.11 builtins/SyntaxWarning#, stacklevelscip-python python python-stdlib 3.11 _warnings/warn().(stacklevel)=2) |
| 5557 | |
| 5558 | # last resort, just use MatchFirst |
| 5559 | return MatchFirstscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/MatchFirst#(parseElementClass(sym) for sym in symbols).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().(' | '.joinscip-python python python-stdlib 3.11 builtins/str#join().(symbols)) |
| 5560 | |
| 5561 | def dictOfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/dictOf().(keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/dictOf().(key), valuescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/dictOf().(value)): |
| 5562 | """Helper to easily and clearly define a dictionary by specifying |
| 5563 | the respective patterns for the key and value. Takes care of |
| 5564 | defining the :class:`Dict`, :class:`ZeroOrMore`, and |
| 5565 | :class:`Group` tokens in the proper order. The key pattern |
| 5566 | can include delimiting markers or punctuation, as long as they are |
| 5567 | suppressed, thereby leaving the significant key text. The value |
| 5568 | pattern can include named results, so that the :class:`Dict` results |
| 5569 | can include named token fields. |
| 5570 | |
| 5571 | Example:: |
| 5572 | |
| 5573 | text = "shape: SQUARE posn: upper left color: light blue texture: burlap" |
| 5574 | attr_expr = (label + Suppress(':') + OneOrMore(data_word, stopOn=label).setParseAction(' '.join)) |
| 5575 | print(OneOrMore(attr_expr).parseString(text).dump()) |
| 5576 | |
| 5577 | attr_label = label |
| 5578 | attr_value = Suppress(':') + OneOrMore(data_word, stopOn=label).setParseAction(' '.join) |
| 5579 | |
| 5580 | # similar to Dict, but simpler call format |
| 5581 | result = dictOf(attr_label, attr_value).parseString(text) |
| 5582 | print(result.dump()) |
| 5583 | print(result['shape']) |
| 5584 | print(result.shape) # object attribute access works too |
| 5585 | print(result.asDict()) |
| 5586 | |
| 5587 | prints:: |
| 5588 | |
| 5589 | [['shape', 'SQUARE'], ['posn', 'upper left'], ['color', 'light blue'], ['texture', 'burlap']] |
| 5590 | - color: light blue |
| 5591 | - posn: upper left |
| 5592 | - shape: SQUARE |
| 5593 | - texture: burlap |
| 5594 | SQUARE |
| 5595 | SQUARE |
| 5596 | {'color': 'light blue', 'shape': 'SQUARE', 'posn': 'upper left', 'texture': 'burlap'} |
| 5597 | """ |
| 5598 | return Dictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#(OneOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#(Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(keyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/dictOf().(key) + valuescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/dictOf().(value)))) |
| 5599 | |
| 5600 | def originalTextForscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/originalTextFor().(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/originalTextFor().(expr), asStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/originalTextFor().(asString)=True): |
| 5601 | """Helper to return the original, untokenized text for a given |
| 5602 | expression. Useful to restore the parsed fields of an HTML start |
| 5603 | tag into the raw tag text itself, or to revert separate tokens with |
| 5604 | intervening whitespace back to the original matching input text. By |
| 5605 | default, returns astring containing the original parsed text. |
| 5606 | |
| 5607 | If the optional ``asString`` argument is passed as |
| 5608 | ``False``, then the return value is |
| 5609 | a :class:`ParseResults` containing any results names that |
| 5610 | were originally matched, and a single token containing the original |
| 5611 | matched text from the input string. So if the expression passed to |
| 5612 | :class:`originalTextFor` contains expressions with defined |
| 5613 | results names, you must set ``asString`` to ``False`` if you |
| 5614 | want to preserve those results name values. |
| 5615 | |
| 5616 | Example:: |
| 5617 | |
| 5618 | src = "this is test <b> bold <i>text</i> </b> normal text " |
| 5619 | for tag in ("b", "i"): |
| 5620 | opener, closer = makeHTMLTags(tag) |
| 5621 | patt = originalTextFor(opener + SkipTo(closer) + closer) |
| 5622 | print(patt.searchString(src)[0]) |
| 5623 | |
| 5624 | prints:: |
| 5625 | |
| 5626 | ['<b> bold <i>text</i> </b>'] |
| 5627 | ['<i>text</i>'] |
| 5628 | """ |
| 5629 | locMarker = Emptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#().setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(lambda s, loc, t: loc) |
| 5630 | endlocMarker = locMarker.copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().() |
| 5631 | endlocMarker.callPreparsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#callPreparse. = False |
| 5632 | matchExpr = locMarker("_original_start") + exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/originalTextFor().(expr) + endlocMarker("_original_end") |
| 5633 | if asStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/originalTextFor().(asString): |
| 5634 | extractText = lambda s, l, t: s[t._original_start: t._original_end] |
| 5635 | else: |
| 5636 | def extractText(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/originalTextFor().extractText().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/originalTextFor().extractText().(l), tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/originalTextFor().extractText().(t)): |
| 5637 | tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/originalTextFor().extractText().(t)[:] = [sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/originalTextFor().extractText().(s)[tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/originalTextFor().extractText().(t).pop('_original_start'):tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/originalTextFor().extractText().(t).pop('_original_end')]] |
| 5638 | matchExpr.setParseAction(extractText) |
| 5639 | matchExpr.ignoreExprs = exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/originalTextFor().(expr).ignoreExprs |
| 5640 | return matchExpr |
| 5641 | |
| 5642 | def ungroupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ungroup().(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ungroup().(expr)): |
| 5643 | """Helper to undo pyparsing's default grouping of And expressions, |
| 5644 | even if all but one are non-empty. |
| 5645 | """ |
| 5646 | return TokenConverterscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/TokenConverter#(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ungroup().(expr)).addParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addParseAction().(lambda t: t[0]) |
| 5647 | |
| 5648 | def locatedExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/locatedExpr().(exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/locatedExpr().(expr)): |
| 5649 | """Helper to decorate a returned token with its starting and ending |
| 5650 | locations in the input string. |
| 5651 | |
| 5652 | This helper adds the following results names: |
| 5653 | |
| 5654 | - locn_start = location where matched expression begins |
| 5655 | - locn_end = location where matched expression ends |
| 5656 | - value = the actual parsed results |
| 5657 | |
| 5658 | Be careful if the input text contains ``<TAB>`` characters, you |
| 5659 | may want to call :class:`ParserElement.parseWithTabs` |
| 5660 | |
| 5661 | Example:: |
| 5662 | |
| 5663 | wd = Word(alphas) |
| 5664 | for match in locatedExpr(wd).searchString("ljsdf123lksdjjf123lkkjj1222"): |
| 5665 | print(match) |
| 5666 | |
| 5667 | prints:: |
| 5668 | |
| 5669 | [[0, 'ljsdf', 5]] |
| 5670 | [[8, 'lksdjjf', 15]] |
| 5671 | [[18, 'lkkjj', 23]] |
| 5672 | """ |
| 5673 | locator = Emptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#().setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(lambda s, l, t: l) |
| 5674 | return Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(locator("locn_start") + exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/locatedExpr().(expr)("value") + locator.copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().().leaveWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#leaveWhitespace().()("locn_end")) |
| 5675 | |
| 5676 | |
| 5677 | # convenience constants for positional expressions |
| 5678 | emptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/empty. = Emptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#().setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("empty") |
| 5679 | lineStartscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/lineStart. = LineStartscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineStart#().setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("lineStart") |
| 5680 | lineEndscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/lineEnd. = LineEndscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#().setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("lineEnd") |
| 5681 | stringStartscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/stringStart. = StringStartscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringStart#().setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("stringStart") |
| 5682 | stringEndscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/stringEnd. = StringEndscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#().setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("stringEnd") |
| 5683 | |
| 5684 | _escapedPuncscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapedPunc. = Wordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#(_bslashscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_bslash., r"\[]-*.$+^?()~ ", exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(exact)=2).setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(lambda s, l, t: t[0][1]) |
| 5685 | _escapedHexCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapedHexChar. = Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r"\\0?[xX][0-9a-fA-F]+").setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(lambda s, l, t: unichrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unichr.(intscip-python python python-stdlib 3.11 builtins/int#(t[0].lstrip(r'\0x'), 16))) |
| 5686 | _escapedOctCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapedOctChar. = Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r"\\0[0-7]+").setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(lambda s, l, t: unichrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unichr.(intscip-python python python-stdlib 3.11 builtins/int#(t[0][1:], 8))) |
| 5687 | _singleCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_singleChar. = _escapedPuncscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapedPunc. | _escapedHexCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapedHexChar. | _escapedOctCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_escapedOctChar. | CharsNotInscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#(r'\]', exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(exact)=1) |
| 5688 | _charRangescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_charRange. = Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(_singleCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_singleChar. + Suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#("-") + _singleCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_singleChar.) |
| 5689 | _reBracketExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_reBracketExpr. = Literalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#("[") + Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#("^").setResultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setResultsName().("negate") + Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(OneOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#(_charRangescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_charRange. | _singleCharscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_singleChar.)).setResultsNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setResultsName().("body") + "]" |
| 5690 | |
| 5691 | def srangescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/srange().(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/srange().(s)): |
| 5692 | r"""Helper to easily define string ranges for use in Word |
| 5693 | construction. Borrows syntax from regexp '[]' string range |
| 5694 | definitions:: |
| 5695 | |
| 5696 | srange("[0-9]") -> "0123456789" |
| 5697 | srange("[a-z]") -> "abcdefghijklmnopqrstuvwxyz" |
| 5698 | srange("[a-z$_]") -> "abcdefghijklmnopqrstuvwxyz$_" |
| 5699 | |
| 5700 | The input string must be enclosed in []'s, and the returned string |
| 5701 | is the expanded character set joined into a single string. The |
| 5702 | values enclosed in the []'s may be: |
| 5703 | |
| 5704 | - a single character |
| 5705 | - an escaped character with a leading backslash (such as ``\-`` |
| 5706 | or ``\]``) |
| 5707 | - an escaped hex character with a leading ``'\x'`` |
| 5708 | (``\x21``, which is a ``'!'`` character) (``\0x##`` |
| 5709 | is also supported for backwards compatibility) |
| 5710 | - an escaped octal character with a leading ``'\0'`` |
| 5711 | (``\041``, which is a ``'!'`` character) |
| 5712 | - a range of any of the above, separated by a dash (``'a-z'``, |
| 5713 | etc.) |
| 5714 | - any combination of the above (``'aeiouy'``, |
| 5715 | ``'a-zA-Z0-9_$'``, etc.) |
| 5716 | """ |
| 5717 | _expanded = lambda p: p if not isinstance(p, ParseResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseResults#) else ''.joinscip-python python python-stdlib 3.11 builtins/str#join().(unichrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unichr.(c) for c in rangescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/range.(ord(p[0]), ord(p[1]) + 1)) |
| 5718 | try: |
| 5719 | return "".joinscip-python python python-stdlib 3.11 builtins/str#join().(_expanded(part) for part in _reBracketExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_reBracketExpr..parseString(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/srange().(s)).body) |
| 5720 | except Exceptionscip-python python python-stdlib 3.11 builtins/Exception#: |
| 5721 | return "" |
| 5722 | |
| 5723 | def matchOnlyAtColscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchOnlyAtCol().(nscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchOnlyAtCol().(n)): |
| 5724 | """Helper method for defining parse actions that require matching at |
| 5725 | a specific column in the input text. |
| 5726 | """ |
| 5727 | def verifyColscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchOnlyAtCol().verifyCol().(strgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchOnlyAtCol().verifyCol().(strg), locnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchOnlyAtCol().verifyCol().(locn), toksscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchOnlyAtCol().verifyCol().(toks)): |
| 5728 | if colscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/col().(locnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchOnlyAtCol().verifyCol().(locn), strgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchOnlyAtCol().verifyCol().(strg)) != nscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchOnlyAtCol().(n): |
| 5729 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(strgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchOnlyAtCol().verifyCol().(strg), locnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchOnlyAtCol().verifyCol().(locn), "matched token not at column %d" % nscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchOnlyAtCol().(n)) |
| 5730 | return verifyColscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/matchOnlyAtCol().verifyCol(). |
| 5731 | |
| 5732 | def replaceWithscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/replaceWith().(replStrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/replaceWith().(replStr)): |
| 5733 | """Helper method for common parse actions that simply return |
| 5734 | a literal value. Especially useful when used with |
| 5735 | :class:`transformString<ParserElement.transformString>` (). |
| 5736 | |
| 5737 | Example:: |
| 5738 | |
| 5739 | num = Word(nums).setParseAction(lambda toks: int(toks[0])) |
| 5740 | na = oneOf("N/A NA").setParseAction(replaceWith(math.nan)) |
| 5741 | term = na | num |
| 5742 | |
| 5743 | OneOrMore(term).parseString("324 234 N/A 234") # -> [324, 234, nan, 234] |
| 5744 | """ |
| 5745 | return lambda s, l, t: [replStrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/replaceWith().(replStr)] |
| 5746 | |
| 5747 | def removeQuotesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/removeQuotes().(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/removeQuotes().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/removeQuotes().(l), tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/removeQuotes().(t)): |
| 5748 | """Helper parse action for removing quotation marks from parsed |
| 5749 | quoted strings. |
| 5750 | |
| 5751 | Example:: |
| 5752 | |
| 5753 | # by default, quotation marks are included in parsed results |
| 5754 | quotedString.parseString("'Now is the Winter of our Discontent'") # -> ["'Now is the Winter of our Discontent'"] |
| 5755 | |
| 5756 | # use removeQuotes to strip quotation marks from parsed results |
| 5757 | quotedString.setParseAction(removeQuotes) |
| 5758 | quotedString.parseString("'Now is the Winter of our Discontent'") # -> ["Now is the Winter of our Discontent"] |
| 5759 | """ |
| 5760 | return tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/removeQuotes().(t)[0][1:-1] |
| 5761 | |
| 5762 | def tokenMapscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().(funcscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().(func), *argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().(args)): |
| 5763 | """Helper to define a parse action by mapping a function to all |
| 5764 | elements of a ParseResults list. If any additional args are passed, |
| 5765 | they are forwarded to the given function as additional arguments |
| 5766 | after the token, as in |
| 5767 | ``hex_integer = Word(hexnums).setParseAction(tokenMap(int, 16))``, |
| 5768 | which will convert the parsed data to an integer using base 16. |
| 5769 | |
| 5770 | Example (compare the last to example in :class:`ParserElement.transformString`:: |
| 5771 | |
| 5772 | hex_ints = OneOrMore(Word(hexnums)).setParseAction(tokenMap(int, 16)) |
| 5773 | hex_ints.runTests(''' |
| 5774 | 00 11 22 aa FF 0a 0d 1a |
| 5775 | ''') |
| 5776 | |
| 5777 | upperword = Word(alphas).setParseAction(tokenMap(str.upper)) |
| 5778 | OneOrMore(upperword).runTests(''' |
| 5779 | my kingdom for a horse |
| 5780 | ''') |
| 5781 | |
| 5782 | wd = Word(alphas).setParseAction(tokenMap(str.title)) |
| 5783 | OneOrMore(wd).setParseAction(' '.join).runTests(''' |
| 5784 | now is the winter of our discontent made glorious summer by this sun of york |
| 5785 | ''') |
| 5786 | |
| 5787 | prints:: |
| 5788 | |
| 5789 | 00 11 22 aa FF 0a 0d 1a |
| 5790 | [0, 17, 34, 170, 255, 10, 13, 26] |
| 5791 | |
| 5792 | my kingdom for a horse |
| 5793 | ['MY', 'KINGDOM', 'FOR', 'A', 'HORSE'] |
| 5794 | |
| 5795 | now is the winter of our discontent made glorious summer by this sun of york |
| 5796 | ['Now Is The Winter Of Our Discontent Made Glorious Summer By This Sun Of York'] |
| 5797 | """ |
| 5798 | def pascip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().pa().(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().pa().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().pa().(l), tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().pa().(t)): |
| 5799 | return [funcscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().(func)(tokn, *argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().(args)) for tokn in tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().pa().(t)] |
| 5800 | |
| 5801 | try: |
| 5802 | func_name = getattrscip-python python python-stdlib 3.11 builtins/getattr().(funcscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().(func), '__name__', |
| 5803 | getattrscip-python python python-stdlib 3.11 builtins/getattr().(funcscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().(func), '__class__').__name__) |
| 5804 | except Exceptionscip-python python python-stdlib 3.11 builtins/Exception#: |
| 5805 | func_name = strscip-python python python-stdlib 3.11 builtins/str#(funcscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().(func)) |
| 5806 | pascip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().pa()..__name__ = func_name |
| 5807 | |
| 5808 | return pascip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().pa(). |
| 5809 | |
| 5810 | upcaseTokensscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/upcaseTokens. = tokenMapscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().(lambda t: _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(t).upperscip-python python python-stdlib 3.11 builtins/str#upper().()) |
| 5811 | """(Deprecated) Helper parse action to convert tokens to upper case. |
| 5812 | Deprecated in favor of :class:`pyparsing_common.upcaseTokens`""" |
| 5813 | |
| 5814 | downcaseTokensscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/downcaseTokens. = tokenMapscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().(lambda t: _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(t).lowerscip-python python python-stdlib 3.11 builtins/str#lower().()) |
| 5815 | """(Deprecated) Helper parse action to convert tokens to lower case. |
| 5816 | Deprecated in favor of :class:`pyparsing_common.downcaseTokens`""" |
| 5817 | |
| 5818 | def _makeTagsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_makeTags().(tagStrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_makeTags().(tagStr), xmlscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_makeTags().(xml), |
| 5819 | suppress_LTscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_makeTags().(suppress_LT)=Suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#("<"), |
| 5820 | suppress_GTscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_makeTags().(suppress_GT)=Suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#(">")): |
| 5821 | """Internal helper to construct opening and closing tag expressions, given a tag name""" |
| 5822 | if isinstance(tagStrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_makeTags().(tagStr), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 5823 | resname = tagStrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_makeTags().(tagStr) |
| 5824 | tagStrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_makeTags().(tagStr) = Keywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#(tagStrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_makeTags().(tagStr), caselessscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#__init__().(caseless)=not xmlscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_makeTags().(xml)) |
| 5825 | else: |
| 5826 | resname = tagStrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_makeTags().(tagStr).name |
| 5827 | |
| 5828 | tagAttrName = Wordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#(alphasscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/alphas., alphanumsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/alphanums. + "_-:") |
| 5829 | if xmlscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_makeTags().(xml): |
| 5830 | tagAttrValue = dblQuotedStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/dblQuotedString..copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().().setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(removeQuotesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/removeQuotes().) |
| 5831 | openTag = (suppress_LTscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_makeTags().(suppress_LT) |
| 5832 | + tagStrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_makeTags().(tagStr)("tag") |
| 5833 | + Dictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#(ZeroOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#(Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(tagAttrName + Suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#("=") + tagAttrValue))) |
| 5834 | + Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#("/", defaultscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__init__().(default)=[False])("empty").setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(lambda s, l, t: t[0] == '/') |
| 5835 | + suppress_GTscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_makeTags().(suppress_GT)) |
| 5836 | else: |
| 5837 | tagAttrValue = quotedStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/quotedString..copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().().setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(removeQuotesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/removeQuotes().) | Wordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#(printablesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/printables., excludeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(excludeChars)=">") |
| 5838 | openTag = (suppress_LTscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_makeTags().(suppress_LT) |
| 5839 | + tagStrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_makeTags().(tagStr)("tag") |
| 5840 | + Dictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Dict#(ZeroOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#(Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(tagAttrName.setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(downcaseTokensscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/downcaseTokens.) |
| 5841 | + Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#(Suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#("=") + tagAttrValue)))) |
| 5842 | + Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#("/", defaultscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__init__().(default)=[False])("empty").setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(lambda s, l, t: t[0] == '/') |
| 5843 | + suppress_GTscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_makeTags().(suppress_GT)) |
| 5844 | closeTag = Combinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#(_Lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_L.("</") + tagStrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_makeTags().(tagStr) + ">", adjacentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#__init__().(adjacent)=False) |
| 5845 | |
| 5846 | openTag.setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("<%s>" % resname) |
| 5847 | # add start<tagname> results name in parse action now that ungrouped names are not reported at two levels |
| 5848 | openTag.addParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addParseAction().(lambda t: t.__setitem__("start" + "".joinscip-python python python-stdlib 3.11 builtins/str#join().(resname.replacescip-python python python-stdlib 3.11 builtins/str#replace().(":", " ").titlescip-python python python-stdlib 3.11 builtins/str#title().().splitscip-python python python-stdlib 3.11 builtins/str#split().()), t.copy())) |
| 5849 | closeTag = closeTag("end" + "".joinscip-python python python-stdlib 3.11 builtins/str#join().(resname.replacescip-python python python-stdlib 3.11 builtins/str#replace().(":", " ").titlescip-python python python-stdlib 3.11 builtins/str#title().().splitscip-python python python-stdlib 3.11 builtins/str#split().())).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("</%s>" % resname) |
| 5850 | openTag.tag = resname |
| 5851 | closeTag.tag = resname |
| 5852 | openTag.tag_body = SkipToscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/SkipTo#(closeTag()) |
| 5853 | return openTag, closeTag |
| 5854 | |
| 5855 | def makeHTMLTagsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/makeHTMLTags().(tagStrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/makeHTMLTags().(tagStr)): |
| 5856 | """Helper to construct opening and closing tag expressions for HTML, |
| 5857 | given a tag name. Matches tags in either upper or lower case, |
| 5858 | attributes with namespaces and with quoted or unquoted values. |
| 5859 | |
| 5860 | Example:: |
| 5861 | |
| 5862 | text = '<td>More info at the <a href="https://github.com/pyparsing/pyparsing/wiki">pyparsing</a> wiki page</td>' |
| 5863 | # makeHTMLTags returns pyparsing expressions for the opening and |
| 5864 | # closing tags as a 2-tuple |
| 5865 | a, a_end = makeHTMLTags("A") |
| 5866 | link_expr = a + SkipTo(a_end)("link_text") + a_end |
| 5867 | |
| 5868 | for link in link_expr.searchString(text): |
| 5869 | # attributes in the <A> tag (like "href" shown here) are |
| 5870 | # also accessible as named results |
| 5871 | print(link.link_text, '->', link.href) |
| 5872 | |
| 5873 | prints:: |
| 5874 | |
| 5875 | pyparsing -> https://github.com/pyparsing/pyparsing/wiki |
| 5876 | """ |
| 5877 | return _makeTagsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_makeTags().(tagStrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/makeHTMLTags().(tagStr), False) |
| 5878 | |
| 5879 | def makeXMLTagsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/makeXMLTags().(tagStrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/makeXMLTags().(tagStr)): |
| 5880 | """Helper to construct opening and closing tag expressions for XML, |
| 5881 | given a tag name. Matches tags only in the given upper/lower case. |
| 5882 | |
| 5883 | Example: similar to :class:`makeHTMLTags` |
| 5884 | """ |
| 5885 | return _makeTagsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_makeTags().(tagStrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/makeXMLTags().(tagStr), True) |
| 5886 | |
| 5887 | def withAttributescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withAttribute().(*argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withAttribute().(args), **attrDictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withAttribute().(attrDict)): |
| 5888 | """Helper to create a validating parse action to be used with start |
| 5889 | tags created with :class:`makeXMLTags` or |
| 5890 | :class:`makeHTMLTags`. Use ``withAttribute`` to qualify |
| 5891 | a starting tag with a required attribute value, to avoid false |
| 5892 | matches on common tags such as ``<TD>`` or ``<DIV>``. |
| 5893 | |
| 5894 | Call ``withAttribute`` with a series of attribute names and |
| 5895 | values. Specify the list of filter attributes names and values as: |
| 5896 | |
| 5897 | - keyword arguments, as in ``(align="right")``, or |
| 5898 | - as an explicit dict with ``**`` operator, when an attribute |
| 5899 | name is also a Python reserved word, as in ``**{"class":"Customer", "align":"right"}`` |
| 5900 | - a list of name-value tuples, as in ``(("ns1:class", "Customer"), ("ns2:align", "right"))`` |
| 5901 | |
| 5902 | For attribute names with a namespace prefix, you must use the second |
| 5903 | form. Attribute names are matched insensitive to upper/lower case. |
| 5904 | |
| 5905 | If just testing for ``class`` (with or without a namespace), use |
| 5906 | :class:`withClass`. |
| 5907 | |
| 5908 | To verify that the attribute exists, but without specifying a value, |
| 5909 | pass ``withAttribute.ANY_VALUE`` as the value. |
| 5910 | |
| 5911 | Example:: |
| 5912 | |
| 5913 | html = ''' |
| 5914 | <div> |
| 5915 | Some text |
| 5916 | <div type="grid">1 4 0 1 0</div> |
| 5917 | <div type="graph">1,3 2,3 1,1</div> |
| 5918 | <div>this has no type</div> |
| 5919 | </div> |
| 5920 | |
| 5921 | ''' |
| 5922 | div,div_end = makeHTMLTags("div") |
| 5923 | |
| 5924 | # only match div tag having a type attribute with value "grid" |
| 5925 | div_grid = div().setParseAction(withAttribute(type="grid")) |
| 5926 | grid_expr = div_grid + SkipTo(div | div_end)("body") |
| 5927 | for grid_header in grid_expr.searchString(html): |
| 5928 | print(grid_header.body) |
| 5929 | |
| 5930 | # construct a match with any div tag having a type attribute, regardless of the value |
| 5931 | div_any_type = div().setParseAction(withAttribute(type=withAttribute.ANY_VALUE)) |
| 5932 | div_expr = div_any_type + SkipTo(div | div_end)("body") |
| 5933 | for div_header in div_expr.searchString(html): |
| 5934 | print(div_header.body) |
| 5935 | |
| 5936 | prints:: |
| 5937 | |
| 5938 | 1 4 0 1 0 |
| 5939 | |
| 5940 | 1 4 0 1 0 |
| 5941 | 1,3 2,3 1,1 |
| 5942 | """ |
| 5943 | if argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withAttribute().(args): |
| 5944 | attrs = argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withAttribute().(args)[:] |
| 5945 | else: |
| 5946 | attrs = attrDictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withAttribute().(attrDict).itemsscip-python python python-stdlib 3.11 builtins/dict#items().() |
| 5947 | attrs = [(k, v) for k, v in attrs] |
| 5948 | def pascip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withAttribute().pa().(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withAttribute().pa().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withAttribute().pa().(l), tokensscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withAttribute().pa().(tokens)): |
| 5949 | for attrName, attrValue in attrs: |
| 5950 | if attrName not in tokensscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withAttribute().pa().(tokens): |
| 5951 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withAttribute().pa().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withAttribute().pa().(l), "no matching attribute " + attrName) |
| 5952 | if attrValue != withAttributescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withAttribute()..ANY_VALUE and tokensscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withAttribute().pa().(tokens)[attrName] != attrValue: |
| 5953 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withAttribute().pa().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withAttribute().pa().(l), "attribute '%s' has value '%s', must be '%s'" % |
| 5954 | (attrName, tokensscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withAttribute().pa().(tokens)[attrName], attrValue)) |
| 5955 | return pascip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withAttribute().pa(). |
| 5956 | withAttributescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withAttribute()..ANY_VALUE = objectscip-python python python-stdlib 3.11 builtins/object#() |
| 5957 | |
| 5958 | def withClassscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withClass().(classnamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withClass().(classname), namespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withClass().(namespace)=''): |
| 5959 | """Simplified version of :class:`withAttribute` when |
| 5960 | matching on a div class - made difficult because ``class`` is |
| 5961 | a reserved word in Python. |
| 5962 | |
| 5963 | Example:: |
| 5964 | |
| 5965 | html = ''' |
| 5966 | <div> |
| 5967 | Some text |
| 5968 | <div class="grid">1 4 0 1 0</div> |
| 5969 | <div class="graph">1,3 2,3 1,1</div> |
| 5970 | <div>this <div> has no class</div> |
| 5971 | </div> |
| 5972 | |
| 5973 | ''' |
| 5974 | div,div_end = makeHTMLTags("div") |
| 5975 | div_grid = div().setParseAction(withClass("grid")) |
| 5976 | |
| 5977 | grid_expr = div_grid + SkipTo(div | div_end)("body") |
| 5978 | for grid_header in grid_expr.searchString(html): |
| 5979 | print(grid_header.body) |
| 5980 | |
| 5981 | div_any_type = div().setParseAction(withClass(withAttribute.ANY_VALUE)) |
| 5982 | div_expr = div_any_type + SkipTo(div | div_end)("body") |
| 5983 | for div_header in div_expr.searchString(html): |
| 5984 | print(div_header.body) |
| 5985 | |
| 5986 | prints:: |
| 5987 | |
| 5988 | 1 4 0 1 0 |
| 5989 | |
| 5990 | 1 4 0 1 0 |
| 5991 | 1,3 2,3 1,1 |
| 5992 | """ |
| 5993 | classattr = "%s:class" % namespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withClass().(namespace) if namespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withClass().(namespace) else "class" |
| 5994 | return withAttributescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withAttribute().(**{classattr: classnamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/withClass().(classname)}) |
| 5995 | |
| 5996 | opAssocscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/opAssoc. = SimpleNamespacescip-python python python-stdlib 3.11 types/SimpleNamespace#() |
| 5997 | opAssocscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/opAssoc..LEFT = objectscip-python python python-stdlib 3.11 builtins/object#() |
| 5998 | opAssocscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/opAssoc..RIGHT = objectscip-python python python-stdlib 3.11 builtins/object#() |
| 5999 | |
| 6000 | def infixNotationscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation().(baseExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation().(baseExpr), opListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation().(opList), lparscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation().(lpar)=Suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#('('), rparscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation().(rpar)=Suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#(')')): |
| 6001 | """Helper method for constructing grammars of expressions made up of |
| 6002 | operators working in a precedence hierarchy. Operators may be unary |
| 6003 | or binary, left- or right-associative. Parse actions can also be |
| 6004 | attached to operator expressions. The generated parser will also |
| 6005 | recognize the use of parentheses to override operator precedences |
| 6006 | (see example below). |
| 6007 | |
| 6008 | Note: if you define a deep operator list, you may see performance |
| 6009 | issues when using infixNotation. See |
| 6010 | :class:`ParserElement.enablePackrat` for a mechanism to potentially |
| 6011 | improve your parser performance. |
| 6012 | |
| 6013 | Parameters: |
| 6014 | - baseExpr - expression representing the most basic element for the |
| 6015 | nested |
| 6016 | - opList - list of tuples, one for each operator precedence level |
| 6017 | in the expression grammar; each tuple is of the form ``(opExpr, |
| 6018 | numTerms, rightLeftAssoc, parseAction)``, where: |
| 6019 | |
| 6020 | - opExpr is the pyparsing expression for the operator; may also |
| 6021 | be a string, which will be converted to a Literal; if numTerms |
| 6022 | is 3, opExpr is a tuple of two expressions, for the two |
| 6023 | operators separating the 3 terms |
| 6024 | - numTerms is the number of terms for this operator (must be 1, |
| 6025 | 2, or 3) |
| 6026 | - rightLeftAssoc is the indicator whether the operator is right |
| 6027 | or left associative, using the pyparsing-defined constants |
| 6028 | ``opAssoc.RIGHT`` and ``opAssoc.LEFT``. |
| 6029 | - parseAction is the parse action to be associated with |
| 6030 | expressions matching this operator expression (the parse action |
| 6031 | tuple member may be omitted); if the parse action is passed |
| 6032 | a tuple or list of functions, this is equivalent to calling |
| 6033 | ``setParseAction(*fn)`` |
| 6034 | (:class:`ParserElement.setParseAction`) |
| 6035 | - lpar - expression for matching left-parentheses |
| 6036 | (default= ``Suppress('(')``) |
| 6037 | - rpar - expression for matching right-parentheses |
| 6038 | (default= ``Suppress(')')``) |
| 6039 | |
| 6040 | Example:: |
| 6041 | |
| 6042 | # simple example of four-function arithmetic with ints and |
| 6043 | # variable names |
| 6044 | integer = pyparsing_common.signed_integer |
| 6045 | varname = pyparsing_common.identifier |
| 6046 | |
| 6047 | arith_expr = infixNotation(integer | varname, |
| 6048 | [ |
| 6049 | ('-', 1, opAssoc.RIGHT), |
| 6050 | (oneOf('* /'), 2, opAssoc.LEFT), |
| 6051 | (oneOf('+ -'), 2, opAssoc.LEFT), |
| 6052 | ]) |
| 6053 | |
| 6054 | arith_expr.runTests(''' |
| 6055 | 5+3*6 |
| 6056 | (5+3)*6 |
| 6057 | -2--11 |
| 6058 | ''', fullDump=False) |
| 6059 | |
| 6060 | prints:: |
| 6061 | |
| 6062 | 5+3*6 |
| 6063 | [[5, '+', [3, '*', 6]]] |
| 6064 | |
| 6065 | (5+3)*6 |
| 6066 | [[[5, '+', 3], '*', 6]] |
| 6067 | |
| 6068 | -2--11 |
| 6069 | [[['-', 2], '-', ['-', 11]]] |
| 6070 | """ |
| 6071 | # captive version of FollowedBy that does not do parse actions or capture results names |
| 6072 | class _FBscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation()._FB#(FollowedByscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/FollowedBy#): |
| 6073 | def parseImplscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation()._FB#parseImpl().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation()._FB#parseImpl().(self), instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation()._FB#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation()._FB#parseImpl().(loc), doActionsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation()._FB#parseImpl().(doActions)=True): |
| 6074 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation()._FB#parseImpl().(self).exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr..tryParsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#tryParse().(instringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation()._FB#parseImpl().(instring), locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation()._FB#parseImpl().(loc)) |
| 6075 | return locscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation()._FB#parseImpl().(loc), [] |
| 6076 | |
| 6077 | ret = Forwardscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#() |
| 6078 | lastExpr = baseExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation().(baseExpr) | (lparscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation().(lpar) + ret + rparscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation().(rpar)) |
| 6079 | for i, operDef in enumeratescip-python python python-stdlib 3.11 builtins/enumerate#(opListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation().(opList)): |
| 6080 | opExpr, arity, rightLeftAssoc, pa = (operDef + (None, ))[:4] |
| 6081 | termName = "%s term" % opExpr if arity < 3 else "%s%s term" % opExpr |
| 6082 | if arity == 3: |
| 6083 | if opExpr is None or len(opExpr) != 2: |
| 6084 | raise ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#( |
| 6085 | "if numterms=3, opExpr must be a tuple or list of two expressions") |
| 6086 | opExpr1, opExpr2 = opExpr |
| 6087 | thisExpr = Forwardscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#().setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().(termName) |
| 6088 | if rightLeftAssoc == opAssocscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/opAssoc..LEFT: |
| 6089 | if arity == 1: |
| 6090 | matchExpr = _FBscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation()._FB#(lastExpr + opExpr) + Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(lastExpr + OneOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#(opExpr)) |
| 6091 | elif arity == 2: |
| 6092 | if opExpr is not None: |
| 6093 | matchExpr = _FBscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation()._FB#(lastExpr + opExpr + lastExpr) + Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(lastExpr + OneOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#(opExpr + lastExpr)) |
| 6094 | else: |
| 6095 | matchExpr = _FBscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation()._FB#(lastExpr + lastExpr) + Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(lastExpr + OneOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#(lastExpr)) |
| 6096 | elif arity == 3: |
| 6097 | matchExpr = (_FBscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation()._FB#(lastExpr + opExpr1 + lastExpr + opExpr2 + lastExpr) |
| 6098 | + Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(lastExpr + OneOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#(opExpr1 + lastExpr + opExpr2 + lastExpr))) |
| 6099 | else: |
| 6100 | raise ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#("operator must be unary (1), binary (2), or ternary (3)") |
| 6101 | elif rightLeftAssoc == opAssocscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/opAssoc..RIGHT: |
| 6102 | if arity == 1: |
| 6103 | # try to avoid LR with this extra test |
| 6104 | if not isinstance(opExpr, Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#): |
| 6105 | opExpr = Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#(opExpr) |
| 6106 | matchExpr = _FBscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation()._FB#(opExpr.exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#expr. + thisExpr) + Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(opExpr + thisExpr) |
| 6107 | elif arity == 2: |
| 6108 | if opExpr is not None: |
| 6109 | matchExpr = _FBscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation()._FB#(lastExpr + opExpr + thisExpr) + Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(lastExpr + OneOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#(opExpr + thisExpr)) |
| 6110 | else: |
| 6111 | matchExpr = _FBscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation()._FB#(lastExpr + thisExpr) + Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(lastExpr + OneOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#(thisExpr)) |
| 6112 | elif arity == 3: |
| 6113 | matchExpr = (_FBscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation()._FB#(lastExpr + opExpr1 + thisExpr + opExpr2 + thisExpr) |
| 6114 | + Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(lastExpr + opExpr1 + thisExpr + opExpr2 + thisExpr)) |
| 6115 | else: |
| 6116 | raise ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#("operator must be unary (1), binary (2), or ternary (3)") |
| 6117 | else: |
| 6118 | raise ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#("operator must indicate right or left associativity") |
| 6119 | if pa: |
| 6120 | if isinstance(pa, (tuplescip-python python python-stdlib 3.11 builtins/tuple#, listscip-python python python-stdlib 3.11 builtins/list#)): |
| 6121 | matchExpr.setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(*pa) |
| 6122 | else: |
| 6123 | matchExpr.setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(pa) |
| 6124 | thisExpr <<= (matchExpr.setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().(termName) | lastExpr) |
| 6125 | lastExpr = thisExpr |
| 6126 | ret <<= lastExpr |
| 6127 | return ret |
| 6128 | |
| 6129 | operatorPrecedencescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/operatorPrecedence. = infixNotationscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/infixNotation(). |
| 6130 | """(Deprecated) Former name of :class:`infixNotation`, will be |
| 6131 | dropped in a future release.""" |
| 6132 | |
| 6133 | dblQuotedStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/dblQuotedString. = Combinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#(Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r'"(?:[^"\n\r\\]|(?:"")|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*') + '"').setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("string enclosed in double quotes") |
| 6134 | sglQuotedStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/sglQuotedString. = Combinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#(Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r"'(?:[^'\n\r\\]|(?:'')|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*") + "'").setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("string enclosed in single quotes") |
| 6135 | quotedStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/quotedString. = Combinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#(Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r'"(?:[^"\n\r\\]|(?:"")|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*') + '"' |
| 6136 | | Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r"'(?:[^'\n\r\\]|(?:'')|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*") + "'").setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("quotedString using single or double quotes") |
| 6137 | unicodeStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicodeString. = Combinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#(_Lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_L.('u') + quotedStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/quotedString..copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().()).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("unicode string literal") |
| 6138 | |
| 6139 | def nestedExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(openerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(opener)="(", closerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(closer)=")", contentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(content)=None, ignoreExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(ignoreExpr)=quotedStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/quotedString..copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().()): |
| 6140 | """Helper method for defining nested lists enclosed in opening and |
| 6141 | closing delimiters ("(" and ")" are the default). |
| 6142 | |
| 6143 | Parameters: |
| 6144 | - opener - opening character for a nested list |
| 6145 | (default= ``"("``); can also be a pyparsing expression |
| 6146 | - closer - closing character for a nested list |
| 6147 | (default= ``")"``); can also be a pyparsing expression |
| 6148 | - content - expression for items within the nested lists |
| 6149 | (default= ``None``) |
| 6150 | - ignoreExpr - expression for ignoring opening and closing |
| 6151 | delimiters (default= :class:`quotedString`) |
| 6152 | |
| 6153 | If an expression is not provided for the content argument, the |
| 6154 | nested expression will capture all whitespace-delimited content |
| 6155 | between delimiters as a list of separate values. |
| 6156 | |
| 6157 | Use the ``ignoreExpr`` argument to define expressions that may |
| 6158 | contain opening or closing characters that should not be treated as |
| 6159 | opening or closing characters for nesting, such as quotedString or |
| 6160 | a comment expression. Specify multiple expressions using an |
| 6161 | :class:`Or` or :class:`MatchFirst`. The default is |
| 6162 | :class:`quotedString`, but if no expressions are to be ignored, then |
| 6163 | pass ``None`` for this argument. |
| 6164 | |
| 6165 | Example:: |
| 6166 | |
| 6167 | data_type = oneOf("void int short long char float double") |
| 6168 | decl_data_type = Combine(data_type + Optional(Word('*'))) |
| 6169 | ident = Word(alphas+'_', alphanums+'_') |
| 6170 | number = pyparsing_common.number |
| 6171 | arg = Group(decl_data_type + ident) |
| 6172 | LPAR, RPAR = map(Suppress, "()") |
| 6173 | |
| 6174 | code_body = nestedExpr('{', '}', ignoreExpr=(quotedString | cStyleComment)) |
| 6175 | |
| 6176 | c_function = (decl_data_type("type") |
| 6177 | + ident("name") |
| 6178 | + LPAR + Optional(delimitedList(arg), [])("args") + RPAR |
| 6179 | + code_body("body")) |
| 6180 | c_function.ignore(cStyleComment) |
| 6181 | |
| 6182 | source_code = ''' |
| 6183 | int is_odd(int x) { |
| 6184 | return (x%2); |
| 6185 | } |
| 6186 | |
| 6187 | int dec_to_hex(char hchar) { |
| 6188 | if (hchar >= '0' && hchar <= '9') { |
| 6189 | return (ord(hchar)-ord('0')); |
| 6190 | } else { |
| 6191 | return (10+ord(hchar)-ord('A')); |
| 6192 | } |
| 6193 | } |
| 6194 | ''' |
| 6195 | for func in c_function.searchString(source_code): |
| 6196 | print("%(name)s (%(type)s) args: %(args)s" % func) |
| 6197 | |
| 6198 | |
| 6199 | prints:: |
| 6200 | |
| 6201 | is_odd (int) args: [['int', 'x']] |
| 6202 | dec_to_hex (int) args: [['char', 'hchar']] |
| 6203 | """ |
| 6204 | if openerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(opener) == closerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(closer): |
| 6205 | raise ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#("opening and closing strings cannot be the same") |
| 6206 | if contentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(content) is None: |
| 6207 | if isinstance(openerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(opener), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.) and isinstance(closerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(closer), basestringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/basestring.): |
| 6208 | if len(openerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(opener)) == 1 and len(closerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(closer)) == 1: |
| 6209 | if ignoreExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(ignoreExpr) is not None: |
| 6210 | contentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(content) = (Combinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#(OneOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#(~ignoreExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(ignoreExpr) |
| 6211 | + CharsNotInscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#(openerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(opener) |
| 6212 | + closerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(closer) |
| 6213 | + ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.DEFAULT_WHITE_CHARSscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#DEFAULT_WHITE_CHARS., exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(exact)=1) |
| 6214 | ) |
| 6215 | ).setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(lambda t: t[0].strip())) |
| 6216 | else: |
| 6217 | contentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(content) = (emptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/empty..copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().() + CharsNotInscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#(openerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(opener) |
| 6218 | + closerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(closer) |
| 6219 | + ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.DEFAULT_WHITE_CHARSscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#DEFAULT_WHITE_CHARS. |
| 6220 | ).setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(lambda t: t[0].strip())) |
| 6221 | else: |
| 6222 | if ignoreExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(ignoreExpr) is not None: |
| 6223 | contentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(content) = (Combinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#(OneOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#(~ignoreExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(ignoreExpr) |
| 6224 | + ~Literalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#(openerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(opener)) |
| 6225 | + ~Literalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#(closerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(closer)) |
| 6226 | + CharsNotInscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#(ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.DEFAULT_WHITE_CHARSscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#DEFAULT_WHITE_CHARS., exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(exact)=1)) |
| 6227 | ).setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(lambda t: t[0].strip())) |
| 6228 | else: |
| 6229 | contentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(content) = (Combinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#(OneOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#(~Literalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#(openerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(opener)) |
| 6230 | + ~Literalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#(closerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(closer)) |
| 6231 | + CharsNotInscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#(ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.DEFAULT_WHITE_CHARSscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#DEFAULT_WHITE_CHARS., exactscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CharsNotIn#__init__().(exact)=1)) |
| 6232 | ).setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(lambda t: t[0].strip())) |
| 6233 | else: |
| 6234 | raise ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#("opening and closing arguments must be strings if no content expression is given") |
| 6235 | ret = Forwardscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Forward#() |
| 6236 | if ignoreExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(ignoreExpr) is not None: |
| 6237 | ret <<= Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(Suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#(openerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(opener)) + ZeroOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#(ignoreExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(ignoreExpr) | ret | contentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(content)) + Suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#(closerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(closer))) |
| 6238 | else: |
| 6239 | ret <<= Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(Suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#(openerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(opener)) + ZeroOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ZeroOrMore#(ret | contentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(content)) + Suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Suppress#(closerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(closer))) |
| 6240 | ret.setName('nested %s%s expression' % (openerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(opener), closerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nestedExpr().(closer))) |
| 6241 | return ret |
| 6242 | |
| 6243 | def indentedBlockscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().(blockStatementExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().(blockStatementExpr), indentStackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().(indentStack), indentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().(indent)=True): |
| 6244 | """Helper method for defining space-delimited indentation blocks, |
| 6245 | such as those used to define block statements in Python source code. |
| 6246 | |
| 6247 | Parameters: |
| 6248 | |
| 6249 | - blockStatementExpr - expression defining syntax of statement that |
| 6250 | is repeated within the indented block |
| 6251 | - indentStack - list created by caller to manage indentation stack |
| 6252 | (multiple statementWithIndentedBlock expressions within a single |
| 6253 | grammar should share a common indentStack) |
| 6254 | - indent - boolean indicating whether block must be indented beyond |
| 6255 | the current level; set to False for block of left-most |
| 6256 | statements (default= ``True``) |
| 6257 | |
| 6258 | A valid block must contain at least one ``blockStatement``. |
| 6259 | |
| 6260 | Example:: |
| 6261 | |
| 6262 | data = ''' |
| 6263 | def A(z): |
| 6264 | A1 |
| 6265 | B = 100 |
| 6266 | G = A2 |
| 6267 | A2 |
| 6268 | A3 |
| 6269 | B |
| 6270 | def BB(a,b,c): |
| 6271 | BB1 |
| 6272 | def BBA(): |
| 6273 | bba1 |
| 6274 | bba2 |
| 6275 | bba3 |
| 6276 | C |
| 6277 | D |
| 6278 | def spam(x,y): |
| 6279 | def eggs(z): |
| 6280 | pass |
| 6281 | ''' |
| 6282 | |
| 6283 | |
| 6284 | indentStack = [1] |
| 6285 | stmt = Forward() |
| 6286 | |
| 6287 | identifier = Word(alphas, alphanums) |
| 6288 | funcDecl = ("def" + identifier + Group("(" + Optional(delimitedList(identifier)) + ")") + ":") |
| 6289 | func_body = indentedBlock(stmt, indentStack) |
| 6290 | funcDef = Group(funcDecl + func_body) |
| 6291 | |
| 6292 | rvalue = Forward() |
| 6293 | funcCall = Group(identifier + "(" + Optional(delimitedList(rvalue)) + ")") |
| 6294 | rvalue << (funcCall | identifier | Word(nums)) |
| 6295 | assignment = Group(identifier + "=" + rvalue) |
| 6296 | stmt << (funcDef | assignment | identifier) |
| 6297 | |
| 6298 | module_body = OneOrMore(stmt) |
| 6299 | |
| 6300 | parseTree = module_body.parseString(data) |
| 6301 | parseTree.pprint() |
| 6302 | |
| 6303 | prints:: |
| 6304 | |
| 6305 | [['def', |
| 6306 | 'A', |
| 6307 | ['(', 'z', ')'], |
| 6308 | ':', |
| 6309 | [['A1'], [['B', '=', '100']], [['G', '=', 'A2']], ['A2'], ['A3']]], |
| 6310 | 'B', |
| 6311 | ['def', |
| 6312 | 'BB', |
| 6313 | ['(', 'a', 'b', 'c', ')'], |
| 6314 | ':', |
| 6315 | [['BB1'], [['def', 'BBA', ['(', ')'], ':', [['bba1'], ['bba2'], ['bba3']]]]]], |
| 6316 | 'C', |
| 6317 | 'D', |
| 6318 | ['def', |
| 6319 | 'spam', |
| 6320 | ['(', 'x', 'y', ')'], |
| 6321 | ':', |
| 6322 | [[['def', 'eggs', ['(', 'z', ')'], ':', [['pass']]]]]]] |
| 6323 | """ |
| 6324 | backup_stack = indentStackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().(indentStack)[:] |
| 6325 | |
| 6326 | def reset_stackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().reset_stack().(): |
| 6327 | indentStackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().(indentStack)[:] = backup_stack |
| 6328 | |
| 6329 | def checkPeerIndentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkPeerIndent().(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkPeerIndent().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkPeerIndent().(l), tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkPeerIndent().(t)): |
| 6330 | if lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkPeerIndent().(l) >= len(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkPeerIndent().(s)): return |
| 6331 | curCol = colscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/col().(lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkPeerIndent().(l), sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkPeerIndent().(s)) |
| 6332 | if curCol != indentStackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().(indentStack)[-1]: |
| 6333 | if curCol > indentStackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().(indentStack)[-1]: |
| 6334 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkPeerIndent().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkPeerIndent().(l), "illegal nesting") |
| 6335 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkPeerIndent().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkPeerIndent().(l), "not a peer entry") |
| 6336 | |
| 6337 | def checkSubIndentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkSubIndent().(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkSubIndent().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkSubIndent().(l), tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkSubIndent().(t)): |
| 6338 | curCol = colscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/col().(lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkSubIndent().(l), sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkSubIndent().(s)) |
| 6339 | if curCol > indentStackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().(indentStack)[-1]: |
| 6340 | indentStackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().(indentStack).append(curCol) |
| 6341 | else: |
| 6342 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkSubIndent().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkSubIndent().(l), "not a subentry") |
| 6343 | |
| 6344 | def checkUnindentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkUnindent().(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkUnindent().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkUnindent().(l), tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkUnindent().(t)): |
| 6345 | if lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkUnindent().(l) >= len(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkUnindent().(s)): return |
| 6346 | curCol = colscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/col().(lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkUnindent().(l), sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkUnindent().(s)) |
| 6347 | if not(indentStackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().(indentStack) and curCol in indentStackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().(indentStack)): |
| 6348 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkUnindent().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkUnindent().(l), "not an unindent") |
| 6349 | if curCol < indentStackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().(indentStack)[-1]: |
| 6350 | indentStackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().(indentStack).pop() |
| 6351 | |
| 6352 | NL = OneOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#(LineEndscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#().setWhitespaceCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setWhitespaceChars().("\t ").suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#suppress().(), stopOnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#__init__().(stopOn)=StringEndscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#()) |
| 6353 | INDENT = (Emptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#() + Emptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#().setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(checkSubIndentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkSubIndent().)).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().('INDENT') |
| 6354 | PEER = Emptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#().setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(checkPeerIndentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkPeerIndent().).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().('') |
| 6355 | UNDENT = Emptyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Empty#().setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(checkUnindentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().checkUnindent().).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().('UNINDENT') |
| 6356 | if indentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().(indent): |
| 6357 | smExpr = Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#(NL) |
| 6358 | + INDENT |
| 6359 | + OneOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#(PEER + Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(blockStatementExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().(blockStatementExpr)) + Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#(NL), stopOnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#__init__().(stopOn)=StringEndscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#()) |
| 6360 | + UNDENT) |
| 6361 | else: |
| 6362 | smExpr = Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#(NL) |
| 6363 | + OneOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#(PEER + Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(blockStatementExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().(blockStatementExpr)) + Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#(NL), stopOnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_MultipleMatch#__init__().(stopOn)=StringEndscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/StringEnd#()) |
| 6364 | + UNDENT) |
| 6365 | smExpr.setFailActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setFailAction().(lambda a, b, c, d: reset_stackscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().reset_stack().()) |
| 6366 | blockStatementExprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/indentedBlock().(blockStatementExpr).ignore(_bslashscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_bslash. + LineEndscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#()) |
| 6367 | return smExpr.setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().('indented block') |
| 6368 | |
| 6369 | alphas8bitscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/alphas8bit. = srangescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/srange().(r"[\0xc0-\0xd6\0xd8-\0xf6\0xf8-\0xff]") |
| 6370 | punc8bitscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/punc8bit. = srangescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/srange().(r"[\0xa1-\0xbf\0xd7\0xf7]") |
| 6371 | |
| 6372 | anyOpenTagscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/anyOpenTag., anyCloseTagscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/anyCloseTag. = makeHTMLTagsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/makeHTMLTags().(Wordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#(alphasscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/alphas., alphanumsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/alphanums. + "_:").setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().('any tag')) |
| 6373 | _htmlEntityMapscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_htmlEntityMap. = dictscip-python python python-stdlib 3.11 builtins/dict#(zipscip-python python python-stdlib 3.11 builtins/zip#("gt lt amp nbsp quot apos".splitscip-python python python-stdlib 3.11 builtins/str#split().(), '><& "\'')) |
| 6374 | commonHTMLEntityscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/commonHTMLEntity. = Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#('&(?P<entity>' + '|'.joinscip-python python python-stdlib 3.11 builtins/str#join().(_htmlEntityMapscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_htmlEntityMap..keysscip-python python python-stdlib 3.11 builtins/dict#keys().()) +");").setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("common HTML entity") |
| 6375 | def replaceHTMLEntityscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/replaceHTMLEntity().(tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/replaceHTMLEntity().(t)): |
| 6376 | """Helper parser action to replace common HTML entities with their special characters""" |
| 6377 | return _htmlEntityMapscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_htmlEntityMap..getscip-python python python-stdlib 3.11 builtins/dict#get().(tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/replaceHTMLEntity().(t).entity) |
| 6378 | |
| 6379 | # it's easy to get these comment structures wrong - they're very common, so may as well make them available |
| 6380 | cStyleCommentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/cStyleComment. = Combinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#(Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r"/\*(?:[^*]|\*(?!/))*") + '*/').setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("C style comment") |
| 6381 | "Comment of the form ``/* ... */``" |
| 6382 | |
| 6383 | htmlCommentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/htmlComment. = Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r"<!--[\s\S]*?-->").setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("HTML comment") |
| 6384 | "Comment of the form ``<!-- ... -->``" |
| 6385 | |
| 6386 | restOfLinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/restOfLine. = Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r".*").leaveWhitespacescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#leaveWhitespace().().setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("rest of line") |
| 6387 | dblSlashCommentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/dblSlashComment. = Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r"//(?:\\\n|[^\n])*").setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("// comment") |
| 6388 | "Comment of the form ``// ... (to end of line)``" |
| 6389 | |
| 6390 | cppStyleCommentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/cppStyleComment. = Combinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#(Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r"/\*(?:[^*]|\*(?!/))*") + '*/' | dblSlashCommentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/dblSlashComment.).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("C++ style comment") |
| 6391 | "Comment of either form :class:`cStyleComment` or :class:`dblSlashComment`" |
| 6392 | |
| 6393 | javaStyleCommentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/javaStyleComment. = cppStyleCommentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/cppStyleComment. |
| 6394 | "Same as :class:`cppStyleComment`" |
| 6395 | |
| 6396 | pythonStyleCommentscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pythonStyleComment. = Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r"#.*").setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("Python style comment") |
| 6397 | "Comment of the form ``# ... (to end of line)``" |
| 6398 | |
| 6399 | _commasepitemscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_commasepitem. = Combinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#(OneOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#(Wordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#(printablesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/printables., excludeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(excludeChars)=',') |
| 6400 | + Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#(Wordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#(" \t") |
| 6401 | + ~Literalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#(",") + ~LineEndscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#()))).streamlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#streamline().().setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("commaItem") |
| 6402 | commaSeparatedListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/commaSeparatedList. = delimitedListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#(quotedStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/quotedString..copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().() | _commasepitemscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_commasepitem., defaultscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__init__().(default)="")).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("commaSeparatedList") |
| 6403 | """(Deprecated) Predefined expression of 1 or more printable words or |
| 6404 | quoted strings, separated by commas. |
| 6405 | |
| 6406 | This expression is deprecated in favor of :class:`pyparsing_common.comma_separated_list`. |
| 6407 | """ |
| 6408 | |
| 6409 | # some other useful expressions - using lower-case class name since we are really using this as a namespace |
| 6410 | class pyparsing_commonscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#: |
| 6411 | """Here are some common low-level expressions that may be useful in |
| 6412 | jump-starting parser development: |
| 6413 | |
| 6414 | - numeric forms (:class:`integers<integer>`, :class:`reals<real>`, |
| 6415 | :class:`scientific notation<sci_real>`) |
| 6416 | - common :class:`programming identifiers<identifier>` |
| 6417 | - network addresses (:class:`MAC<mac_address>`, |
| 6418 | :class:`IPv4<ipv4_address>`, :class:`IPv6<ipv6_address>`) |
| 6419 | - ISO8601 :class:`dates<iso8601_date>` and |
| 6420 | :class:`datetime<iso8601_datetime>` |
| 6421 | - :class:`UUID<uuid>` |
| 6422 | - :class:`comma-separated list<comma_separated_list>` |
| 6423 | |
| 6424 | Parse actions: |
| 6425 | |
| 6426 | - :class:`convertToInteger` |
| 6427 | - :class:`convertToFloat` |
| 6428 | - :class:`convertToDate` |
| 6429 | - :class:`convertToDatetime` |
| 6430 | - :class:`stripHTMLTags` |
| 6431 | - :class:`upcaseTokens` |
| 6432 | - :class:`downcaseTokens` |
| 6433 | |
| 6434 | Example:: |
| 6435 | |
| 6436 | pyparsing_common.number.runTests(''' |
| 6437 | # any int or real number, returned as the appropriate type |
| 6438 | 100 |
| 6439 | -100 |
| 6440 | +100 |
| 6441 | 3.14159 |
| 6442 | 6.02e23 |
| 6443 | 1e-12 |
| 6444 | ''') |
| 6445 | |
| 6446 | pyparsing_common.fnumber.runTests(''' |
| 6447 | # any int or real number, returned as float |
| 6448 | 100 |
| 6449 | -100 |
| 6450 | +100 |
| 6451 | 3.14159 |
| 6452 | 6.02e23 |
| 6453 | 1e-12 |
| 6454 | ''') |
| 6455 | |
| 6456 | pyparsing_common.hex_integer.runTests(''' |
| 6457 | # hex numbers |
| 6458 | 100 |
| 6459 | FF |
| 6460 | ''') |
| 6461 | |
| 6462 | pyparsing_common.fraction.runTests(''' |
| 6463 | # fractions |
| 6464 | 1/2 |
| 6465 | -3/4 |
| 6466 | ''') |
| 6467 | |
| 6468 | pyparsing_common.mixed_integer.runTests(''' |
| 6469 | # mixed fractions |
| 6470 | 1 |
| 6471 | 1/2 |
| 6472 | -3/4 |
| 6473 | 1-3/4 |
| 6474 | ''') |
| 6475 | |
| 6476 | import uuid |
| 6477 | pyparsing_common.uuid.setParseAction(tokenMap(uuid.UUID)) |
| 6478 | pyparsing_common.uuid.runTests(''' |
| 6479 | # uuid |
| 6480 | 12345678-1234-5678-1234-567812345678 |
| 6481 | ''') |
| 6482 | |
| 6483 | prints:: |
| 6484 | |
| 6485 | # any int or real number, returned as the appropriate type |
| 6486 | 100 |
| 6487 | [100] |
| 6488 | |
| 6489 | -100 |
| 6490 | [-100] |
| 6491 | |
| 6492 | +100 |
| 6493 | [100] |
| 6494 | |
| 6495 | 3.14159 |
| 6496 | [3.14159] |
| 6497 | |
| 6498 | 6.02e23 |
| 6499 | [6.02e+23] |
| 6500 | |
| 6501 | 1e-12 |
| 6502 | [1e-12] |
| 6503 | |
| 6504 | # any int or real number, returned as float |
| 6505 | 100 |
| 6506 | [100.0] |
| 6507 | |
| 6508 | -100 |
| 6509 | [-100.0] |
| 6510 | |
| 6511 | +100 |
| 6512 | [100.0] |
| 6513 | |
| 6514 | 3.14159 |
| 6515 | [3.14159] |
| 6516 | |
| 6517 | 6.02e23 |
| 6518 | [6.02e+23] |
| 6519 | |
| 6520 | 1e-12 |
| 6521 | [1e-12] |
| 6522 | |
| 6523 | # hex numbers |
| 6524 | 100 |
| 6525 | [256] |
| 6526 | |
| 6527 | FF |
| 6528 | [255] |
| 6529 | |
| 6530 | # fractions |
| 6531 | 1/2 |
| 6532 | [0.5] |
| 6533 | |
| 6534 | -3/4 |
| 6535 | [-0.75] |
| 6536 | |
| 6537 | # mixed fractions |
| 6538 | 1 |
| 6539 | [1] |
| 6540 | |
| 6541 | 1/2 |
| 6542 | [0.5] |
| 6543 | |
| 6544 | -3/4 |
| 6545 | [-0.75] |
| 6546 | |
| 6547 | 1-3/4 |
| 6548 | [1.75] |
| 6549 | |
| 6550 | # uuid |
| 6551 | 12345678-1234-5678-1234-567812345678 |
| 6552 | [UUID('12345678-1234-5678-1234-567812345678')] |
| 6553 | """ |
| 6554 | |
| 6555 | convertToIntegerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#convertToInteger. = tokenMapscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().(intscip-python python python-stdlib 3.11 builtins/int#) |
| 6556 | """ |
| 6557 | Parse action for converting parsed integers to Python int |
| 6558 | """ |
| 6559 | |
| 6560 | convertToFloatscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#convertToFloat. = tokenMapscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().(floatscip-python python python-stdlib 3.11 builtins/float#) |
| 6561 | """ |
| 6562 | Parse action for converting parsed numbers to Python float |
| 6563 | """ |
| 6564 | |
| 6565 | integerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#integer. = Wordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#(numsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/nums.).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("integer").setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(convertToIntegerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#convertToInteger.) |
| 6566 | """expression that parses an unsigned integer, returns an int""" |
| 6567 | |
| 6568 | hex_integerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#hex_integer. = Wordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#(hexnumsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/hexnums.).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("hex integer").setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(tokenMapscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().(intscip-python python python-stdlib 3.11 builtins/int#, 16)) |
| 6569 | """expression that parses a hexadecimal integer, returns an int""" |
| 6570 | |
| 6571 | signed_integerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#signed_integer. = Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r'[+-]?\d+').setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("signed integer").setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(convertToIntegerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#convertToInteger.) |
| 6572 | """expression that parses an integer with optional leading sign, returns an int""" |
| 6573 | |
| 6574 | fractionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#fraction. = (signed_integerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#signed_integer.().setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(convertToFloatscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#convertToFloat.) + '/' + signed_integerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#signed_integer.().setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(convertToFloatscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#convertToFloat.)).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("fraction") |
| 6575 | """fractional expression of an integer divided by an integer, returns a float""" |
| 6576 | fractionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#fraction..addParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addParseAction().(lambda t: t[0]/t[-1]) |
| 6577 | |
| 6578 | mixed_integerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#mixed_integer. = (fractionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#fraction. | signed_integerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#signed_integer. + Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#(Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#('-').suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#suppress().() + fractionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#fraction.)).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("fraction or mixed integer-fraction") |
| 6579 | """mixed integer of the form 'integer - fraction', with optional leading integer, returns float""" |
| 6580 | mixed_integerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#mixed_integer..addParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addParseAction().(sumscip-python python python-stdlib 3.11 builtins/sum().) |
| 6581 | |
| 6582 | realscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#real. = Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r'[+-]?(?:\d+\.\d*|\.\d+)').setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("real number").setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(convertToFloatscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#convertToFloat.) |
| 6583 | """expression that parses a floating point number and returns a float""" |
| 6584 | |
| 6585 | sci_realscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#sci_real. = Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r'[+-]?(?:\d+(?:[eE][+-]?\d+)|(?:\d+\.\d*|\.\d+)(?:[eE][+-]?\d+)?)').setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("real number with scientific notation").setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(convertToFloatscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#convertToFloat.) |
| 6586 | """expression that parses a floating point number with optional |
| 6587 | scientific notation and returns a float""" |
| 6588 | |
| 6589 | # streamlining this expression makes the docs nicer-looking |
| 6590 | numberscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#number. = (sci_realscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#sci_real. | realscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#real. | signed_integerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#signed_integer.).streamlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#streamline().() |
| 6591 | """any numeric expression, returns the corresponding Python type""" |
| 6592 | |
| 6593 | fnumberscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#fnumber. = Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r'[+-]?\d+\.?\d*([eE][+-]?\d+)?').setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("fnumber").setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(convertToFloatscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#convertToFloat.) |
| 6594 | """any int or real number, returned as float""" |
| 6595 | |
| 6596 | identifierscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#identifier. = Wordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#(alphasscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/alphas. + '_', alphanumsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/alphanums. + '_').setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("identifier") |
| 6597 | """typical code identifier (leading alpha or '_', followed by 0 or more alphas, nums, or '_')""" |
| 6598 | |
| 6599 | ipv4_addressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#ipv4_address. = Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r'(25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})(\.(25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})){3}').setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("IPv4 address") |
| 6600 | "IPv4 address (``0.0.0.0 - 255.255.255.255``)" |
| 6601 | |
| 6602 | _ipv6_partscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#_ipv6_part. = Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r'[0-9a-fA-F]{1,4}').setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("hex_integer") |
| 6603 | _full_ipv6_addressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#_full_ipv6_address. = (_ipv6_partscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#_ipv6_part. + (':' + _ipv6_partscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#_ipv6_part.) * 7).setName("full IPv6 address") |
| 6604 | _short_ipv6_addressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#_short_ipv6_address. = (Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#(_ipv6_partscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#_ipv6_part. + (':' + _ipv6_partscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#_ipv6_part.) * (0, 6)) |
| 6605 | + "::" |
| 6606 | + Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#(_ipv6_partscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#_ipv6_part. + (':' + _ipv6_partscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#_ipv6_part.) * (0, 6)) |
| 6607 | ).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("short IPv6 address") |
| 6608 | _short_ipv6_addressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#_short_ipv6_address..addConditionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#addCondition().(lambda t: sumscip-python python python-stdlib 3.11 builtins/sum().(1 for tt in t if pyparsing_commonscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#._ipv6_partscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#_ipv6_part..matchesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#matches().(tt)) < 8) |
| 6609 | _mixed_ipv6_addressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#_mixed_ipv6_address. = ("::ffff:" + ipv4_addressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#ipv4_address.).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("mixed IPv6 address") |
| 6610 | ipv6_addressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#ipv6_address. = Combinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#((_full_ipv6_addressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#_full_ipv6_address. | _mixed_ipv6_addressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#_mixed_ipv6_address. | _short_ipv6_addressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#_short_ipv6_address.).setName("IPv6 address")).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("IPv6 address") |
| 6611 | "IPv6 address (long, short, or mixed form)" |
| 6612 | |
| 6613 | mac_addressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#mac_address. = Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r'[0-9a-fA-F]{2}([:.-])[0-9a-fA-F]{2}(?:\1[0-9a-fA-F]{2}){4}').setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("MAC address") |
| 6614 | "MAC address xx:xx:xx:xx:xx (may also have '-' or '.' delimiters)" |
| 6615 | |
| 6616 | @staticmethodscip-python python python-stdlib 3.11 builtins/staticmethod# |
| 6617 | def convertToDatescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#convertToDate().(fmtscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#convertToDate().(fmt)="%Y-%m-%d"): |
| 6618 | """ |
| 6619 | Helper to create a parse action for converting parsed date string to Python datetime.date |
| 6620 | |
| 6621 | Params - |
| 6622 | - fmt - format to be passed to datetime.strptime (default= ``"%Y-%m-%d"``) |
| 6623 | |
| 6624 | Example:: |
| 6625 | |
| 6626 | date_expr = pyparsing_common.iso8601_date.copy() |
| 6627 | date_expr.setParseAction(pyparsing_common.convertToDate()) |
| 6628 | print(date_expr.parseString("1999-12-31")) |
| 6629 | |
| 6630 | prints:: |
| 6631 | |
| 6632 | [datetime.date(1999, 12, 31)] |
| 6633 | """ |
| 6634 | def cvt_fnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#cvt_fn().(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#cvt_fn().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#cvt_fn().(l), tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#cvt_fn().(t)): |
| 6635 | try: |
| 6636 | return datetimescip-python python python-stdlib 3.11 datetime/datetime#.strptimescip-python python python-stdlib 3.11 datetime/datetime#strptime().(tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#cvt_fn().(t)[0], fmtscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#convertToDate().(fmt)).datescip-python python python-stdlib 3.11 datetime/datetime#date().() |
| 6637 | except ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError# as ve: |
| 6638 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#cvt_fn().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#cvt_fn().(l), strscip-python python python-stdlib 3.11 builtins/str#(ve)) |
| 6639 | return cvt_fnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#cvt_fn(). |
| 6640 | |
| 6641 | @staticmethodscip-python python python-stdlib 3.11 builtins/staticmethod# |
| 6642 | def convertToDatetimescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#convertToDatetime().(fmtscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#convertToDatetime().(fmt)="%Y-%m-%dT%H:%M:%S.%f"): |
| 6643 | """Helper to create a parse action for converting parsed |
| 6644 | datetime string to Python datetime.datetime |
| 6645 | |
| 6646 | Params - |
| 6647 | - fmt - format to be passed to datetime.strptime (default= ``"%Y-%m-%dT%H:%M:%S.%f"``) |
| 6648 | |
| 6649 | Example:: |
| 6650 | |
| 6651 | dt_expr = pyparsing_common.iso8601_datetime.copy() |
| 6652 | dt_expr.setParseAction(pyparsing_common.convertToDatetime()) |
| 6653 | print(dt_expr.parseString("1999-12-31T23:59:59.999")) |
| 6654 | |
| 6655 | prints:: |
| 6656 | |
| 6657 | [datetime.datetime(1999, 12, 31, 23, 59, 59, 999000)] |
| 6658 | """ |
| 6659 | def cvt_fnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#cvt_fn().(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#cvt_fn().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#cvt_fn().(l), tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#cvt_fn().(t)): |
| 6660 | try: |
| 6661 | return datetimescip-python python python-stdlib 3.11 datetime/datetime#.strptimescip-python python python-stdlib 3.11 datetime/datetime#strptime().(tscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#cvt_fn().(t)[0], fmtscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#convertToDatetime().(fmt)) |
| 6662 | except ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError# as ve: |
| 6663 | raise ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#cvt_fn().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#cvt_fn().(l), strscip-python python python-stdlib 3.11 builtins/str#(ve)) |
| 6664 | return cvt_fnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#cvt_fn(). |
| 6665 | |
| 6666 | iso8601_datescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#iso8601_date. = Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r'(?P<year>\d{4})(?:-(?P<month>\d\d)(?:-(?P<day>\d\d))?)?').setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("ISO8601 date") |
| 6667 | "ISO8601 date (``yyyy-mm-dd``)" |
| 6668 | |
| 6669 | iso8601_datetimescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#iso8601_datetime. = Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r'(?P<year>\d{4})-(?P<month>\d\d)-(?P<day>\d\d)[T ](?P<hour>\d\d):(?P<minute>\d\d)(:(?P<second>\d\d(\.\d*)?)?)?(?P<tz>Z|[+-]\d\d:?\d\d)?').setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("ISO8601 datetime") |
| 6670 | "ISO8601 datetime (``yyyy-mm-ddThh:mm:ss.s(Z|+-00:00)``) - trailing seconds, milliseconds, and timezone optional; accepts separating ``'T'`` or ``' '``" |
| 6671 | |
| 6672 | uuidscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#uuid. = Regexscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Regex#(r'[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}').setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("UUID") |
| 6673 | "UUID (``xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx``)" |
| 6674 | |
| 6675 | _html_stripperscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#_html_stripper. = anyOpenTagscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/anyOpenTag..suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#suppress().() | anyCloseTagscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/anyCloseTag..suppressscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#suppress().() |
| 6676 | @staticmethodscip-python python python-stdlib 3.11 builtins/staticmethod# |
| 6677 | def stripHTMLTagsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#stripHTMLTags().(sscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#stripHTMLTags().(s), lscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#stripHTMLTags().(l), tokensscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#stripHTMLTags().(tokens)): |
| 6678 | """Parse action to remove HTML tags from web page HTML source |
| 6679 | |
| 6680 | Example:: |
| 6681 | |
| 6682 | # strip HTML links from normal text |
| 6683 | text = '<td>More info at the <a href="https://github.com/pyparsing/pyparsing/wiki">pyparsing</a> wiki page</td>' |
| 6684 | td, td_end = makeHTMLTags("TD") |
| 6685 | table_text = td + SkipTo(td_end).setParseAction(pyparsing_common.stripHTMLTags)("body") + td_end |
| 6686 | print(table_text.parseString(text).body) |
| 6687 | |
| 6688 | Prints:: |
| 6689 | |
| 6690 | More info at the pyparsing wiki page |
| 6691 | """ |
| 6692 | return pyparsing_commonscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#._html_stripperscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#_html_stripper..transformStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#transformString().(tokensscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#stripHTMLTags().(tokens)[0]) |
| 6693 | |
| 6694 | _commasepitemscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#_commasepitem. = Combinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Combine#(OneOrMorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/OneOrMore#(~Literalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Literal#(",") |
| 6695 | + ~LineEndscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/LineEnd#() |
| 6696 | + Wordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#(printablesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/printables., excludeCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#__init__().(excludeChars)=',') |
| 6697 | + Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#(Whitescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/White#(" \t")))).streamlinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseElementEnhance#streamline().().setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("commaItem") |
| 6698 | comma_separated_listscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#comma_separated_list. = delimitedListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(Optionalscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#(quotedStringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/quotedString..copyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#copy().() |
| 6699 | | _commasepitemscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#_commasepitem., defaultscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Optional#__init__().(default)='') |
| 6700 | ).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("comma separated list") |
| 6701 | """Predefined expression of 1 or more printable words or quoted strings, separated by commas.""" |
| 6702 | |
| 6703 | upcaseTokensscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#upcaseTokens. = staticmethodscip-python python python-stdlib 3.11 builtins/staticmethod#(tokenMapscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().(lambda t: _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(t).upperscip-python python python-stdlib 3.11 builtins/str#upper().())) |
| 6704 | """Parse action to convert tokens to upper case.""" |
| 6705 | |
| 6706 | downcaseTokensscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#downcaseTokens. = staticmethodscip-python python python-stdlib 3.11 builtins/staticmethod#(tokenMapscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().(lambda t: _ustrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_ustr.(t).lowerscip-python python python-stdlib 3.11 builtins/str#lower().())) |
| 6707 | """Parse action to convert tokens to lower case.""" |
| 6708 | |
| 6709 | |
| 6710 | class _lazyclasspropertyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#(objectscip-python python python-stdlib 3.11 builtins/object#): |
| 6711 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__init__().(self), fnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__init__().(fn)): |
| 6712 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__init__().(self).fnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#fn. = fnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__init__().(fn) |
| 6713 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__init__().(self).__doc__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty# = fnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__init__().(fn).__doc__ |
| 6714 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__init__().(self).__name__scip-python python python-stdlib 3.11 builtins/__name__# = fnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__init__().(fn).__name__ |
| 6715 | |
| 6716 | def __get__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__get__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__get__().(self), objscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__get__().(obj), clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__get__().(cls)): |
| 6717 | if clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__get__().(cls) is None: |
| 6718 | clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__get__().(cls) = typescip-python python python-stdlib 3.11 builtins/type#(objscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__get__().(obj)) |
| 6719 | if not hasattr(clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__get__().(cls), '_intern') or any(clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__get__().(cls)._intern is getattrscip-python python python-stdlib 3.11 builtins/getattr().(superclass, '_intern', []) |
| 6720 | for superclass in clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__get__().(cls).__mro__[1:]): |
| 6721 | clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__get__().(cls)._intern = {} |
| 6722 | attrname = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__get__().(self).fnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#fn..__name__ |
| 6723 | if attrname not in clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__get__().(cls)._intern: |
| 6724 | clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__get__().(cls)._intern[attrname] = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__get__().(self).fnscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#fn.(clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__get__().(cls)) |
| 6725 | return clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty#__get__().(cls)._intern[attrname] |
| 6726 | |
| 6727 | |
| 6728 | class unicode_setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#(objectscip-python python python-stdlib 3.11 builtins/object#): |
| 6729 | """ |
| 6730 | A set of Unicode characters, for language-specific strings for |
| 6731 | ``alphas``, ``nums``, ``alphanums``, and ``printables``. |
| 6732 | A unicode_set is defined by a list of ranges in the Unicode character |
| 6733 | set, in a class attribute ``_ranges``, such as:: |
| 6734 | |
| 6735 | _ranges = [(0x0020, 0x007e), (0x00a0, 0x00ff),] |
| 6736 | |
| 6737 | A unicode set can also be defined using multiple inheritance of other unicode sets:: |
| 6738 | |
| 6739 | class CJK(Chinese, Japanese, Korean): |
| 6740 | pass |
| 6741 | """ |
| 6742 | _rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#_ranges. = [] |
| 6743 | |
| 6744 | @classmethodscip-python python python-stdlib 3.11 builtins/classmethod# |
| 6745 | def _get_chars_for_rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#_get_chars_for_ranges().(clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#_get_chars_for_ranges().(cls)): |
| 6746 | ret = [] |
| 6747 | for cc in clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#_get_chars_for_ranges().(cls).__mro__scip-python python python-stdlib 3.11 builtins/type#__mro__().: |
| 6748 | if cc is unicode_setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#: |
| 6749 | break |
| 6750 | for rr in cc._ranges: |
| 6751 | ret.extendscip-python python python-stdlib 3.11 builtins/list#extend().(rangescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/range.(rr[0], rr[-1] + 1)) |
| 6752 | return [unichrscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unichr.(c) for c in sortedscip-python python python-stdlib 3.11 builtins/sorted().(setscip-python python python-stdlib 3.11 builtins/set#(ret))] |
| 6753 | |
| 6754 | @_lazyclasspropertyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty# |
| 6755 | def printablesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#printables().(clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#printables().(cls)): |
| 6756 | "all non-whitespace characters in this range" |
| 6757 | return u''.joinscip-python python python-stdlib 3.11 builtins/str#join().(filterfalsescip-python python python-stdlib 3.11 itertools/filterfalse#(unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode..isspacescip-python python python-stdlib 3.11 builtins/str#isspace()., clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#printables().(cls)._get_chars_for_rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#_get_chars_for_ranges().())) |
| 6758 | |
| 6759 | @_lazyclasspropertyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty# |
| 6760 | def alphasscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#alphas().(clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#alphas().(cls)): |
| 6761 | "all alphabetic characters in this range" |
| 6762 | return u''.joinscip-python python python-stdlib 3.11 builtins/str#join().(filterscip-python python python-stdlib 3.11 builtins/filter#(unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode..isalphascip-python python python-stdlib 3.11 builtins/str#isalpha()., clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#alphas().(cls)._get_chars_for_rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#_get_chars_for_ranges().())) |
| 6763 | |
| 6764 | @_lazyclasspropertyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty# |
| 6765 | def numsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#nums().(clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#nums().(cls)): |
| 6766 | "all numeric digit characters in this range" |
| 6767 | return u''.joinscip-python python python-stdlib 3.11 builtins/str#join().(filterscip-python python python-stdlib 3.11 builtins/filter#(unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode..isdigitscip-python python python-stdlib 3.11 builtins/str#isdigit()., clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#nums().(cls)._get_chars_for_rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#_get_chars_for_ranges().())) |
| 6768 | |
| 6769 | @_lazyclasspropertyscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/_lazyclassproperty# |
| 6770 | def alphanumsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#alphanums().(clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#alphanums().(cls)): |
| 6771 | "all alphanumeric characters in this range" |
| 6772 | return clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#alphanums().(cls).alphasscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#alphas(). + clsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#alphanums().(cls).numsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#nums(). |
| 6773 | |
| 6774 | |
| 6775 | class pyparsing_unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#(unicode_setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#): |
| 6776 | """ |
| 6777 | A namespace class for defining common language unicode_sets. |
| 6778 | """ |
| 6779 | _rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#_ranges. = [(32, sysscip-python python python-stdlib 3.11 sys/__init__:.maxunicodescip-python python python-stdlib 3.11 sys/maxunicode.maxunicode.)] |
| 6780 | |
| 6781 | class Latin1scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Latin1#(unicode_setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#): |
| 6782 | "Unicode set for Latin-1 Unicode Character Range" |
| 6783 | _rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Latin1#_ranges. = [(0x0020, 0x007e), (0x00a0, 0x00ff),] |
| 6784 | |
| 6785 | class LatinAscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#LatinA#(unicode_setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#): |
| 6786 | "Unicode set for Latin-A Unicode Character Range" |
| 6787 | _rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#LatinA#_ranges. = [(0x0100, 0x017f),] |
| 6788 | |
| 6789 | class LatinBscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#LatinB#(unicode_setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#): |
| 6790 | "Unicode set for Latin-B Unicode Character Range" |
| 6791 | _rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#LatinB#_ranges. = [(0x0180, 0x024f),] |
| 6792 | |
| 6793 | class Greekscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Greek#(unicode_setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#): |
| 6794 | "Unicode set for Greek Unicode Character Ranges" |
| 6795 | _rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Greek#_ranges. = [ |
| 6796 | (0x0370, 0x03ff), (0x1f00, 0x1f15), (0x1f18, 0x1f1d), (0x1f20, 0x1f45), (0x1f48, 0x1f4d), |
| 6797 | (0x1f50, 0x1f57), (0x1f59,), (0x1f5b,), (0x1f5d,), (0x1f5f, 0x1f7d), (0x1f80, 0x1fb4), (0x1fb6, 0x1fc4), |
| 6798 | (0x1fc6, 0x1fd3), (0x1fd6, 0x1fdb), (0x1fdd, 0x1fef), (0x1ff2, 0x1ff4), (0x1ff6, 0x1ffe), |
| 6799 | ] |
| 6800 | |
| 6801 | class Cyrillicscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Cyrillic#(unicode_setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#): |
| 6802 | "Unicode set for Cyrillic Unicode Character Range" |
| 6803 | _rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Cyrillic#_ranges. = [(0x0400, 0x04ff)] |
| 6804 | |
| 6805 | class Chinesescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Chinese#(unicode_setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#): |
| 6806 | "Unicode set for Chinese Unicode Character Range" |
| 6807 | _rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Chinese#_ranges. = [(0x4e00, 0x9fff), (0x3000, 0x303f),] |
| 6808 | |
| 6809 | class Japanesescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#(unicode_setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#): |
| 6810 | "Unicode set for Japanese Unicode Character Range, combining Kanji, Hiragana, and Katakana ranges" |
| 6811 | _rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#_ranges. = [] |
| 6812 | |
| 6813 | class Kanjiscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#Kanji#(unicode_setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#): |
| 6814 | "Unicode set for Kanji Unicode Character Range" |
| 6815 | _rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#Kanji#_ranges. = [(0x4E00, 0x9Fbf), (0x3000, 0x303f),] |
| 6816 | |
| 6817 | class Hiraganascip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#Hiragana#(unicode_setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#): |
| 6818 | "Unicode set for Hiragana Unicode Character Range" |
| 6819 | _rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#Hiragana#_ranges. = [(0x3040, 0x309f),] |
| 6820 | |
| 6821 | class Katakanascip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#Katakana#(unicode_setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#): |
| 6822 | "Unicode set for Katakana Unicode Character Range" |
| 6823 | _rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#Katakana#_ranges. = [(0x30a0, 0x30ff),] |
| 6824 | |
| 6825 | class Koreanscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Korean#(unicode_setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#): |
| 6826 | "Unicode set for Korean Unicode Character Range" |
| 6827 | _rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Korean#_ranges. = [(0xac00, 0xd7af), (0x1100, 0x11ff), (0x3130, 0x318f), (0xa960, 0xa97f), (0xd7b0, 0xd7ff), (0x3000, 0x303f),] |
| 6828 | |
| 6829 | class CJKscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#CJK#(Chinesescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Chinese#, Japanesescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#, Koreanscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Korean#): |
| 6830 | "Unicode set for combined Chinese, Japanese, and Korean (CJK) Unicode Character Range" |
| 6831 | pass |
| 6832 | |
| 6833 | class Thaiscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Thai#(unicode_setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#): |
| 6834 | "Unicode set for Thai Unicode Character Range" |
| 6835 | _rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Thai#_ranges. = [(0x0e01, 0x0e3a), (0x0e3f, 0x0e5b),] |
| 6836 | |
| 6837 | class Arabicscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Arabic#(unicode_setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#): |
| 6838 | "Unicode set for Arabic Unicode Character Range" |
| 6839 | _rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Arabic#_ranges. = [(0x0600, 0x061b), (0x061e, 0x06ff), (0x0700, 0x077f),] |
| 6840 | |
| 6841 | class Hebrewscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Hebrew#(unicode_setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#): |
| 6842 | "Unicode set for Hebrew Unicode Character Range" |
| 6843 | _rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Hebrew#_ranges. = [(0x0590, 0x05ff),] |
| 6844 | |
| 6845 | class Devanagariscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Devanagari#(unicode_setscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/unicode_set#): |
| 6846 | "Unicode set for Devanagari Unicode Character Range" |
| 6847 | _rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Devanagari#_ranges. = [(0x0900, 0x097f), (0xa8e0, 0xa8ff)] |
| 6848 | |
| 6849 | pyparsing_unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#.Japanesescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#._rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#_ranges. = (pyparsing_unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#.Japanesescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#.Kanjiscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#Kanji#._rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#Kanji#_ranges. |
| 6850 | + pyparsing_unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#.Japanesescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#.Hiraganascip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#Hiragana#._rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#Hiragana#_ranges. |
| 6851 | + pyparsing_unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#.Japanesescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#.Katakanascip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#Katakana#._rangesscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#Katakana#_ranges.) |
| 6852 | |
| 6853 | # define ranges in language character sets |
| 6854 | if PY_3scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/PY_3.: |
| 6855 | setattr(pyparsing_unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#, u"العربية", pyparsing_scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Arabic#.Arabic) |
| 6856 | setattr(pyparsing_unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#, u"中文", pyparsing_uniscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#code.Chiscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Chinese#nese) |
| 6857 | setattr(pyparsing_unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#, u"кириллица", pyparsinscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#g_unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Cyrillic#.Cyrillic) |
| 6858 | setattr(pyparsing_unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#, u"Ελληνικά", pyparsingscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#_unicoscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Greek#de.Greek) |
| 6859 | setattr(pyparsing_unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#, u"עִברִית", pyparsing_scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Hebrew#.Hebrew) |
| 6860 | setattr(pyparsing_unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#, u"日本語", pyparsing_uscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#nicode.Jascip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#panese) |
| 6861 | setattr(pyparsing_unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#.Japanesescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#, u"漢字", pyparsing_uniscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#code.Japascip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#nese.Kscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#Kanji#anji) |
| 6862 | setattr(pyparsing_unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#.Japanesescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#, u"カタカナ", pyparsingscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#_unicode.scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#Japanese.scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#Katakana#Katakana) |
| 6863 | setattr(pyparsing_unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#.Japanesescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#, u"ひらがな", pyparsingscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#_unicode.scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#Japanese.scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Japanese#Hiragana#Hiragana) |
| 6864 | setattr(pyparsing_unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#, u"한국어", pyparsing_uscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#nicode.scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Korean#Korean) |
| 6865 | setattr(pyparsing_unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#, u"ไทย", pyparsing_uscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#nicodscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Thai#e.Thai) |
| 6866 | setattr(pyparsing_unicodescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#, u"देवनागरी", pscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#yparsing_unscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_unicode#Devanagari#icode.Devanagari) |
| 6867 | |
| 6868 | |
| 6869 | class pyparsing_testscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#: |
| 6870 | """ |
| 6871 | namespace class for classes useful in writing unit tests |
| 6872 | """ |
| 6873 | |
| 6874 | class reset_pyparsing_contextscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#: |
| 6875 | """ |
| 6876 | Context manager to be used when writing unit tests that modify pyparsing config values: |
| 6877 | - packrat parsing |
| 6878 | - default whitespace characters. |
| 6879 | - default keyword characters |
| 6880 | - literal string auto-conversion class |
| 6881 | - __diag__ settings |
| 6882 | |
| 6883 | Example: |
| 6884 | with reset_pyparsing_context(): |
| 6885 | # test that literals used to construct a grammar are automatically suppressed |
| 6886 | ParserElement.inlineLiteralsUsing(Suppress) |
| 6887 | |
| 6888 | term = Word(alphas) | Word(nums) |
| 6889 | group = Group('(' + term[...] + ')') |
| 6890 | |
| 6891 | # assert that the '()' characters are not included in the parsed tokens |
| 6892 | self.assertParseAndCheckLisst(group, "(abc 123 def)", ['abc', '123', 'def']) |
| 6893 | |
| 6894 | # after exiting context manager, literals are converted to Literal expressions again |
| 6895 | """ |
| 6896 | |
| 6897 | def __init__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#__init__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#__init__().(self)): |
| 6898 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#__init__().(self)._save_contextscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/reset_pyparsing_context#_save_context. = {} |
| 6899 | |
| 6900 | def savescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#save().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#save().(self)): |
| 6901 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#save().(self)._save_contextscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/reset_pyparsing_context#_save_context.["default_whitespace"] = ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.DEFAULT_WHITE_CHARSscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#DEFAULT_WHITE_CHARS. |
| 6902 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#save().(self)._save_contextscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/reset_pyparsing_context#_save_context.["default_keyword_chars"] = Keywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#.DEFAULT_KEYWORD_CHARSscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#DEFAULT_KEYWORD_CHARS. |
| 6903 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#save().(self)._save_contextscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/reset_pyparsing_context#_save_context.[ |
| 6904 | "literal_string_class" |
| 6905 | ] = ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#._literalStringClass |
| 6906 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#save().(self)._save_contextscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/reset_pyparsing_context#_save_context.["packrat_enabled"] = ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#._packratEnabledscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_packratEnabled. |
| 6907 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#save().(self)._save_contextscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/reset_pyparsing_context#_save_context.["packrat_parse"] = ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse. |
| 6908 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#save().(self)._save_contextscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/reset_pyparsing_context#_save_context.["__diag__"] = { |
| 6909 | name: getattrscip-python python python-stdlib 3.11 builtins/getattr().(__diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__., name) for name in __diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__.._all_names |
| 6910 | } |
| 6911 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#save().(self)._save_contextscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/reset_pyparsing_context#_save_context.["__compat__"] = { |
| 6912 | "collect_all_And_tokens": __compat__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__compat__..collect_all_And_tokens |
| 6913 | } |
| 6914 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#save().(self) |
| 6915 | |
| 6916 | def restorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#restore().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#restore().(self)): |
| 6917 | # reset pyparsing global state |
| 6918 | if ( |
| 6919 | ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.DEFAULT_WHITE_CHARSscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#DEFAULT_WHITE_CHARS. |
| 6920 | != selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#restore().(self)._save_contextscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/reset_pyparsing_context#_save_context.["default_whitespace"] |
| 6921 | ): |
| 6922 | ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.setDefaultWhitespaceCharsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setDefaultWhitespaceChars().( |
| 6923 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#restore().(self)._save_contextscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/reset_pyparsing_context#_save_context.["default_whitespace"] |
| 6924 | ) |
| 6925 | Keywordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#.DEFAULT_KEYWORD_CHARSscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Keyword#DEFAULT_KEYWORD_CHARS. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#restore().(self)._save_contextscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/reset_pyparsing_context#_save_context.["default_keyword_chars"] |
| 6926 | ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#.inlineLiteralsUsingscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#inlineLiteralsUsing().( |
| 6927 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#restore().(self)._save_contextscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/reset_pyparsing_context#_save_context.["literal_string_class"] |
| 6928 | ) |
| 6929 | for name, value in selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#restore().(self)._save_contextscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/reset_pyparsing_context#_save_context.["__diag__"].items(): |
| 6930 | setattr(__diag__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__diag__., name, value) |
| 6931 | ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#._packratEnabledscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_packratEnabled. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#restore().(self)._save_contextscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/reset_pyparsing_context#_save_context.["packrat_enabled"] |
| 6932 | ParserElementscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#._parsescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#_parse. = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#restore().(self)._save_contextscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/reset_pyparsing_context#_save_context.["packrat_parse"] |
| 6933 | __compat__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/__compat__..collect_all_And_tokens = selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#restore().(self)._save_contextscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/reset_pyparsing_context#_save_context.["__compat__"] |
| 6934 | |
| 6935 | def __enter__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#__enter__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#__enter__().(self)): |
| 6936 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#__enter__().(self).savescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#save().() |
| 6937 | |
| 6938 | def __exit__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#__exit__().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#__exit__().(self), *argsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#__exit__().(args)): |
| 6939 | return selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#__exit__().(self).restorescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#reset_pyparsing_context#restore().() |
| 6940 | |
| 6941 | class TestParseResultsAssertsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#: |
| 6942 | """ |
| 6943 | A mixin class to add parse results assertion methods to normal unittest.TestCase classes. |
| 6944 | """ |
| 6945 | def assertParseResultsEqualsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().( |
| 6946 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(self), resultscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(result), expected_listscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(expected_list)=None, expected_dictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(expected_dict)=None, msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(msg)=None |
| 6947 | ): |
| 6948 | """ |
| 6949 | Unit test assertion to compare a ParseResults object with an optional expected_list, |
| 6950 | and compare any defined results names with an optional expected_dict. |
| 6951 | """ |
| 6952 | if expected_listscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(expected_list) is not None: |
| 6953 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(self).assertEqual(expected_listscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(expected_list), resultscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(result).asList(), msg=msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(msg)) |
| 6954 | if expected_dictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(expected_dict) is not None: |
| 6955 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(self).assertEqual(expected_dictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(expected_dict), resultscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(result).asDict(), msg=msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(msg)) |
| 6956 | |
| 6957 | def assertParseAndCheckListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckList().( |
| 6958 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckList().(self), exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckList().(expr), test_stringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckList().(test_string), expected_listscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckList().(expected_list), msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckList().(msg)=None, verbosescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckList().(verbose)=True |
| 6959 | ): |
| 6960 | """ |
| 6961 | Convenience wrapper assert to test a parser element and input string, and assert that |
| 6962 | the resulting ParseResults.asList() is equal to the expected_list. |
| 6963 | """ |
| 6964 | result = exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckList().(expr).parseString(test_stringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckList().(test_string), parseAll=True) |
| 6965 | if verbosescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckList().(verbose): |
| 6966 | printscip-python python python-stdlib 3.11 builtins/print().(result.dump()) |
| 6967 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckList().(self).assertParseResultsEqualsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(result, expected_listscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(expected_list)=expected_listscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckList().(expected_list), msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(msg)=msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckList().(msg)) |
| 6968 | |
| 6969 | def assertParseAndCheckDictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckDict().( |
| 6970 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckDict().(self), exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckDict().(expr), test_stringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckDict().(test_string), expected_dictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckDict().(expected_dict), msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckDict().(msg)=None, verbosescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckDict().(verbose)=True |
| 6971 | ): |
| 6972 | """ |
| 6973 | Convenience wrapper assert to test a parser element and input string, and assert that |
| 6974 | the resulting ParseResults.asDict() is equal to the expected_dict. |
| 6975 | """ |
| 6976 | result = exprscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckDict().(expr).parseString(test_stringscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckDict().(test_string), parseAll=True) |
| 6977 | if verbosescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckDict().(verbose): |
| 6978 | printscip-python python python-stdlib 3.11 builtins/print().(result.dump()) |
| 6979 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckDict().(self).assertParseResultsEqualsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(result, expected_dictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(expected_dict)=expected_dictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckDict().(expected_dict), msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(msg)=msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseAndCheckDict().(msg)) |
| 6980 | |
| 6981 | def assertRunTestResultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRunTestResults().( |
| 6982 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRunTestResults().(self), run_tests_reportscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRunTestResults().(run_tests_report), expected_parse_resultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRunTestResults().(expected_parse_results)=None, msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRunTestResults().(msg)=None |
| 6983 | ): |
| 6984 | """ |
| 6985 | Unit test assertion to evaluate output of ParserElement.runTests(). If a list of |
| 6986 | list-dict tuples is given as the expected_parse_results argument, then these are zipped |
| 6987 | with the report tuples returned by runTests and evaluated using assertParseResultsEquals. |
| 6988 | Finally, asserts that the overall runTests() success value is True. |
| 6989 | |
| 6990 | :param run_tests_report: tuple(bool, [tuple(str, ParseResults or Exception)]) returned from runTests |
| 6991 | :param expected_parse_results (optional): [tuple(str, list, dict, Exception)] |
| 6992 | """ |
| 6993 | run_test_success, run_test_results = run_tests_reportscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRunTestResults().(run_tests_report) |
| 6994 | |
| 6995 | if expected_parse_resultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRunTestResults().(expected_parse_results) is not None: |
| 6996 | merged = [ |
| 6997 | (rpt[0], rpt[1], expected) |
| 6998 | for rpt, expected in zipscip-python python python-stdlib 3.11 builtins/zip#(run_test_results, expected_parse_resultsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRunTestResults().(expected_parse_results)) |
| 6999 | ] |
| 7000 | for test_string, result, expected in merged: |
| 7001 | # expected should be a tuple containing a list and/or a dict or an exception, |
| 7002 | # and optional failure message string |
| 7003 | # an empty tuple will skip any result validation |
| 7004 | fail_msg = nextscip-python python python-stdlib 3.11 builtins/next().( |
| 7005 | (exp for exp in expected if isinstance(exp, strscip-python python python-stdlib 3.11 builtins/str#)), None |
| 7006 | ) |
| 7007 | expected_exception = nextscip-python python python-stdlib 3.11 builtins/next().( |
| 7008 | ( |
| 7009 | exp |
| 7010 | for exp in expected |
| 7011 | if isinstance(exp, typescip-python python python-stdlib 3.11 builtins/type#) and issubclass(exp, Exceptionscip-python python python-stdlib 3.11 builtins/Exception#) |
| 7012 | ), |
| 7013 | None, |
| 7014 | ) |
| 7015 | if expected_exception is not None: |
| 7016 | with selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRunTestResults().(self).assertRaises( |
| 7017 | expected_exception=expected_exception, msg=fail_msg or msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRunTestResults().(msg) |
| 7018 | ): |
| 7019 | if isinstance(result, Exceptionscip-python python python-stdlib 3.11 builtins/Exception#): |
| 7020 | raise result |
| 7021 | else: |
| 7022 | expected_list = nextscip-python python python-stdlib 3.11 builtins/next().( |
| 7023 | (exp for exp in expected if isinstance(exp, listscip-python python python-stdlib 3.11 builtins/list#)), None |
| 7024 | ) |
| 7025 | expected_dict = nextscip-python python python-stdlib 3.11 builtins/next().( |
| 7026 | (exp for exp in expected if isinstance(exp, dictscip-python python python-stdlib 3.11 builtins/dict#)), None |
| 7027 | ) |
| 7028 | if (expected_list, expected_dict) != (None, None): |
| 7029 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRunTestResults().(self).assertParseResultsEqualsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().( |
| 7030 | result, |
| 7031 | expected_listscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(expected_list)=expected_list, |
| 7032 | expected_dictscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(expected_dict)=expected_dict, |
| 7033 | msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertParseResultsEquals().(msg)=fail_msg or msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRunTestResults().(msg), |
| 7034 | ) |
| 7035 | else: |
| 7036 | # warning here maybe? |
| 7037 | printscip-python python python-stdlib 3.11 builtins/print().("no validation for {!r}".format(test_string)) |
| 7038 | |
| 7039 | # do this last, in case some specific test results can be reported instead |
| 7040 | selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRunTestResults().(self).assertTrue( |
| 7041 | run_test_success, msg=msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRunTestResults().(msg) if msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRunTestResults().(msg) is not None else "failed runTests" |
| 7042 | ) |
| 7043 | |
| 7044 | @contextmanagerscip-python python python-stdlib 3.11 contextlib/contextmanager(). |
| 7045 | def assertRaisesParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRaisesParseException().(selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRaisesParseException().(self), exc_typescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRaisesParseException().(exc_type)=ParseExceptionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParseException#, msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRaisesParseException().(msg)=None): |
| 7046 | with selfscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRaisesParseException().(self).assertRaises(exc_typescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRaisesParseException().(exc_type), msg=msgscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_test#TestParseResultsAsserts#assertRaisesParseException().(msg)): |
| 7047 | yield |
| 7048 | |
| 7049 | |
| 7050 | if __name__scip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ == "__main__": |
| 7051 | |
| 7052 | selectTokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/selectToken. = CaselessLiteralscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#("select") |
| 7053 | fromTokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/fromToken. = CaselessLiteralscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/CaselessLiteral#("from") |
| 7054 | |
| 7055 | identscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ident. = Wordscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Word#(alphasscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/alphas., alphanumsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/alphanums. + "_$") |
| 7056 | |
| 7057 | columnNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/columnName. = delimitedListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(identscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ident., ".", combinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(combine)=True).setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(upcaseTokensscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/upcaseTokens.) |
| 7058 | columnNameListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/columnNameList. = Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(delimitedListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(columnNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/columnName.)).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("columns") |
| 7059 | columnSpecscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/columnSpec. = ('*' | columnNameListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/columnNameList.) |
| 7060 | |
| 7061 | tableNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tableName. = delimitedListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(identscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ident., ".", combinescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(combine)=True).setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(upcaseTokensscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/upcaseTokens.) |
| 7062 | tableNameListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tableNameList. = Groupscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/Group#(delimitedListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/delimitedList().(tableNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tableName.)).setNamescip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setName().("tables") |
| 7063 | |
| 7064 | simpleSQLscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/simpleSQL. = selectTokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/selectToken.("command") + columnSpecscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/columnSpec.("columns") + fromTokenscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/fromToken. + tableNameListscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tableNameList.("tables") |
| 7065 | |
| 7066 | # demo runTests method, including embedded comments in test string |
| 7067 | simpleSQLscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/simpleSQL..runTestsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(""" |
| 7068 | # '*' as column list and dotted table name |
| 7069 | select * from SYS.XYZZY |
| 7070 | |
| 7071 | # caseless match on "SELECT", and casts back to "select" |
| 7072 | SELECT * from XYZZY, ABC |
| 7073 | |
| 7074 | # list of column names, and mixed case SELECT keyword |
| 7075 | Select AA,BB,CC from Sys.dual |
| 7076 | |
| 7077 | # multiple tables |
| 7078 | Select A, B, C from Sys.dual, Table2 |
| 7079 | |
| 7080 | # invalid SELECT keyword - should fail |
| 7081 | Xelect A, B, C from Sys.dual |
| 7082 | |
| 7083 | # incomplete command - should fail |
| 7084 | Select |
| 7085 | |
| 7086 | # invalid column name - should fail |
| 7087 | Select ^^^ frox Sys.dual |
| 7088 | |
| 7089 | """) |
| 7090 | |
| 7091 | pyparsing_commonscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#.numberscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#number..runTestsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(""" |
| 7092 | 100 |
| 7093 | -100 |
| 7094 | +100 |
| 7095 | 3.14159 |
| 7096 | 6.02e23 |
| 7097 | 1e-12 |
| 7098 | """) |
| 7099 | |
| 7100 | # any int or real number, returned as float |
| 7101 | pyparsing_commonscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#.fnumberscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#fnumber..runTestsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(""" |
| 7102 | 100 |
| 7103 | -100 |
| 7104 | +100 |
| 7105 | 3.14159 |
| 7106 | 6.02e23 |
| 7107 | 1e-12 |
| 7108 | """) |
| 7109 | |
| 7110 | pyparsing_commonscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#.hex_integerscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#hex_integer..runTestsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(""" |
| 7111 | 100 |
| 7112 | FF |
| 7113 | """) |
| 7114 | |
| 7115 | import uuidscip-python python python-stdlib 3.11 uuid/__init__: |
| 7116 | pyparsing_commonscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#.uuidscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#uuid..setParseActionscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#setParseAction().(tokenMapscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/tokenMap().(uuidscip-python python python-stdlib 3.11 uuid/__init__:.UUIDscip-python python python-stdlib 3.11 uuid/UUID#)) |
| 7117 | pyparsing_commonscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#.uuidscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/pyparsing_common#uuid..runTestsscip-python python gavodachs 2.13 `gavo.imp.pyparsing`/ParserElement#runTests().(""" |
| 7118 | 12345678-1234-5678-1234-567812345678 |
| 7119 | """) |