File: demo_quicklist.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 (70 lines) | stat: -rwxr-xr-x 1,546 bytes parent folder | download | duplicates (6)
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
#! /usr/local/bin/perl -w

use Parse::RecDescent;

#$RD_TRACE=1;
#$RD_HINT=1;

my $parser = Parse::RecDescent->new(<<'EOG') or die;

	list1N_c:	term(s /,/)
	list1N_s:	term(s /\/+/)

	list0N_c:	term(s? /,/)
	list0N_s:	term(s? /\/+/)

	list01_c:	term(? /,/)
	list01_s:	term(? /\/+/)

	list2_c:	term(2 /,/)
	list2_s:	term(2 /\/+/)

	list02_c:	term(0..2 /,/)
	list02_s:	term(0..2 /\/+/)

	list2N_c:	term(2.. /,/)
	list2N_s:	term(2.. /\/+/)

	list13_c:	term(..3 /,/)
	list13_s:	term(..3 /\/+/)

	term: 't'
EOG

while (<DATA>)
{
	print;
	print "\tlist1N_c:\t", @{$parser->list1N_c($_)||['undef']}, "\n";
	print "\tlist1N_s:\t", @{$parser->list1N_s($_)||['undef']}, "\n";

	print "\tlist0N_c:\t", @{$parser->list0N_c($_)||['undef']}, "\n";
	print "\tlist0N_s:\t", @{$parser->list0N_s($_)||['undef']}, "\n";

	print "\tlist01_c:\t", @{$parser->list01_c($_)||['undef']}, "\n";
	print "\tlist01_s:\t", @{$parser->list01_s($_)||['undef']}, "\n";

	print "\tlist2_c:\t", @{$parser->list2_c($_)||['undef']}, "\n";
	print "\tlist2_s:\t", @{$parser->list2_s($_)||['undef']}, "\n";

	print "\tlist02_c:\t", @{$parser->list02_c($_)||['undef']}, "\n";
	print "\tlist02_s:\t", @{$parser->list02_s($_)||['undef']}, "\n";

	print "\tlist2N_c:\t", @{$parser->list2N_c($_)||['undef']}, "\n";
	print "\tlist2N_s:\t", @{$parser->list2N_s($_)||['undef']}, "\n";

	print "\tlist13_c:\t", @{$parser->list13_c($_)||['undef']}, "\n";
	print "\tlist13_s:\t", @{$parser->list13_s($_)||['undef']}, "\n";

	print "-----\n";
}

__DATA__

t
t,t
t,t,t
t,t,t,t
t
t/t
t/t//t
t/t///t/t