parse.pxd 2.82 KB
Newer Older
Eckhart Arnold's avatar
Eckhart Arnold committed
1
2
3
4
#cython: infer_types=True
#cython: language_level=3
#cython: c_string_type=unicode
#cython: c_string_encoding=utf-8
5
6
7
8
9
10
11
12
13

cdef class Parser:
    cdef public str pname
    cdef public str tag_name
    cdef _grammar
    cdef object visited
    cdef object recursion_counter
    cdef object cycle_detection

eckhart's avatar
eckhart committed
14
    cpdef _parse(self, text)
eckhart's avatar
eckhart committed
15
16
17
18
19
    cpdef reset(self)
    cpdef _apply(self, func, flip)
    # cpdef push_rollback__(self, int location, func)
    # cpdef rollback_to__(self, int location)
    # cpdef line_col__(self, text)
20

eckhart's avatar
eckhart committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
cdef class Grammar:
    cdef dict __dict__
    cdef public set all_parsers__
    cdef public object start_parser__
    cdef bint _dirty_flag__
    cdef public bint history_tracking__
    cdef public bint memoization__
    cdef public bint left_recursion_handling__
#    cdef public object root_parser__  # do not uncomment this!!!
    cdef public object tree__
    cdef public object document__
    cdef public object _reversed__
    cdef public int document_length__
    cdef public list document_lbreaks__
    cdef public object variables__
    cdef public list rollback__
    cdef public int last_rb__loc__
    cdef public list call_stack__
    cdef public list history__
    cdef public bint moving_forward__
    cdef public set recursion_locations__
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58

cdef class PreprocessorToken(Parser):
    pass

cdef class ZombieParser(Parser):
    pass

cdef class Token(Parser):
    cdef public str text
    cdef public int len

cdef class RegExp(Parser):
    cdef public object regexp

cdef class Whitespace(RegExp):
    pass

59
60
61
62
63
cdef class MetaParser(Parser):
    cpdef _return_value(self, node)
    cpdef _return_values(self, results)

cdef class UnaryParser(MetaParser):
64
65
    cdef public object parser

66
cdef class NaryParser(MetaParser):
67
68
    cdef public object parsers

69
cdef class Option(UnaryParser):
70
71
72
73
74
    pass

cdef class ZeroOrMore(Option):
    pass

75
cdef class OneOrMore(UnaryParser):
76
77
    pass

78
cdef class Series(NaryParser):
79
80
81
82
    cdef public int mandatory
    cdef public object err_msgs
    cdef public object skip

83
cdef class Alternative(NaryParser):
84
85
    pass

86
cdef class AllOf(NaryParser):
87
88
89
90
91
    cdef public int num_parsers
    cdef public int mandatory
    cdef public object err_msgs
    cdef public object skip

92
cdef class SomeOf(NaryParser):
93
94
    pass

95
cdef class FlowParser(UnaryParser):
96
97
    pass

98
cdef class Lookahead(FlowParser):
99
100
101
102
103
    pass

cdef class NegativeLookahead(Lookahead):
    pass

104
cdef class Lookbehind(FlowParser):
105
106
107
108
109
110
    cdef public object regexp
    cdef public str text

cdef class NegativeLookbehind(Lookbehind):
    pass

111
cdef class Capture(UnaryParser):
112
113
114
115
116
117
118
    pass

cdef class Retrieve(Parser):
    cdef public object symbol
    cdef public object filter

cdef class Pop(Retrieve):
eckhart's avatar
eckhart committed
119
    cdef public list values
120

121
cdef class Synonym(UnaryParser):
122
123
124
125
126
    pass

cdef class Forward(Parser):
    cdef public object parser
    cdef public bint cycle_reached