File: reproducibility.t

package info (click to toggle)
libparse-yapp-perl 1.21-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 492 kB
  • sloc: perl: 2,751; makefile: 2
file content (412 lines) | stat: -rw-r--r-- 5,882 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl

use strict;
use warnings;
use Parse::Yapp;
use Text::Diff;

BEGIN { $| = 1; print "1..1\n"; }

open( my $inp, 'Calc.yp' );
my $grammar = join '', <$inp>;
close $inp;

my $parser = new Parse::Yapp( input => $grammar );

my $output_new = $parser->Output( classname => 'Calc' );
$output_new =~ s/(Parse::Yapp version )\d+\.\d+/$1<version>/;
$output_new =~ s/(yyversion => ')[^']+'/$1<version>'/;

my $output_old = join '', <DATA>;
close DATA;

my $diff = diff \$output_old, \$output_new;
if( $diff ) {
    print "not ok 1\n";
    print "Non-zero diff:\n" . $diff;
    exit(1);
} else {
    print "ok 1\n";
}

__DATA__
####################################################################
#
#    This file was generated using Parse::Yapp version <version>.
#
#        Don't edit this file, use source file instead.
#
#             ANY CHANGE MADE HERE WILL BE LOST !
#
####################################################################
package Calc;
use vars qw ( @ISA );
use strict;

@ISA= qw ( Parse::Yapp::Driver );
use Parse::Yapp::Driver;



sub new {
        my($class)=shift;
        ref($class)
    and $class=ref($class);

    my($self)=$class->SUPER::new( yyversion => '<version>',
                                  yystates =>
[
	{#State 0
		DEFAULT => -1,
		GOTOS => {
			'input' => 1
		}
	},
	{#State 1
		ACTIONS => {
			'' => 2,
			"(" => 3,
			"-" => 4,
			"\n" => 5,
			'NUM' => 6,
			'VAR' => 7,
			'error' => 8
		},
		GOTOS => {
			'exp' => 9,
			'line' => 10
		}
	},
	{#State 2
		DEFAULT => 0
	},
	{#State 3
		ACTIONS => {
			"(" => 3,
			"-" => 4,
			'NUM' => 6,
			'VAR' => 7
		},
		GOTOS => {
			'exp' => 11
		}
	},
	{#State 4
		ACTIONS => {
			"(" => 3,
			"-" => 4,
			'NUM' => 6,
			'VAR' => 7
		},
		GOTOS => {
			'exp' => 12
		}
	},
	{#State 5
		DEFAULT => -3
	},
	{#State 6
		DEFAULT => -6
	},
	{#State 7
		ACTIONS => {
			"=" => 13
		},
		DEFAULT => -7
	},
	{#State 8
		ACTIONS => {
			"\n" => 14
		}
	},
	{#State 9
		ACTIONS => {
			"*" => 15,
			"+" => 16,
			"-" => 17,
			"/" => 18,
			"\n" => 19,
			"^" => 20
		}
	},
	{#State 10
		DEFAULT => -2
	},
	{#State 11
		ACTIONS => {
			")" => 21,
			"*" => 15,
			"+" => 16,
			"-" => 17,
			"/" => 18,
			"^" => 20
		}
	},
	{#State 12
		ACTIONS => {
			"^" => 20
		},
		DEFAULT => -13
	},
	{#State 13
		ACTIONS => {
			"(" => 3,
			"-" => 4,
			'NUM' => 6,
			'VAR' => 7
		},
		GOTOS => {
			'exp' => 22
		}
	},
	{#State 14
		DEFAULT => -5
	},
	{#State 15
		ACTIONS => {
			"(" => 3,
			"-" => 4,
			'NUM' => 6,
			'VAR' => 7
		},
		GOTOS => {
			'exp' => 23
		}
	},
	{#State 16
		ACTIONS => {
			"(" => 3,
			"-" => 4,
			'NUM' => 6,
			'VAR' => 7
		},
		GOTOS => {
			'exp' => 24
		}
	},
	{#State 17
		ACTIONS => {
			"(" => 3,
			"-" => 4,
			'NUM' => 6,
			'VAR' => 7
		},
		GOTOS => {
			'exp' => 25
		}
	},
	{#State 18
		ACTIONS => {
			"(" => 3,
			"-" => 4,
			'NUM' => 6,
			'VAR' => 7
		},
		GOTOS => {
			'exp' => 26
		}
	},
	{#State 19
		DEFAULT => -4
	},
	{#State 20
		ACTIONS => {
			"(" => 3,
			"-" => 4,
			'NUM' => 6,
			'VAR' => 7
		},
		GOTOS => {
			'exp' => 27
		}
	},
	{#State 21
		DEFAULT => -15
	},
	{#State 22
		ACTIONS => {
			"*" => 15,
			"+" => 16,
			"-" => 17,
			"/" => 18,
			"^" => 20
		},
		DEFAULT => -8
	},
	{#State 23
		ACTIONS => {
			"^" => 20
		},
		DEFAULT => -11
	},
	{#State 24
		ACTIONS => {
			"*" => 15,
			"/" => 18,
			"^" => 20
		},
		DEFAULT => -9
	},
	{#State 25
		ACTIONS => {
			"*" => 15,
			"/" => 18,
			"^" => 20
		},
		DEFAULT => -10
	},
	{#State 26
		ACTIONS => {
			"^" => 20
		},
		DEFAULT => -12
	},
	{#State 27
		ACTIONS => {
			"^" => 20
		},
		DEFAULT => -14
	}
],
                                  yyrules  =>
[
	[#Rule 0
		 '$start', 2, undef
	],
	[#Rule 1
		 'input', 0, undef
	],
	[#Rule 2
		 'input', 2,
sub
#line 17 "unkown"
{ push(@{$_[1]},$_[2]); $_[1] }
	],
	[#Rule 3
		 'line', 1,
sub
#line 20 "unkown"
{ $_[1] }
	],
	[#Rule 4
		 'line', 2,
sub
#line 21 "unkown"
{ print "$_[1]\n" }
	],
	[#Rule 5
		 'line', 2,
sub
#line 22 "unkown"
{ $_[0]->YYErrok }
	],
	[#Rule 6
		 'exp', 1, undef
	],
	[#Rule 7
		 'exp', 1,
sub
#line 26 "unkown"
{ $_[0]->YYData->{VARS}{$_[1]} }
	],
	[#Rule 8
		 'exp', 3,
sub
#line 27 "unkown"
{ $_[0]->YYData->{VARS}{$_[1]}=$_[3] }
	],
	[#Rule 9
		 'exp', 3,
sub
#line 28 "unkown"
{ $_[1] + $_[3] }
	],
	[#Rule 10
		 'exp', 3,
sub
#line 29 "unkown"
{ $_[1] - $_[3] }
	],
	[#Rule 11
		 'exp', 3,
sub
#line 30 "unkown"
{ $_[1] * $_[3] }
	],
	[#Rule 12
		 'exp', 3,
sub
#line 31 "unkown"
{
                                      $_[3]
                                  and return($_[1] / $_[3]);
                                  $_[0]->YYData->{ERRMSG}
                                    =   "Illegal division by zero.\n";
                                  $_[0]->YYError;
                                  undef
                                }
	],
	[#Rule 13
		 'exp', 2,
sub
#line 39 "unkown"
{ -$_[2] }
	],
	[#Rule 14
		 'exp', 3,
sub
#line 40 "unkown"
{ $_[1] ** $_[3] }
	],
	[#Rule 15
		 'exp', 3,
sub
#line 41 "unkown"
{ $_[2] }
	]
],
                                  @_);
    bless($self,$class);
}

#line 44 "unkown"


sub _Error {
        exists $_[0]->YYData->{ERRMSG}
    and do {
        print $_[0]->YYData->{ERRMSG};
        delete $_[0]->YYData->{ERRMSG};
        return;
    };
    print "Syntax error.\n";
}

sub _Lexer {
    my($parser)=shift;

        $parser->YYData->{INPUT}
    or  $parser->YYData->{INPUT} = <STDIN>
    or  return('',undef);

    $parser->YYData->{INPUT}=~s/^[ \t]//;

    for ($parser->YYData->{INPUT}) {
        s/^([0-9]+(?:\.[0-9]+)?)//
                and return('NUM',$1);
        s/^([A-Za-z][A-Za-z0-9_]*)//
                and return('VAR',$1);
        s/^(.)//s
                and return($1,$1);
    }
}

sub Run {
    my($self)=shift;
    $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
}

my($calc)=new Calc;
$calc->Run;

1;