File: pratt_api.rst

package info (click to toggle)
elementpath 5.0.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,360 kB
  • sloc: python: 35,725; xml: 40; makefile: 13
file content (72 lines) | stat: -rw-r--r-- 1,930 bytes parent folder | download | duplicates (4)
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