Parse-Eyapp
view release on metacpan or search on metacpan
lib/Parse/Eyapp.pod view on Meta::CPAN
19 use warnings;
20 use strict;
21 use Calc;
22 use T;
23
24 sub R::TERMINAL::info { $_[0]{attr} }
25
26 my $parser = new Calc(yyprefix => "R::");
27 # stdin, prompt , read one line at time
28 $parser->slurp_file('','Arithmetic expression: ', "\n");
29
30 my $t = $parser->YYParse;
31
32 unless ($parser->YYNberr) {
33 print "\n***** Tree before the transformations ******\n";
34 print $t->str."\n";
35
36 $t->s(@T::all);
37 print "\n***** Tree after the transformations were applied ******\n";
38 print $t->str."\n";
39 }
running the program produces the following output:
pl@nereida:~/LEyapp/examples/Eyapp$ ./foldand0rule9_4.pl
Arithmetic expression: a = 2*3
***** Tree before the transformations ******
R::ASSIGN(R::TERMINAL[a],R::TERMINAL[=],R::TIMES(R::NUM(R::TERMINAL[2]),R::TERMINAL[*],R::NUM(R::TERMINAL[3])))
***** Tree after the transformations were applied ******
R::ASSIGN(R::TERMINAL[a],R::TERMINAL[=],R::NUM(R::TERMINAL[6]))
pl@nereida:~/LEyapp/examples/Eyapp$ ./foldand0rule9_4.pl
Arithmetic expression: a = 2*[3+b]
Syntax error near '['.
Expected one of these terminals: '-' 'NUM' 'VAR' '('
=head1 L<Parse::Eyapp::Scope>: SUPPORT FOR SCOPE ANALYSIS
See the documentation for L<Parse::Eyapp::Scope>
=head1 MISCELLANEOUS SUPPORT FUNCTIONS IN L<Parse::Eyapp::Base>
See the documentation in L<Parse::Eyapp::Base>
=head1 ENVIRONMENT
Remember to set the environment variable C<PERL5LIB>
if you decide to install C<Parse::Eyapp> at a location other than the standard.
For example, on a bash or sh:
export PERL5LIB=/home/user/wherever_it_is/lib/:$PERL5LIB
on a C<csh> or C<tcsh>
setenv PERL5LIB /home/user/wherever_it_is/lib/:$PERL5LIB
Be sure the scripts C<eyapp> and C<treereg> are in the execution PATH.
=head1 DEPENDENCIES
This distribution depends on the following modules:
=over
=item * L<List::Util>
=item * L<Data::Dumper>
=item * L<Pod::Usage>
=back
It seems that L<List::Util> is in the core of Perl
distributions since version 5.73:
> perl -MModule::CoreList -e 'print Module::CoreList->first_release("List::Util")'
5.007003
and L<Data::Dumper> is also in the core since 5.5:
> perl -MModule::CoreList -e 'print Module::CoreList->first_release("Data::Dumper")'
5.005
and L<Pod::Usage> is also in the core since 5.6:
> perl -MModule::CoreList -e 'print Module::CoreList->first_release("Pod::Usage")'
5.006
=for none
> perl -MModule::CoreList -e 'print Module::CoreList->first_release("Memoize")'
5.007003
I also recommend the following modules:
=over
=item * L<Test::Pod>
=item * L<Test::Warn>
=item * L<Test::Exception>
=back
The dependence on L<Test::Warn>, L<Test::Pod> and L<Test::Exception> is merely for
the execution of tests. If the modules aren't installed the tests
depending on them will be skipped.
=head1 INSTALLATION
To install it, follow the traditional mantra:
perl Makefile.PL
make
make test
( run in 2.907 seconds using v1.01-cache-2.11-cpan-6aa56a78535 )