Skip to content

Commit

Permalink
Documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
eerimoq committed Jul 29, 2018
1 parent dae8b33 commit 0b942c9
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions textparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,9 @@ def __init__(self, pattern, end=None, key=None):


class DelimitedList(Pattern):
"""Matches a delimented list of `pattern` separated by `delim`.
"""Matches a delimented list of `pattern` separated by
`delim`. Returns a list of matches if `pattern` matched at least
once. The delimitors are not part of the result.
"""

Expand Down Expand Up @@ -517,7 +519,7 @@ def match(self, tokens):


class Not(Pattern):
"""Does not match given pattern.
"""Does not match given pattern. Returns an empty list on match.
"""

Expand Down Expand Up @@ -545,7 +547,8 @@ def match(self, tokens):


class Tag(Pattern):
"""Tags any matched `pattern` with `name`.
"""Tags any matched `pattern` with `name`, and retuns it as a
two-tuple of `name` and match.
"""

Expand Down Expand Up @@ -615,6 +618,11 @@ def parse(self, tokens, token_tree=False):


def choice(*patterns):
"""Returns an instance of the fastest choice pattern class for given
`patterns`.
"""

try:
return ChoiceDict(*patterns)
except Error:
Expand Down Expand Up @@ -705,12 +713,15 @@ def token_specs(self):
``(kind, name, re)``. If the second form is used, the grammar
should use `name` instead of `kind`.
See :class:`~textparser.Parser` for an example usage.
"""

return []

def tokenize(self, text):
"""Tokenize given string `text`, and return a list of tokens.
"""Tokenize given string `text`, and return a list of tokens. Raises
:class:`~textparser.TokenizeError` on failure.
This method should only be called by
:func:`~textparser.Parser.parse()`, but may very well be
Expand Down Expand Up @@ -747,6 +758,7 @@ def grammar(self):
"""The text grammar is used to create a parse tree out of a list of
tokens.
See :class:`~textparser.Parser` for an example usage.
"""

Expand Down

0 comments on commit 0b942c9

Please sign in to comment.