|
| | __init__ (self, str init_chars="", typing.Optional[str] body_chars=None, int min=1, int max=0, int exact=0, bool as_keyword=False, typing.Optional[str] exclude_chars=None, *typing.Optional[str] initChars=None, typing.Optional[str] bodyChars=None, bool asKeyword=False, typing.Optional[str] excludeChars=None) |
| |
| | parseImpl (self, instring, loc, doActions=True) |
| |
|
| parseImpl_regex (self, instring, loc, doActions=True) |
| |
| | using_each (cls, seq, **class_kwargs) |
| |
| "ParserElement" | suppress_warning (self, Diagnostics warning_type) |
| |
| | visit_all (self) |
| |
| "ParserElement" | copy (self) |
| |
| "ParserElement" | set_results_name (self, str name, bool list_all_matches=False, *bool listAllMatches=False) |
| |
| "ParserElement" | set_break (self, bool break_flag=True) |
| |
| "ParserElement" | set_parse_action (self, *ParseAction fns, **kwargs) |
| |
| "ParserElement" | add_parse_action (self, *ParseAction fns, **kwargs) |
| |
| "ParserElement" | add_condition (self, *ParseCondition fns, **kwargs) |
| |
| "ParserElement" | set_fail_action (self, ParseFailAction fn) |
| |
|
int | preParse (self, str instring, int loc) |
| |
|
| postParse (self, instring, loc, tokenlist) |
| |
|
int | try_parse (self, str instring, int loc, *bool raise_fatal=False, bool do_actions=False) |
| |
|
bool | can_parse_next (self, str instring, int loc, bool do_actions=False) |
| |
| ParseResults | parse_string (self, str instring, bool parse_all=False, *bool parseAll=False) |
| |
| Generator[Tuple[ParseResults, int, int], None, None] | scan_string (self, str instring, int max_matches=_MAX_INT, bool overlap=False, *bool debug=False, int maxMatches=_MAX_INT) |
| |
| str | transform_string (self, str instring, *bool debug=False) |
| |
| ParseResults | search_string (self, str instring, int max_matches=_MAX_INT, *bool debug=False, int maxMatches=_MAX_INT) |
| |
| Generator[str, None, None] | split (self, str instring, int maxsplit=_MAX_INT, bool include_separators=False, *includeSeparators=False) |
| |
| "ParserElement" | __add__ (self, other) |
| |
| "ParserElement" | __radd__ (self, other) |
| |
| "ParserElement" | __sub__ (self, other) |
| |
| "ParserElement" | __rsub__ (self, other) |
| |
| "ParserElement" | __mul__ (self, other) |
| |
|
"ParserElement" | __rmul__ (self, other) |
| |
| "ParserElement" | __or__ (self, other) |
| |
| "ParserElement" | __ror__ (self, other) |
| |
| "ParserElement" | __xor__ (self, other) |
| |
| "ParserElement" | __rxor__ (self, other) |
| |
| "ParserElement" | __and__ (self, other) |
| |
| "ParserElement" | __rand__ (self, other) |
| |
| "ParserElement" | __invert__ (self) |
| |
| | __getitem__ (self, key) |
| |
| "ParserElement" | __call__ (self, typing.Optional[str] name=None) |
| |
| "ParserElement" | suppress (self) |
| |
| "ParserElement" | ignore_whitespace (self, bool recursive=True) |
| |
| "ParserElement" | leave_whitespace (self, bool recursive=True) |
| |
| "ParserElement" | set_whitespace_chars (self, Union[Set[str], str] chars, bool copy_defaults=False) |
| |
| "ParserElement" | parse_with_tabs (self) |
| |
| "ParserElement" | ignore (self, "ParserElement" other) |
| |
| "ParserElement" | set_debug_actions (self, DebugStartAction start_action, DebugSuccessAction success_action, DebugExceptionAction exception_action) |
| |
| "ParserElement" | set_debug (self, bool flag=True, bool recurse=False) |
| |
|
str | default_name (self) |
| |
| "ParserElement" | set_name (self, str name) |
| |
|
str | name (self) |
| |
|
str | __str__ (self) |
| |
|
str | __repr__ (self) |
| |
|
"ParserElement" | streamline (self) |
| |
|
List["ParserElement"] | recurse (self) |
| |
| None | validate (self, validateTrace=None) |
| |
| ParseResults | parse_file (self, Union[str, Path, TextIO] file_or_filename, str encoding="utf-8", bool parse_all=False, *bool parseAll=False) |
| |
|
| __eq__ (self, other) |
| |
|
| __hash__ (self) |
| |
| bool | matches (self, str test_string, bool parse_all=True, *bool parseAll=True) |
| |
| Tuple[bool, List[Tuple[str, Union[ParseResults, Exception]]]] | run_tests (self, Union[str, List[str]] tests, bool parse_all=True, typing.Optional[Union["ParserElement", str]] comment="#", bool full_dump=True, bool print_results=True, bool failure_tests=False, typing.Optional[Callable[[str, ParseResults], str]] post_parse=None, typing.Optional[TextIO] file=None, bool with_line_numbers=False, *bool parseAll=True, bool fullDump=True, bool printResults=True, bool failureTests=False, typing.Optional[Callable[[str, ParseResults], str]] postParse=None) |
| |
| None | create_diagram (self, Union[TextIO, Path, str] output_html, int vertical=3, bool show_results_names=False, bool show_groups=False, bool embed=False, **kwargs) |
| |
|
| setResultsName (self) |
| |
|
| setBreak (self) |
| |
|
| setParseAction (self) |
| |
|
| addParseAction (self) |
| |
|
| addCondition (self) |
| |
|
| setFailAction (self) |
| |
|
| tryParse (self) |
| |
|
| parseString (self) |
| |
|
| scanString (self) |
| |
|
| transformString (self) |
| |
|
| searchString (self) |
| |
|
| ignoreWhitespace (self) |
| |
|
| leaveWhitespace (self) |
| |
|
| setWhitespaceChars (self) |
| |
|
| parseWithTabs (self) |
| |
|
| setDebugActions (self) |
| |
|
| setDebug (self) |
| |
|
| setName (self) |
| |
|
| parseFile (self) |
| |
|
| runTests (self) |
| |
Token for matching words composed of allowed character sets.
Parameters:
- ``init_chars`` - string of all characters that should be used to
match as a word; "ABC" will match "AAA", "ABAB", "CBAC", etc.;
if ``body_chars`` is also specified, then this is the string of
initial characters
- ``body_chars`` - string of characters that
can be used for matching after a matched initial character as
given in ``init_chars``; if omitted, same as the initial characters
(default=``None``)
- ``min`` - minimum number of characters to match (default=1)
- ``max`` - maximum number of characters to match (default=0)
- ``exact`` - exact number of characters to match (default=0)
- ``as_keyword`` - match as a keyword (default=``False``)
- ``exclude_chars`` - characters that might be
found in the input ``body_chars`` string but which should not be
accepted for matching ;useful to define a word of all
printables except for one or two characters, for instance
(default=``None``)
:class:`srange` is useful for defining custom character set strings
for defining :class:`Word` expressions, using range notation from
regular expression character sets.
A common mistake is to use :class:`Word` to match a specific literal
string, as in ``Word("Address")``. Remember that :class:`Word`
uses the string argument to define *sets* of matchable characters.
This expression would match "Add", "AAA", "dAred", or any other word
made up of the characters 'A', 'd', 'r', 'e', and 's'. To match an
exact literal string, use :class:`Literal` or :class:`Keyword`.
pyparsing includes helper strings for building Words:
- :class:`alphas`
- :class:`nums`
- :class:`alphanums`
- :class:`hexnums`
- :class:`alphas8bit` (alphabetic characters in ASCII range 128-255
- accented, tilded, umlauted, etc.)
- :class:`punc8bit` (non-alphabetic characters in ASCII range
128-255 - currency, symbols, superscripts, diacriticals, etc.)
- :class:`printables` (any non-whitespace character)
``alphas``, ``nums``, and ``printables`` are also defined in several
Unicode sets - see :class:`pyparsing_unicode``.
Example::
# a word composed of digits
integer = Word(nums) # equivalent to Word("0123456789") or Word(srange("0-9"))
# a word with a leading capital, and zero or more lowercase
capital_word = Word(alphas.upper(), alphas.lower())
# hostnames are alphanumeric, with leading alpha, and '-'
hostname = Word(alphas, alphanums + '-')
# roman numeral (not a strict parser, accepts invalid mix of characters)
roman = Word("IVXLCDM")
# any string of non-whitespace characters, except for ','
csv_value = Word(printables, exclude_chars=",")