File: demo_bad.pl

package info (click to toggle)
libparse-recdescent-perl 1.967015%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 764 kB
  • sloc: perl: 6,797; makefile: 13; ansic: 9
file content (49 lines) | stat: -rwxr-xr-x 816 bytes parent folder | download | duplicates (5)
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
use v5.10;
use warnings;


# SHOWCASE VARIOUS ERROR MESSAGES WITH A VERY UNWELL GRAMMAR

use Parse::RecDescent;

open (Parse::RecDescent::ERROR, ">-") or die;

$grammar =
q{
    <warn:3>

	typedef : a ... ...! ... b
	typedef : a ...!...!...!...! b
		| /type/ ident /has/ field(s) /end type/
			{ $result = $item[2]; }
		| /type/ ident /is/ ident
			{ $result = $item[2]; }
		| quasit(s)
		| quasit(-1..3)
		| quasit(..0)
		| field(?) field end
		| <error> quasit "here" ...!/why/

	Extend: extend

	Replace: replace
		$%^@#

	field   : /field/ ident /is/ ident
		| field quasit
		| !quasit(s?)
		!| #NOTHING


	typedef : whatever

	package somewhereelse

	!ident   : /[A-Za-z]\w*???/
			{ $result = $item[1]; }

	quasit  : field
		| typedef
 };

new Parse::RecDescent ($grammar) || die "Bad grammar! No biscuit!\n";