racc 1.5.2 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.ja.rdoc +0 -1
- data/README.rdoc +6 -7
- data/{rdoc → doc}/en/NEWS.en.rdoc +0 -0
- data/{rdoc → doc}/en/grammar.en.rdoc +27 -31
- data/doc/en/grammar2.en.rdoc +219 -0
- data/{rdoc → doc}/ja/NEWS.ja.rdoc +0 -0
- data/{rdoc → doc}/ja/command.ja.html +0 -0
- data/{rdoc → doc}/ja/debug.ja.rdoc +0 -0
- data/{rdoc → doc}/ja/grammar.ja.rdoc +0 -0
- data/{rdoc → doc}/ja/index.ja.html +0 -0
- data/{rdoc → doc}/ja/parser.ja.rdoc +0 -0
- data/{rdoc → doc}/ja/usage.ja.html +0 -0
- data/ext/racc/cparse/cparse.c +1 -1
- data/ext/racc/cparse/extconf.rb +1 -0
- data/lib/racc/info.rb +1 -1
- data/lib/racc/parser-text.rb +1 -1
- data/lib/racc/parser.rb +1 -1
- data/lib/racc/parserfilegenerator.rb +0 -44
- data/lib/racc/statetransitiontable.rb +2 -8
- metadata +15 -121
- data/Rakefile +0 -79
- data/ext/racc/com/headius/racc/Cparse.java +0 -849
- data/lib/racc/pre-setup +0 -13
- data/sample/array.y +0 -67
- data/sample/array2.y +0 -59
- data/sample/calc-ja.y +0 -66
- data/sample/calc.y +0 -65
- data/sample/conflict.y +0 -15
- data/sample/hash.y +0 -60
- data/sample/lalr.y +0 -17
- data/sample/lists.y +0 -57
- data/sample/syntax.y +0 -46
- data/sample/yyerr.y +0 -46
- data/test/assets/cadenza.y +0 -170
- data/test/assets/cast.y +0 -926
- data/test/assets/chk.y +0 -126
- data/test/assets/conf.y +0 -16
- data/test/assets/csspool.y +0 -729
- data/test/assets/digraph.y +0 -29
- data/test/assets/echk.y +0 -118
- data/test/assets/edtf.y +0 -583
- data/test/assets/err.y +0 -60
- data/test/assets/error_recovery.y +0 -35
- data/test/assets/expect.y +0 -7
- data/test/assets/firstline.y +0 -4
- data/test/assets/huia.y +0 -318
- data/test/assets/ichk.y +0 -102
- data/test/assets/intp.y +0 -546
- data/test/assets/journey.y +0 -47
- data/test/assets/liquor.y +0 -313
- data/test/assets/machete.y +0 -423
- data/test/assets/macruby.y +0 -2197
- data/test/assets/mailp.y +0 -437
- data/test/assets/mediacloth.y +0 -599
- data/test/assets/mof.y +0 -649
- data/test/assets/namae.y +0 -302
- data/test/assets/nasl.y +0 -626
- data/test/assets/newsyn.y +0 -25
- data/test/assets/noend.y +0 -4
- data/test/assets/nokogiri-css.y +0 -255
- data/test/assets/nonass.y +0 -41
- data/test/assets/normal.y +0 -27
- data/test/assets/norule.y +0 -4
- data/test/assets/nullbug1.y +0 -25
- data/test/assets/nullbug2.y +0 -15
- data/test/assets/opal.y +0 -1807
- data/test/assets/opt.y +0 -123
- data/test/assets/percent.y +0 -35
- data/test/assets/php_serialization.y +0 -98
- data/test/assets/recv.y +0 -97
- data/test/assets/riml.y +0 -665
- data/test/assets/rrconf.y +0 -14
- data/test/assets/ruby18.y +0 -1943
- data/test/assets/ruby19.y +0 -2174
- data/test/assets/ruby20.y +0 -2350
- data/test/assets/ruby21.y +0 -2359
- data/test/assets/ruby22.y +0 -2381
- data/test/assets/scan.y +0 -72
- data/test/assets/syntax.y +0 -50
- data/test/assets/tp_plus.y +0 -622
- data/test/assets/twowaysql.y +0 -278
- data/test/assets/unterm.y +0 -5
- data/test/assets/useless.y +0 -12
- data/test/assets/yyerr.y +0 -46
- data/test/bench.y +0 -36
- data/test/helper.rb +0 -115
- data/test/infini.y +0 -8
- data/test/regress/cadenza +0 -796
- data/test/regress/cast +0 -3428
- data/test/regress/csspool +0 -2314
- data/test/regress/edtf +0 -1794
- data/test/regress/huia +0 -1392
- data/test/regress/journey +0 -222
- data/test/regress/liquor +0 -885
- data/test/regress/machete +0 -833
- data/test/regress/mediacloth +0 -1463
- data/test/regress/mof +0 -1368
- data/test/regress/namae +0 -634
- data/test/regress/nasl +0 -2058
- data/test/regress/nokogiri-css +0 -836
- data/test/regress/opal +0 -6431
- data/test/regress/php_serialization +0 -336
- data/test/regress/riml +0 -3283
- data/test/regress/ruby18 +0 -6344
- data/test/regress/ruby22 +0 -7460
- data/test/regress/tp_plus +0 -1933
- data/test/regress/twowaysql +0 -556
- data/test/scandata/brace +0 -7
- data/test/scandata/gvar +0 -1
- data/test/scandata/normal +0 -4
- data/test/scandata/percent +0 -18
- data/test/scandata/slash +0 -10
- data/test/src.intp +0 -34
- data/test/start.y +0 -20
- data/test/test_chk_y.rb +0 -52
- data/test/test_grammar_file_parser.rb +0 -15
- data/test/test_racc_command.rb +0 -339
- data/test/test_scan_y.rb +0 -52
- data/test/testscanner.rb +0 -51
- data/web/racc.en.rhtml +0 -42
- data/web/racc.ja.rhtml +0 -51
data/test/assets/nasl.y
DELETED
@@ -1,626 +0,0 @@
|
|
1
|
-
################################################################################
|
2
|
-
# Copyright (c) 2011-2014, Tenable Network Security
|
3
|
-
# All rights reserved.
|
4
|
-
#
|
5
|
-
# Redistribution and use in source and binary forms, with or without
|
6
|
-
# modification, are permitted provided that the following conditions are met:
|
7
|
-
#
|
8
|
-
# 1. Redistributions of source code must retain the above copyright notice, this
|
9
|
-
# list of conditions and the following disclaimer.
|
10
|
-
#
|
11
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
12
|
-
# this list of conditions and the following disclaimer in the documentation
|
13
|
-
# and/or other materials provided with the distribution.
|
14
|
-
#
|
15
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
16
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18
|
-
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
19
|
-
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
20
|
-
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
21
|
-
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
22
|
-
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
23
|
-
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
24
|
-
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
25
|
-
################################################################################
|
26
|
-
|
27
|
-
class Nasl::Grammar
|
28
|
-
|
29
|
-
preclow
|
30
|
-
right ASS_EQ ADD_EQ SUB_EQ MUL_EQ DIV_EQ MOD_EQ SLL_EQ SRA_EQ SRL_EQ
|
31
|
-
left OR
|
32
|
-
left AND
|
33
|
-
left CMP_LT CMP_GT CMP_EQ CMP_NE CMP_GE CMP_LE SUBSTR_EQ SUBSTR_NE REGEX_EQ REGEX_NE
|
34
|
-
left BIT_OR
|
35
|
-
left BIT_XOR
|
36
|
-
left AMPERSAND
|
37
|
-
left BIT_SRA BIT_SRL BIT_SLL
|
38
|
-
left ADD SUB
|
39
|
-
left MUL DIV MOD
|
40
|
-
right NOT
|
41
|
-
right UMINUS BIT_NOT
|
42
|
-
right EXP
|
43
|
-
right INCR DECR
|
44
|
-
prechigh
|
45
|
-
|
46
|
-
# Tell the parser generator that we don't wish to use the result variable in the
|
47
|
-
# action section of rules. Instead, the result of the rule will be the value of
|
48
|
-
# evaluating the action block.
|
49
|
-
options no_result_var
|
50
|
-
|
51
|
-
# Tell the parser generator that we expect one shift/reduce conflict due to the
|
52
|
-
# well-known dangling else problem. We could make the grammar solve this
|
53
|
-
# problem, but this is how the NASL YACC file solves it, so we'll follow suit.
|
54
|
-
expect 1
|
55
|
-
|
56
|
-
rule
|
57
|
-
##############################################################################
|
58
|
-
# Aggregate Statements
|
59
|
-
##############################################################################
|
60
|
-
|
61
|
-
start : roots
|
62
|
-
{ val[0] }
|
63
|
-
| /* Blank */
|
64
|
-
{ [] }
|
65
|
-
;
|
66
|
-
|
67
|
-
roots : root roots
|
68
|
-
{ [val[0]] + val[1] }
|
69
|
-
| root
|
70
|
-
{ [val[0]] }
|
71
|
-
;
|
72
|
-
|
73
|
-
root : COMMENT export
|
74
|
-
{ c(*val) }
|
75
|
-
| export
|
76
|
-
{ val[0] }
|
77
|
-
| COMMENT function
|
78
|
-
{ c(*val) }
|
79
|
-
| function
|
80
|
-
{ val[0] }
|
81
|
-
| statement
|
82
|
-
{ val[0] }
|
83
|
-
;
|
84
|
-
|
85
|
-
statement : simple
|
86
|
-
{ val[0] }
|
87
|
-
| compound
|
88
|
-
{ val[0] }
|
89
|
-
;
|
90
|
-
|
91
|
-
##############################################################################
|
92
|
-
# Root Statements
|
93
|
-
##############################################################################
|
94
|
-
|
95
|
-
export : EXPORT function
|
96
|
-
{ n(:Export, *val) }
|
97
|
-
;
|
98
|
-
|
99
|
-
function : FUNCTION ident LPAREN params RPAREN block
|
100
|
-
{ n(:Function, *val) }
|
101
|
-
| FUNCTION ident LPAREN RPAREN block
|
102
|
-
{ n(:Function, *val) }
|
103
|
-
;
|
104
|
-
|
105
|
-
simple : assign
|
106
|
-
{ val[0] }
|
107
|
-
| break
|
108
|
-
{ val[0] }
|
109
|
-
| call
|
110
|
-
{ val[0] }
|
111
|
-
| continue
|
112
|
-
{ val[0] }
|
113
|
-
| decr
|
114
|
-
{ val[0] }
|
115
|
-
| empty
|
116
|
-
{ val[0] }
|
117
|
-
| COMMENT global
|
118
|
-
{ c(*val) }
|
119
|
-
| global
|
120
|
-
{ val[0] }
|
121
|
-
| import
|
122
|
-
{ val[0] }
|
123
|
-
| include
|
124
|
-
{ val[0] }
|
125
|
-
| incr
|
126
|
-
{ val[0] }
|
127
|
-
| local
|
128
|
-
{ val[0] }
|
129
|
-
| rep
|
130
|
-
{ val[0] }
|
131
|
-
| return
|
132
|
-
{ val[0] }
|
133
|
-
;
|
134
|
-
|
135
|
-
compound : block
|
136
|
-
{ val[0] }
|
137
|
-
| for
|
138
|
-
{ val[0] }
|
139
|
-
| foreach
|
140
|
-
{ val[0] }
|
141
|
-
| if
|
142
|
-
{ val[0] }
|
143
|
-
| repeat
|
144
|
-
{ val[0] }
|
145
|
-
| while
|
146
|
-
{ val[0] }
|
147
|
-
;
|
148
|
-
|
149
|
-
##############################################################################
|
150
|
-
# Simple Statements
|
151
|
-
##############################################################################
|
152
|
-
|
153
|
-
assign : assign_exp SEMICOLON
|
154
|
-
{ val[0] }
|
155
|
-
;
|
156
|
-
|
157
|
-
break : BREAK SEMICOLON
|
158
|
-
{ n(:Break, *val) }
|
159
|
-
;
|
160
|
-
|
161
|
-
call : call_exp SEMICOLON
|
162
|
-
{ val[0] }
|
163
|
-
;
|
164
|
-
|
165
|
-
continue : CONTINUE SEMICOLON
|
166
|
-
{ n(:Continue, *val) }
|
167
|
-
;
|
168
|
-
|
169
|
-
decr : decr_exp SEMICOLON
|
170
|
-
{ val[0] }
|
171
|
-
;
|
172
|
-
|
173
|
-
empty : SEMICOLON
|
174
|
-
{ n(:Empty, *val) }
|
175
|
-
;
|
176
|
-
|
177
|
-
global : GLOBAL var_decls SEMICOLON
|
178
|
-
{ n(:Global, *val) }
|
179
|
-
;
|
180
|
-
|
181
|
-
incr : incr_exp SEMICOLON
|
182
|
-
{ val[0] }
|
183
|
-
;
|
184
|
-
|
185
|
-
import : IMPORT LPAREN string RPAREN SEMICOLON
|
186
|
-
{ n(:Import, *val) }
|
187
|
-
;
|
188
|
-
|
189
|
-
include : INCLUDE LPAREN string RPAREN SEMICOLON
|
190
|
-
{ n(:Include, *val) }
|
191
|
-
;
|
192
|
-
|
193
|
-
local : LOCAL var_decls SEMICOLON
|
194
|
-
{ n(:Local, *val) }
|
195
|
-
;
|
196
|
-
|
197
|
-
rep : call_exp REP expr SEMICOLON
|
198
|
-
{ n(:Repetition, *val[0..-1]) }
|
199
|
-
;
|
200
|
-
|
201
|
-
return : RETURN expr SEMICOLON
|
202
|
-
{ n(:Return, *val) }
|
203
|
-
| RETURN ref SEMICOLON
|
204
|
-
{ n(:Return, *val) }
|
205
|
-
| RETURN SEMICOLON
|
206
|
-
{ n(:Return, *val) }
|
207
|
-
;
|
208
|
-
|
209
|
-
##############################################################################
|
210
|
-
# Compound Statements
|
211
|
-
##############################################################################
|
212
|
-
|
213
|
-
block : LBRACE statements RBRACE
|
214
|
-
{ n(:Block, *val) }
|
215
|
-
| LBRACE RBRACE
|
216
|
-
{ n(:Block, *val) }
|
217
|
-
;
|
218
|
-
|
219
|
-
for : FOR LPAREN field SEMICOLON expr SEMICOLON field RPAREN statement
|
220
|
-
{ n(:For, *val) }
|
221
|
-
;
|
222
|
-
|
223
|
-
foreach : FOREACH ident LPAREN expr RPAREN statement
|
224
|
-
{ n(:Foreach, val[0], val[1], val[3], val[5]) }
|
225
|
-
| FOREACH LPAREN ident IN expr RPAREN statement
|
226
|
-
{ n(:Foreach, val[0], val[2], val[4], val[6]) }
|
227
|
-
;
|
228
|
-
|
229
|
-
if : IF LPAREN expr RPAREN statement
|
230
|
-
{ n(:If, *val) }
|
231
|
-
| IF LPAREN expr RPAREN statement ELSE statement
|
232
|
-
{ n(:If, *val) }
|
233
|
-
;
|
234
|
-
|
235
|
-
repeat : REPEAT statement UNTIL expr SEMICOLON
|
236
|
-
{ n(:Repeat, *val) }
|
237
|
-
;
|
238
|
-
|
239
|
-
while : WHILE LPAREN expr RPAREN statement
|
240
|
-
{ n(:While, *val) }
|
241
|
-
;
|
242
|
-
|
243
|
-
##############################################################################
|
244
|
-
# Expressions
|
245
|
-
##############################################################################
|
246
|
-
|
247
|
-
assign_exp : lval ASS_EQ expr
|
248
|
-
{ n(:Assignment, *val) }
|
249
|
-
| lval ASS_EQ ref
|
250
|
-
{ n(:Assignment, *val) }
|
251
|
-
| lval ADD_EQ expr
|
252
|
-
{ n(:Assignment, *val) }
|
253
|
-
| lval SUB_EQ expr
|
254
|
-
{ n(:Assignment, *val) }
|
255
|
-
| lval MUL_EQ expr
|
256
|
-
{ n(:Assignment, *val) }
|
257
|
-
| lval DIV_EQ expr
|
258
|
-
{ n(:Assignment, *val) }
|
259
|
-
| lval MOD_EQ expr
|
260
|
-
{ n(:Assignment, *val) }
|
261
|
-
| lval SRL_EQ expr
|
262
|
-
{ n(:Assignment, *val) }
|
263
|
-
| lval SRA_EQ expr
|
264
|
-
{ n(:Assignment, *val) }
|
265
|
-
| lval SLL_EQ expr
|
266
|
-
{ n(:Assignment, *val) }
|
267
|
-
;
|
268
|
-
|
269
|
-
call_exp : lval LPAREN args RPAREN
|
270
|
-
{ n(:Call, *val) }
|
271
|
-
| lval LPAREN RPAREN
|
272
|
-
{ n(:Call, *val) }
|
273
|
-
;
|
274
|
-
|
275
|
-
decr_exp : DECR lval
|
276
|
-
{ n(:Decrement, val[0]) }
|
277
|
-
| lval DECR
|
278
|
-
{ n(:Decrement, val[0]) }
|
279
|
-
;
|
280
|
-
|
281
|
-
incr_exp : INCR lval
|
282
|
-
{ n(:Increment, val[0]) }
|
283
|
-
| lval INCR
|
284
|
-
{ n(:Increment, val[0]) }
|
285
|
-
;
|
286
|
-
|
287
|
-
expr : LPAREN expr RPAREN
|
288
|
-
{ n(:Expression, *val) }
|
289
|
-
| expr AND expr
|
290
|
-
{ n(:Expression, *val) }
|
291
|
-
| NOT expr
|
292
|
-
{ n(:Expression, *val) }
|
293
|
-
| expr OR expr
|
294
|
-
{ n(:Expression, *val) }
|
295
|
-
| expr ADD expr
|
296
|
-
{ n(:Expression, *val) }
|
297
|
-
| expr SUB expr
|
298
|
-
{ n(:Expression, *val) }
|
299
|
-
| SUB expr =UMINUS
|
300
|
-
{ n(:Expression, *val) }
|
301
|
-
| BIT_NOT expr
|
302
|
-
{ n(:Expression, *val) }
|
303
|
-
| expr MUL expr
|
304
|
-
{ n(:Expression, *val) }
|
305
|
-
| expr EXP expr
|
306
|
-
{ n(:Expression, *val) }
|
307
|
-
| expr DIV expr
|
308
|
-
{ n(:Expression, *val) }
|
309
|
-
| expr MOD expr
|
310
|
-
{ n(:Expression, *val) }
|
311
|
-
| expr AMPERSAND expr
|
312
|
-
{ n(:Expression, *val) }
|
313
|
-
| expr BIT_XOR expr
|
314
|
-
{ n(:Expression, *val) }
|
315
|
-
| expr BIT_OR expr
|
316
|
-
{ n(:Expression, *val) }
|
317
|
-
| expr BIT_SRA expr
|
318
|
-
{ n(:Expression, *val) }
|
319
|
-
| expr BIT_SRL expr
|
320
|
-
{ n(:Expression, *val) }
|
321
|
-
| expr BIT_SLL expr
|
322
|
-
{ n(:Expression, *val) }
|
323
|
-
| incr_exp
|
324
|
-
{ val[0] }
|
325
|
-
| decr_exp
|
326
|
-
{ val[0] }
|
327
|
-
| expr SUBSTR_EQ expr
|
328
|
-
{ n(:Expression, *val) }
|
329
|
-
| expr SUBSTR_NE expr
|
330
|
-
{ n(:Expression, *val) }
|
331
|
-
| expr REGEX_EQ expr
|
332
|
-
{ n(:Expression, *val) }
|
333
|
-
| expr REGEX_NE expr
|
334
|
-
{ n(:Expression, *val) }
|
335
|
-
| expr CMP_LT expr
|
336
|
-
{ n(:Expression, *val) }
|
337
|
-
| expr CMP_GT expr
|
338
|
-
{ n(:Expression, *val) }
|
339
|
-
| expr CMP_EQ expr
|
340
|
-
{ n(:Expression, *val) }
|
341
|
-
| expr CMP_NE expr
|
342
|
-
{ n(:Expression, *val) }
|
343
|
-
| expr CMP_GE expr
|
344
|
-
{ n(:Expression, *val) }
|
345
|
-
| expr CMP_LE expr
|
346
|
-
{ n(:Expression, *val) }
|
347
|
-
| assign_exp
|
348
|
-
{ val[0] }
|
349
|
-
| string
|
350
|
-
{ val[0] }
|
351
|
-
| call_exp
|
352
|
-
{ val[0] }
|
353
|
-
| lval
|
354
|
-
{ val[0] }
|
355
|
-
| ip
|
356
|
-
{ val[0] }
|
357
|
-
| int
|
358
|
-
{ val[0] }
|
359
|
-
| undef
|
360
|
-
{ val[0] }
|
361
|
-
| list_expr
|
362
|
-
{ val[0] }
|
363
|
-
| array_expr
|
364
|
-
{ val[0] }
|
365
|
-
;
|
366
|
-
|
367
|
-
##############################################################################
|
368
|
-
# Named Components
|
369
|
-
##############################################################################
|
370
|
-
|
371
|
-
arg : ident COLON expr
|
372
|
-
{ n(:Argument, *val) }
|
373
|
-
| ident COLON ref
|
374
|
-
{ n(:Argument, *val) }
|
375
|
-
| expr
|
376
|
-
{ n(:Argument, *val) }
|
377
|
-
| ref
|
378
|
-
{ n(:Argument, *val) }
|
379
|
-
;
|
380
|
-
|
381
|
-
kv_pair : string COLON expr
|
382
|
-
{ n(:KeyValuePair, *val) }
|
383
|
-
| int COLON expr
|
384
|
-
{ n(:KeyValuePair, *val) }
|
385
|
-
| ident COLON expr
|
386
|
-
{ n(:KeyValuePair, *val) }
|
387
|
-
| string COLON ref
|
388
|
-
{ n(:KeyValuePair, *val) }
|
389
|
-
| int COLON ref
|
390
|
-
{ n(:KeyValuePair, *val) }
|
391
|
-
| ident COLON ref
|
392
|
-
{ n(:KeyValuePair, *val) }
|
393
|
-
;
|
394
|
-
|
395
|
-
kv_pairs : kv_pair COMMA kv_pairs
|
396
|
-
{ [val[0]] + val[2] }
|
397
|
-
| kv_pair COMMA
|
398
|
-
{ [val[0]] }
|
399
|
-
| kv_pair
|
400
|
-
{ [val[0]] }
|
401
|
-
;
|
402
|
-
|
403
|
-
lval : ident indexes
|
404
|
-
{ n(:Lvalue, *val) }
|
405
|
-
| ident
|
406
|
-
{ n(:Lvalue, *val) }
|
407
|
-
;
|
408
|
-
|
409
|
-
ref : AT_SIGN ident
|
410
|
-
{ n(:Reference, val[1]) }
|
411
|
-
;
|
412
|
-
|
413
|
-
##############################################################################
|
414
|
-
# Anonymous Components
|
415
|
-
##############################################################################
|
416
|
-
|
417
|
-
args : arg COMMA args
|
418
|
-
{ [val[0]] + val[2] }
|
419
|
-
| arg
|
420
|
-
{ [val[0]] }
|
421
|
-
;
|
422
|
-
|
423
|
-
array_expr : LBRACE kv_pairs RBRACE
|
424
|
-
{ n(:Array, *val) }
|
425
|
-
| LBRACE RBRACE
|
426
|
-
{ n(:Array, *val) }
|
427
|
-
;
|
428
|
-
|
429
|
-
field : assign_exp
|
430
|
-
{ val[0] }
|
431
|
-
| call_exp
|
432
|
-
{ val[0] }
|
433
|
-
| decr_exp
|
434
|
-
{ val[0] }
|
435
|
-
| incr_exp
|
436
|
-
{ val[0] }
|
437
|
-
| /* Blank */
|
438
|
-
{ nil }
|
439
|
-
;
|
440
|
-
|
441
|
-
index : LBRACK expr RBRACK
|
442
|
-
{ val[1] }
|
443
|
-
| PERIOD ident
|
444
|
-
{ val[1] }
|
445
|
-
;
|
446
|
-
|
447
|
-
indexes : index indexes
|
448
|
-
{ [val[0]] + val[1] }
|
449
|
-
| index
|
450
|
-
{ [val[0]] }
|
451
|
-
;
|
452
|
-
|
453
|
-
list_elem : expr
|
454
|
-
{ val[0] }
|
455
|
-
| ref
|
456
|
-
{ val[0] }
|
457
|
-
;
|
458
|
-
|
459
|
-
list_elems : list_elem COMMA list_elems
|
460
|
-
{ [val[0]] + val[2] }
|
461
|
-
| list_elem
|
462
|
-
{ [val[0]] }
|
463
|
-
;
|
464
|
-
|
465
|
-
list_expr : LBRACK list_elems RBRACK
|
466
|
-
{ n(:List, *val) }
|
467
|
-
| LBRACK RBRACK
|
468
|
-
{ n(:List, *val) }
|
469
|
-
;
|
470
|
-
|
471
|
-
param : AMPERSAND ident
|
472
|
-
{ n(:Parameter, val[1], 'reference') }
|
473
|
-
| ident
|
474
|
-
{ n(:Parameter, val[0], 'value') }
|
475
|
-
;
|
476
|
-
|
477
|
-
params : param COMMA params
|
478
|
-
{ [val[0]] + val[2] }
|
479
|
-
| param
|
480
|
-
{ [val[0]] }
|
481
|
-
;
|
482
|
-
|
483
|
-
statements : statement statements
|
484
|
-
{ [val[0]] + val[1] }
|
485
|
-
| statement
|
486
|
-
{ [val[0]] }
|
487
|
-
;
|
488
|
-
|
489
|
-
var_decl : ident ASS_EQ expr
|
490
|
-
{ n(:Assignment, *val) }
|
491
|
-
| ident ASS_EQ ref
|
492
|
-
{ n(:Assignment, *val) }
|
493
|
-
| ident
|
494
|
-
{ val[0] }
|
495
|
-
;
|
496
|
-
|
497
|
-
var_decls : var_decl COMMA var_decls
|
498
|
-
{ [val[0]] + val[2] }
|
499
|
-
| var_decl
|
500
|
-
{ [val[0]] }
|
501
|
-
;
|
502
|
-
|
503
|
-
##############################################################################
|
504
|
-
# Literals
|
505
|
-
##############################################################################
|
506
|
-
|
507
|
-
ident : IDENT
|
508
|
-
{ n(:Identifier, *val) }
|
509
|
-
| REP
|
510
|
-
{ n(:Identifier, *val) }
|
511
|
-
| IN
|
512
|
-
{ n(:Identifier, *val) }
|
513
|
-
;
|
514
|
-
|
515
|
-
int : INT_DEC
|
516
|
-
{ n(:Integer, *val) }
|
517
|
-
| INT_HEX
|
518
|
-
{ n(:Integer, *val) }
|
519
|
-
| INT_OCT
|
520
|
-
{ n(:Integer, *val) }
|
521
|
-
| FALSE
|
522
|
-
{ n(:Integer, *val) }
|
523
|
-
| TRUE
|
524
|
-
{ n(:Integer, *val) }
|
525
|
-
;
|
526
|
-
|
527
|
-
ip : int PERIOD int PERIOD int PERIOD int
|
528
|
-
{ n(:Ip, *val) }
|
529
|
-
|
530
|
-
string : DATA
|
531
|
-
{ n(:String, *val) }
|
532
|
-
| STRING
|
533
|
-
{ n(:String, *val) }
|
534
|
-
;
|
535
|
-
|
536
|
-
undef : UNDEF
|
537
|
-
{ n(:Undefined, *val) }
|
538
|
-
;
|
539
|
-
end
|
540
|
-
|
541
|
-
---- header ----
|
542
|
-
|
543
|
-
require 'nasl/parser/tree'
|
544
|
-
|
545
|
-
require 'nasl/parser/argument'
|
546
|
-
require 'nasl/parser/array'
|
547
|
-
require 'nasl/parser/assigment'
|
548
|
-
require 'nasl/parser/block'
|
549
|
-
require 'nasl/parser/break'
|
550
|
-
require 'nasl/parser/call'
|
551
|
-
require 'nasl/parser/comment'
|
552
|
-
require 'nasl/parser/continue'
|
553
|
-
require 'nasl/parser/decrement'
|
554
|
-
require 'nasl/parser/empty'
|
555
|
-
require 'nasl/parser/export'
|
556
|
-
require 'nasl/parser/expression'
|
557
|
-
require 'nasl/parser/for'
|
558
|
-
require 'nasl/parser/foreach'
|
559
|
-
require 'nasl/parser/function'
|
560
|
-
require 'nasl/parser/global'
|
561
|
-
require 'nasl/parser/identifier'
|
562
|
-
require 'nasl/parser/if'
|
563
|
-
require 'nasl/parser/import'
|
564
|
-
require 'nasl/parser/include'
|
565
|
-
require 'nasl/parser/increment'
|
566
|
-
require 'nasl/parser/integer'
|
567
|
-
require 'nasl/parser/ip'
|
568
|
-
require 'nasl/parser/key_value_pair'
|
569
|
-
require 'nasl/parser/list'
|
570
|
-
require 'nasl/parser/local'
|
571
|
-
require 'nasl/parser/lvalue'
|
572
|
-
require 'nasl/parser/parameter'
|
573
|
-
require 'nasl/parser/reference'
|
574
|
-
require 'nasl/parser/repeat'
|
575
|
-
require 'nasl/parser/repetition'
|
576
|
-
require 'nasl/parser/return'
|
577
|
-
require 'nasl/parser/string'
|
578
|
-
require 'nasl/parser/undefined'
|
579
|
-
require 'nasl/parser/while'
|
580
|
-
|
581
|
-
---- inner ----
|
582
|
-
|
583
|
-
def n(cls, *args)
|
584
|
-
begin
|
585
|
-
Nasl.const_get(cls).new(@tree, *args)
|
586
|
-
rescue
|
587
|
-
puts "An exception occurred during the creation of a #{cls} instance."
|
588
|
-
puts
|
589
|
-
puts "The arguments passed to the constructor were:"
|
590
|
-
puts args
|
591
|
-
puts
|
592
|
-
puts @tok.last.context
|
593
|
-
puts
|
594
|
-
raise
|
595
|
-
end
|
596
|
-
end
|
597
|
-
|
598
|
-
def c(*args)
|
599
|
-
n(:Comment, *args)
|
600
|
-
args[1]
|
601
|
-
end
|
602
|
-
|
603
|
-
def on_error(type, value, stack)
|
604
|
-
raise ParseException, "The language's grammar does not permit #{value.name} to appear here", value.context
|
605
|
-
end
|
606
|
-
|
607
|
-
def next_token
|
608
|
-
@tok = @tkz.get_token
|
609
|
-
|
610
|
-
if @first && @tok.first == :COMMENT
|
611
|
-
n(:Comment, @tok.last)
|
612
|
-
@tok = @tkz.get_token
|
613
|
-
end
|
614
|
-
@first = false
|
615
|
-
|
616
|
-
return @tok
|
617
|
-
end
|
618
|
-
|
619
|
-
def parse(env, code, path)
|
620
|
-
@first = true
|
621
|
-
@tree = Tree.new(env)
|
622
|
-
@tkz = Tokenizer.new(code, path)
|
623
|
-
@tree.concat(do_parse)
|
624
|
-
end
|
625
|
-
|
626
|
-
---- footer ----
|
data/test/assets/newsyn.y
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
|
2
|
-
class A
|
3
|
-
|
4
|
-
preclow
|
5
|
-
left preclow prechigh right left nonassoc token
|
6
|
-
right preclow prechigh right left nonassoc token
|
7
|
-
nonassoc preclow prechigh right left nonassoc token
|
8
|
-
prechigh
|
9
|
-
|
10
|
-
convert
|
11
|
-
left 'a'
|
12
|
-
right 'b'
|
13
|
-
preclow 'c'
|
14
|
-
nonassoc 'd'
|
15
|
-
preclow 'e'
|
16
|
-
prechigh 'f'
|
17
|
-
end
|
18
|
-
|
19
|
-
rule
|
20
|
-
|
21
|
-
left: right nonassoc preclow prechigh
|
22
|
-
|
23
|
-
right: A B C
|
24
|
-
|
25
|
-
end
|
data/test/assets/noend.y
DELETED