forked from JetBrains/phpstorm-stubs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRParser.php
199 lines (175 loc) · 5.83 KB
/
RParser.php
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?php
namespace Parle;
class RParser
{
/* Constants */
const ACTION_ERROR = 0 ;
const ACTION_SHIFT = 1 ;
const ACTION_REDUCE = 2 ;
const ACTION_GOTO = 3 ;
const ACTION_ACCEPT = 4 ;
const ERROR_SYNTAX = 0 ;
const ERROR_NON_ASSOCIATIVE = 1 ;
const ERROR_UNKOWN_TOKEN = 2 ;
/* Properties */
/**
* @var int Current parser action that matches one of the action class constants, readonly.
* @property-read
*/
public $action = 0;
/**
* @var int Grammar rule id just processed in the reduce action. The value corresponds either to a token or to a production id. Readonly.
* @property-read
*/
public $reduceId = 0;
/* Methods */
/**
* Process next parser rule.
*
* @link https://php.net/manual/en/parle-rparser.advance.php
* @return void
*/
public function advance() : void {}
/**
* Finalize the grammar rules
*
* Any tokens and grammar rules previously added are finalized.
* The rule set becomes readonly and the parser is ready to start.
*
* @link https://php.net/manual/en/parle-rparser.build.php
* @return void
*/
public function build() : void {}
/**
* Consume the data for parsing.
*
* @link https://php.net/manual/en/parle-rparser.consume.php
* @param string $data Data to be parsed.
* @param Lexer $lexer A lexer object containing the lexing rules prepared for the particular grammar.
* @return void
*/
public function consume(string $data, Lexer $lexer) : void {}
/**
* Dump the current grammar to stdout.
*
* @link https://php.net/manual/en/parle-rparser.dump.php
* @return void
*/
public function dump() : void {}
/**
* Retrieve the error information in case Parle\RParser::action() returned the error action.
*
* @link https://php.net/manual/en/parle-rparser.errorinfo.php
* @return ErrorInfo
*/
public function errorInfo() : ErrorInfo {}
/**
* Declare a terminal with left associativity.
*
* @link https://php.net/manual/en/parle-rparser.left.php
* @param string $token Token name.
* @return void
*/
public function left(string $token) : void {}
/**
* Declare a token with no associativity
*
* Declare a terminal, that cannot appear more than once in the row.
*
* @link https://php.net/manual/en/parle-rparser.nonassoc.php
* @param string $token Token name.
* @return void
*/
public function nonassoc(string $token) : void {}
/**
* Declare a precedence rule
*
* Declares a precedence rule for a fictitious terminal symbol.
* This rule can be later used in the specific grammar rules.
*
* @link https://php.net/manual/en/parle-rparser.precedence.php
* @param string $token
* @return void
*/
public function precedence(string $token) : void {}
/**
* Push a grammar rule.
*
* The production id returned can be used later in the parsing process to identify the rule matched.
*
* @link https://php.net/manual/en/parle-rparser.push.php
* @param string $name Rule name.
* @param string $rule The rule to be added. The syntax is Bison compatible.
* @return int Returns integer representing the rule index.
*/
public function push(string $name, string $rule) : int {}
/**
* Reset parser state using the given token id.
*
* @link https://php.net/manual/en/parle-rparser.reset.php
* @param int $tokenId Token id.
* @return void
*/
public function reset(int $tokenId) : void {}
/**
* Declare a token with right-associativity
*
* @link https://php.net/manual/en/parle-rparser.right.php
* @param string $token Token name.
* @return void
*/
public function right(string $token) : void {}
/**
* Retrieve a matching part of a rule
*
* Retrieve a part of the match by a rule.
* This method is equivalent to the pseudo variable functionality in Bison.
*
* @link https://php.net/manual/en/parle-rparser.sigil.php
* @param int $idx Match index, zero based.
* @return string Returns a string with the matched part.
*/
public function sigil(int $idx) : string {}
/**
* Declare a token
*
* Declare a terminal to be used in the grammar.
*
* @link https://php.net/manual/en/parle-rparser.token.php
* @param string $token Token name.
* @return void
*/
public function token(string $token) : void {}
/**
* Get token id
*
* Retrieve the id of the named token.
*
* @link https://php.net/manual/en/parle-rparser.tokenid.php
* @param string $token Name of the token as used in Parle\Parser::token().
* @return int Returns integer representing the token id.
* @see Parser::token()
*/
public function tokenId(string $token) : int {}
/**
* Trace the parser operation
*
* Retrieve the current parser operation description.
* This can be especially useful for studying the parser and to optimize the grammar.
*
* @link https://php.net/manual/en/parle-rparser.trace.php
* @return string Returns a string with the trace information.
*/
public function trace() : string {}
/**
* Validate an input string.
*
* The string is parsed internally, thus this method is useful for the quick input validation.
*
* @link https://php.net/manual/en/parle-rparser.validate.php
* @param string $data String to be validated.
* @param Lexer $lexer A lexer object containing the lexing rules prepared for the particular grammar.
* @return bool Returns boolean witnessing whether the input chimes or not with the defined rules.
*/
public function validate(string $data, Lexer $lexer) : bool {}
}