1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
******************
Pratt's parser API
******************
The TDOP (Top Down Operator Precedence) parser implemented within this library is
a variant of the original Pratt's parser based on a class for the parser and
meta-classes for tokens.
The parser base class includes helper functions for registering token classes,
the Pratt's methods and a regexp-based tokenizer builder. There are also additional
methods and attributes to help the developing of new parsers. Parsers can be defined
by class derivation and following a tokens registration procedure. These classes are
not available at package level but only within module `elementpath.tdop`.
Token base class
================
.. autoclass:: elementpath.tdop.Token
.. autoattribute:: arity
.. autoattribute:: tree
.. autoattribute:: source
.. automethod:: nud
.. automethod:: led
.. automethod:: evaluate
.. automethod:: iter
Helper methods for checking symbols and for error raising:
.. automethod:: expected
.. automethod:: unexpected
.. automethod:: wrong_syntax
.. automethod:: wrong_value
.. automethod:: wrong_type
Parser base class
=================
.. autoclass:: elementpath.tdop.Parser
.. autoattribute:: position
Parsing methods:
.. automethod:: parse
.. automethod:: advance
.. automethod:: advance_until
.. automethod:: expression
Helper methods for checking parser status:
.. automethod:: is_source_start
.. automethod:: is_line_start
.. automethod:: is_spaced
Helper methods for building new parsers:
.. automethod:: register
.. automethod:: unregister
.. automethod:: duplicate
.. automethod:: literal
.. automethod:: nullary
.. automethod:: prefix
.. automethod:: postfix
.. automethod:: infix
.. automethod:: infixr
.. automethod:: method
.. automethod:: build
.. automethod:: create_tokenizer
|