File: test-arg-alternation.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 (16 lines) | stat: -rw-r--r-- 349 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#! /usr/bin/perl -sw

use Parse::RecDescent;

$grammar =
q{
        main   : foo[ "ok" ]
        foo    : (token1[ $arg[0] ])(s /\|/)
        token1 : 'a'
                 {print "$arg[0]\n"}
};

$parse = new Parse::RecDescent ($grammar);

defined $parse->main('a | a')
  or die "Arguments being passed to either implicit or alternations are lost";