File: synopsis.pl

package info (click to toggle)
libparser-mgc-perl 0.16-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 368 kB
  • sloc: perl: 1,676; makefile: 6; sh: 4
file content (31 lines) | stat: -rw-r--r-- 528 bytes parent folder | download | duplicates (4)
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
use strict;
use warnings;

package LispParser;
use base qw( Parser::MGC );

use constant pattern_ident => qr{[[:alnum:]+*/._:-]+};

sub parse
{
   my $self = shift;

   $self->sequence_of( sub {
      $self->any_of(
         sub { $self->token_int },
         sub { $self->token_string },
         sub { \$self->token_ident },
         sub { $self->scope_of( "(", \&parse, ")" ) }
      );
   } );
}

use Data::Dumper;

if( !caller ) {
   my $parser = __PACKAGE__->new;

   print Dumper( $parser->from_file( $ARGV[0] ) );
}

1;