File: test-arg-alternation.pl

package info (click to toggle)
libparse-recdescent-perl 1.967013%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 772 kB
  • ctags: 780
  • sloc: perl: 6,796; sh: 54; makefile: 13; ansic: 9
file content (16 lines) | stat: -rw-r--r-- 350 bytes parent folder | download | duplicates (7)
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";