File: demo_opreps.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 (48 lines) | stat: -rwxr-xr-x 1,037 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
#! /usr/local/bin/perl -w

use Parse::RecDescent;

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

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

	list1N:	<rightop: term ',' term>(s)

	list12:	<rightop: term ',' term>(..2)

	list2N:	<rightop: term ',' term>(2..)

	list01:	<rightop: term ',' term>(?)

	list:	<rightop: term ',' term>

	list0N:	<rightop: term ',' term>(s?)

	list23:	<rightop: term ',' term>(2..3)

	list03:	<rightop: term ',' term>(0..3)

	term: 't'
EOG

while (<DATA>)
{
	print;
	print "\tlist:\t",   @{$parser->list($_)||['undef']}, "\n";
	print "\tlist01:\t", @{$parser->list01($_)||['undef']}, "\n";
	print "\tlist0N:\t", @{$parser->list0N($_)||['undef']}, "\n";
	print "\tlist1N:\t", @{$parser->list1N($_)||['undef']}, "\n";
	print "\tlist2N:\t", @{$parser->list2N($_)||['undef']}, "\n";
	print "\tlist23:\t", @{$parser->list23($_)||['undef']}, "\n";
	print "\tlist12:\t", @{$parser->list12($_)||['undef']}, "\n";
	print "\tlist03:\t", @{$parser->list03($_)||['undef']}, "\n";
	print "-----\n";
}

__DATA__

t
t,t
t,t,t
t,t,t,t