-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInfix.pm
508 lines (472 loc) · 8.58 KB
/
Infix.pm
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
########################################################################################
#
# This file was generated using Parse::Eyapp version 1.182.
#
# (c) Parse::Yapp Copyright 1998-2001 Francois Desarmenien.
# (c) Parse::Eyapp Copyright 2006-2008 Casiano Rodriguez-Leon. Universidad de La Laguna.
# Don't edit this file, use source file 'Infix.eyp' instead.
#
# ANY CHANGE MADE HERE WILL BE LOST !
#
########################################################################################
package Infix;
use strict;
push @Infix::ISA, 'Parse::Eyapp::Driver';
BEGIN {
# This strange way to load the modules is to guarantee compatibility when
# using several standalone and non-standalone Eyapp parsers
require Parse::Eyapp::Driver unless Parse::Eyapp::Driver->can('YYParse');
require Parse::Eyapp::Node unless Parse::Eyapp::Node->can('hnew');
}
sub unexpendedInput { defined($_) ? substr($_, (defined(pos $_) ? pos $_ : 0)) : '' }
# Default lexical analyzer
our $LEX = sub {
my $self = shift;
my $pos;
for (${$self->input}) {
m{\G(\s+)}gc and $self->tokenline($1 =~ tr{\n}{});
m{\G(\)|\+|\-|\;|\(|\/|\*|\=)}gc and return ($1, $1);
/\G([0-9]+(?:\.[0-9]+)?)/gc and return ('NUM', $1);
/\Gprint\b/gc and return ('PRINT', $1);
/\G([A-Za-z_][A-Za-z0-9_]*)/gc and return ('VAR', $1);
return ('', undef) if ($_ eq '') || (defined(pos($_)) && (pos($_) >= length($_)));
/\G\s*(\S+)/;
my $near = substr($1,0,10);
return($near, $near);
# die( "Error inside the lexical analyzer near '". $near
# ."'. Line: ".$self->line()
# .". File: '".$self->YYFilename()."'. No match found.\n");
}
}
;
#line 64 ./Infix.pm
my $warnmessage =<< "EOFWARN";
Warning!: Did you changed the \@Infix::ISA variable inside the header section of the eyapp program?
EOFWARN
sub new {
my($class)=shift;
ref($class) and $class=ref($class);
warn $warnmessage unless __PACKAGE__->isa('Parse::Eyapp::Driver');
my($self)=$class->SUPER::new(
yyversion => '1.182',
yyGRAMMAR =>
[#[productionNameAndLabel => lhs, [ rhs], bypass]]
[ '_SUPERSTART' => '$start', [ 'line', '$end' ], 1 ],
[ 'EXPS' => 'PLUS-1', [ 'PLUS-1', ';', 'sts' ], 1 ],
[ 'EXPS' => 'PLUS-1', [ 'sts' ], 1 ],
[ 'line_3' => 'line', [ 'PLUS-1' ], 1 ],
[ 'PRINT' => 'sts', [ 'PRINT', 'leftvalue' ], 1 ],
[ 'sts_5' => 'sts', [ 'exp' ], 1 ],
[ 'NUM' => 'exp', [ 'NUM' ], 1 ],
[ 'VAR' => 'exp', [ 'VAR' ], 1 ],
[ 'ASSIGN' => 'exp', [ 'leftvalue', '=', 'exp' ], 1 ],
[ 'PLUS' => 'exp', [ 'exp', '+', 'exp' ], 1 ],
[ 'MINUS' => 'exp', [ 'exp', '-', 'exp' ], 1 ],
[ 'TIMES' => 'exp', [ 'exp', '*', 'exp' ], 1 ],
[ 'DIV' => 'exp', [ 'exp', '/', 'exp' ], 1 ],
[ 'NEG' => 'exp', [ '-', 'exp' ], 0 ],
[ 'exp_14' => 'exp', [ '(', 'exp', ')' ], 1 ],
[ 'VAR' => 'leftvalue', [ 'VAR' ], 1 ],
],
yyLABELS =>
{
'_SUPERSTART' => 0,
'EXPS' => 1,
'EXPS' => 2,
'line_3' => 3,
'PRINT' => 4,
'sts_5' => 5,
'NUM' => 6,
'VAR' => 7,
'ASSIGN' => 8,
'PLUS' => 9,
'MINUS' => 10,
'TIMES' => 11,
'DIV' => 12,
'NEG' => 13,
'exp_14' => 14,
'VAR' => 15,
},
yyTERMS =>
{ '' => { ISSEMANTIC => 0 },
'(' => { ISSEMANTIC => 0 },
')' => { ISSEMANTIC => 0 },
'*' => { ISSEMANTIC => 0 },
'+' => { ISSEMANTIC => 0 },
'-' => { ISSEMANTIC => 0 },
'/' => { ISSEMANTIC => 0 },
';' => { ISSEMANTIC => 0 },
'=' => { ISSEMANTIC => 0 },
NEG => { ISSEMANTIC => 1 },
NUM => { ISSEMANTIC => 1 },
PRINT => { ISSEMANTIC => 1 },
VAR => { ISSEMANTIC => 1 },
error => { ISSEMANTIC => 0 },
},
yyFILENAME => 'Infix.eyp',
yystates =>
[
{#State 0
ACTIONS => {
"(" => 9,
"-" => 7,
'NUM' => 8,
'VAR' => 3,
'PRINT' => 4
},
GOTOS => {
'leftvalue' => 10,
'line' => 5,
'sts' => 2,
'exp' => 1,
'PLUS-1' => 6
}
},
{#State 1
ACTIONS => {
"/" => 12,
"+" => 14,
"*" => 11,
"-" => 13
},
DEFAULT => -5
},
{#State 2
DEFAULT => -2
},
{#State 3
ACTIONS => {
"=" => -15
},
DEFAULT => -7
},
{#State 4
ACTIONS => {
'VAR' => 15
},
GOTOS => {
'leftvalue' => 16
}
},
{#State 5
ACTIONS => {
'' => 17
}
},
{#State 6
ACTIONS => {
";" => 18
},
DEFAULT => -3
},
{#State 7
ACTIONS => {
"-" => 7,
'NUM' => 8,
"(" => 9,
'VAR' => 3
},
GOTOS => {
'exp' => 19,
'leftvalue' => 10
}
},
{#State 8
DEFAULT => -6
},
{#State 9
ACTIONS => {
"(" => 9,
'NUM' => 8,
"-" => 7,
'VAR' => 3
},
GOTOS => {
'exp' => 20,
'leftvalue' => 10
}
},
{#State 10
ACTIONS => {
"=" => 21
}
},
{#State 11
ACTIONS => {
'VAR' => 3,
"(" => 9,
'NUM' => 8,
"-" => 7
},
GOTOS => {
'exp' => 22,
'leftvalue' => 10
}
},
{#State 12
ACTIONS => {
"-" => 7,
'NUM' => 8,
"(" => 9,
'VAR' => 3
},
GOTOS => {
'leftvalue' => 10,
'exp' => 23
}
},
{#State 13
ACTIONS => {
'NUM' => 8,
"-" => 7,
"(" => 9,
'VAR' => 3
},
GOTOS => {
'leftvalue' => 10,
'exp' => 24
}
},
{#State 14
ACTIONS => {
"(" => 9,
'NUM' => 8,
"-" => 7,
'VAR' => 3
},
GOTOS => {
'leftvalue' => 10,
'exp' => 25
}
},
{#State 15
DEFAULT => -15
},
{#State 16
DEFAULT => -4
},
{#State 17
DEFAULT => 0
},
{#State 18
ACTIONS => {
'VAR' => 3,
'PRINT' => 4,
"-" => 7,
'NUM' => 8,
"(" => 9
},
GOTOS => {
'exp' => 1,
'sts' => 26,
'leftvalue' => 10
}
},
{#State 19
DEFAULT => -13
},
{#State 20
ACTIONS => {
"/" => 12,
")" => 27,
"*" => 11,
"+" => 14,
"-" => 13
}
},
{#State 21
ACTIONS => {
'VAR' => 3,
"(" => 9,
"-" => 7,
'NUM' => 8
},
GOTOS => {
'leftvalue' => 10,
'exp' => 28
}
},
{#State 22
DEFAULT => -11
},
{#State 23
DEFAULT => -12
},
{#State 24
ACTIONS => {
"/" => 12,
"*" => 11
},
DEFAULT => -10
},
{#State 25
ACTIONS => {
"*" => 11,
"/" => 12
},
DEFAULT => -9
},
{#State 26
DEFAULT => -1
},
{#State 27
DEFAULT => -14
},
{#State 28
ACTIONS => {
"*" => 11,
"/" => 12,
"-" => 13,
"+" => 14
},
DEFAULT => -8
}
],
yyrules =>
[
[#Rule _SUPERSTART
'$start', 2, undef
#line 354 ./Infix.pm
],
[#Rule EXPS
'PLUS-1', 3,
sub {
#line 16 "Infix.eyp"
goto &Parse::Eyapp::Driver::YYActionforT_TX1X2 }
#line 361 ./Infix.pm
],
[#Rule EXPS
'PLUS-1', 1,
sub {
#line 16 "Infix.eyp"
goto &Parse::Eyapp::Driver::YYActionforT_single }
#line 368 ./Infix.pm
],
[#Rule line_3
'line', 1,
sub {
#line 12 "Infix.eyp"
goto &Parse::Eyapp::Driver::YYBuildAST }
#line 375 ./Infix.pm
],
[#Rule PRINT
'sts', 2,
sub {
#line 12 "Infix.eyp"
goto &Parse::Eyapp::Driver::YYBuildAST }
#line 382 ./Infix.pm
],
[#Rule sts_5
'sts', 1,
sub {
#line 12 "Infix.eyp"
goto &Parse::Eyapp::Driver::YYBuildAST }
#line 389 ./Infix.pm
],
[#Rule NUM
'exp', 1,
sub {
#line 12 "Infix.eyp"
goto &Parse::Eyapp::Driver::YYBuildAST }
#line 396 ./Infix.pm
],
[#Rule VAR
'exp', 1,
sub {
#line 12 "Infix.eyp"
goto &Parse::Eyapp::Driver::YYBuildAST }
#line 403 ./Infix.pm
],
[#Rule ASSIGN
'exp', 3,
sub {
#line 12 "Infix.eyp"
goto &Parse::Eyapp::Driver::YYBuildAST }
#line 410 ./Infix.pm
],
[#Rule PLUS
'exp', 3,
sub {
#line 12 "Infix.eyp"
goto &Parse::Eyapp::Driver::YYBuildAST }
#line 417 ./Infix.pm
],
[#Rule MINUS
'exp', 3,
sub {
#line 12 "Infix.eyp"
goto &Parse::Eyapp::Driver::YYBuildAST }
#line 424 ./Infix.pm
],
[#Rule TIMES
'exp', 3,
sub {
#line 12 "Infix.eyp"
goto &Parse::Eyapp::Driver::YYBuildAST }
#line 431 ./Infix.pm
],
[#Rule DIV
'exp', 3,
sub {
#line 12 "Infix.eyp"
goto &Parse::Eyapp::Driver::YYBuildAST }
#line 438 ./Infix.pm
],
[#Rule NEG
'exp', 2,
sub {
#line 12 "Infix.eyp"
goto &Parse::Eyapp::Driver::YYBuildAST }
#line 445 ./Infix.pm
],
[#Rule exp_14
'exp', 3,
sub {
#line 12 "Infix.eyp"
goto &Parse::Eyapp::Driver::YYBuildAST }
#line 452 ./Infix.pm
],
[#Rule VAR
'leftvalue', 1,
sub {
#line 12 "Infix.eyp"
goto &Parse::Eyapp::Driver::YYBuildAST }
#line 459 ./Infix.pm
]
],
#line 462 ./Infix.pm
yybypass => 1,
yybuildingtree => 1,
yyprefix => '',
yyaccessors => {
},
yyconflicthandlers => {}
,
yystateconflict => { },
@_,
);
bless($self,$class);
$self->make_node_classes('TERMINAL', '_OPTIONAL', '_STAR_LIST', '_PLUS_LIST',
'_SUPERSTART',
'EXPS',
'EXPS',
'line_3',
'PRINT',
'sts_5',
'NUM',
'VAR',
'ASSIGN',
'PLUS',
'MINUS',
'TIMES',
'DIV',
'NEG',
'exp_14',
'VAR', );
$self;
}
#line 48 "Infix.eyp"
=for None
=cut
#line 504 ./Infix.pm
1;