Permalink
Browse files

Perlito5 - grammar - more all parser modules to Grammar/

  • Loading branch information...
fglock committed Aug 13, 2013
1 parent 8a1ddc6 commit 325512627294cb622a5518161803a82e635581da
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -1,6 +1,6 @@
package Perlito5::Grammar;
-use Perlito5::Expression;
+use Perlito5::Grammar::Expression;
use Perlito5::Grammar::Control;
use Perlito5::Grammar::String;
use Perlito5::Grammar::Sigil;
@@ -89,13 +89,13 @@ token optional_namespace_before_ident {
token exp_stmts2 { <exp_stmts> { $MATCH->{capture} = Perlito5::Match::flat($MATCH->{exp_stmts}) } };
token exp {
- <Perlito5::Expression.exp_parse>
- { $MATCH->{capture} = Perlito5::Match::flat($MATCH->{"Perlito5::Expression.exp_parse"}) }
+ <Perlito5::Grammar::Expression.exp_parse>
+ { $MATCH->{capture} = Perlito5::Match::flat($MATCH->{"Perlito5::Grammar::Expression.exp_parse"}) }
};
token exp2 {
- <Perlito5::Expression.exp_parse>
- { $MATCH->{capture} = Perlito5::Match::flat($MATCH->{"Perlito5::Expression.exp_parse"}) }
+ <Perlito5::Grammar::Expression.exp_parse>
+ { $MATCH->{capture} = Perlito5::Match::flat($MATCH->{"Perlito5::Grammar::Expression.exp_parse"}) }
};
token opt_type {
@@ -172,7 +172,7 @@ sub exp_stmts {
$pos = $m->{to};
}
else {
- $m = Perlito5::Expression->statement_parse($str, $pos);
+ $m = Perlito5::Grammar::Expression->statement_parse($str, $pos);
if ($m) {
push @stmts, $m->{capture};
$pos = $m->{to};
@@ -9,9 +9,9 @@ token the_object {
$MATCH->{capture} = Perlito5::Match::flat($MATCH->{'Perlito5::Grammar::Sigil.term_sigil'})->[1];
}
|
- '{' <Perlito5::Expression.curly_parse> '}'
+ '{' <Perlito5::Grammar::Expression.curly_parse> '}'
{
- $MATCH->{capture} = Perlito5::Match::flat($MATCH->{'Perlito5::Expression.curly_parse'});
+ $MATCH->{capture} = Perlito5::Match::flat($MATCH->{'Perlito5::Grammar::Expression.curly_parse'});
}
|
<Perlito5::Grammar::Print.typeglob>
@@ -132,17 +132,17 @@ token the_object {
if ( substr($str, $p, 2) eq '->' ) {
}
elsif ( substr($str, $p, 1) eq '(' ) {
- my $m = Perlito5::Expression->term_paren( $str, $p );
+ my $m = Perlito5::Grammar::Expression->term_paren( $str, $p );
if ( $m ) {
$arg = $m->{capture}[2];
$p = $m->{to};
- $arg = Perlito5::Expression::expand_list( $arg );
+ $arg = Perlito5::Grammar::Expression::expand_list( $arg );
}
}
else {
- my $m = Perlito5::Expression->list_parse( $str, $p );
+ my $m = Perlito5::Grammar::Expression->list_parse( $str, $p );
if ($m->{capture} ne '*undef*') {
- $arg = Perlito5::Expression::expand_list( $m->{capture} );
+ $arg = Perlito5::Grammar::Expression::expand_list( $m->{capture} );
$p = $m->{to};
}
}
@@ -312,19 +312,19 @@ token the_object {
my $m;
my $arg;
if ( substr($str, $p, 1) eq '(' ) {
- $m = Perlito5::Expression->term_paren( $str, $p );
+ $m = Perlito5::Grammar::Expression->term_paren( $str, $p );
if ( !$m ) { return $m };
$p = $m->{to};
$has_paren = 1;
$arg = $m->{capture}[2];
- $arg = Perlito5::Expression::expand_list( $arg );
+ $arg = Perlito5::Grammar::Expression::expand_list( $arg );
my $v = shift @{ $arg };
die "Too many arguments for $name"
if @{ $arg };
$arg = $v;
}
else {
- $m = Perlito5::Expression->argument_parse( $str, $p );
+ $m = Perlito5::Grammar::Expression->argument_parse( $str, $p );
$arg = $m->{capture};
if ( $arg eq '*undef*' ) {
$arg = undef;
@@ -382,10 +382,10 @@ token the_object {
# maybe it's a subroutine call
if ( substr($str, $p, 1) eq '(' ) {
- $m = Perlito5::Expression->term_paren( $str, $p );
+ $m = Perlito5::Grammar::Expression->term_paren( $str, $p );
if ( !$m ) { return $m };
my $arg = $m->{capture}[2];
- $arg = Perlito5::Expression::expand_list( $arg );
+ $arg = Perlito5::Grammar::Expression::expand_list( $arg );
$m->{capture} = [ 'term',
Perlito5::AST::Apply->new(
code => $name,
@@ -397,7 +397,7 @@ token the_object {
}
- my $m_list = Perlito5::Expression->list_parse( $str, $p );
+ my $m_list = Perlito5::Grammar::Expression->list_parse( $str, $p );
my $list = $m_list->{capture};
if ($list ne '*undef*') {
$m_name->{capture} = [ 'postfix_or_term', 'funcall',
@@ -1,7 +1,7 @@
package Perlito5::Grammar::Block;
-use Perlito5::Expression;
+use Perlito5::Grammar::Expression;
use strict;
our %Named_block = (
@@ -12,12 +12,12 @@ our %Named_block = (
END => 1,
);
-Perlito5::Precedence::add_term( 'do' => sub { Perlito5::Grammar::Block->term_do( $_[0], $_[1] ) } );
-Perlito5::Precedence::add_term( 'sub' => sub { Perlito5::Grammar::Block->term_anon_sub( $_[0], $_[1] ) } );
+Perlito5::Grammar::Precedence::add_term( 'do' => sub { Perlito5::Grammar::Block->term_do( $_[0], $_[1] ) } );
+Perlito5::Grammar::Precedence::add_term( 'sub' => sub { Perlito5::Grammar::Block->term_anon_sub( $_[0], $_[1] ) } );
-Perlito5::Expression::add_statement( '{' => sub { Perlito5::Grammar::Block->term_block($_[0], $_[1]) } );
-Perlito5::Expression::add_statement( 'sub' => sub { Perlito5::Grammar::Block->named_sub($_[0], $_[1]) } );
-Perlito5::Expression::add_statement( $_ => sub { Perlito5::Grammar::Block->term_block($_[0], $_[1]) } )
+Perlito5::Grammar::Expression::add_statement( '{' => sub { Perlito5::Grammar::Block->term_block($_[0], $_[1]) } );
+Perlito5::Grammar::Expression::add_statement( 'sub' => sub { Perlito5::Grammar::Block->named_sub($_[0], $_[1]) } );
+Perlito5::Grammar::Expression::add_statement( $_ => sub { Perlito5::Grammar::Block->term_block($_[0], $_[1]) } )
for keys %Named_block;
@@ -42,7 +42,7 @@ sub term_block {
if ( substr($str, $p, 1) eq '{' ) {
# do we recognize a bare block in this position?
# warn "maybe bareblock at $p";
- my $m = Perlito5::Expression->term_curly($str, $p);
+ my $m = Perlito5::Grammar::Expression->term_curly($str, $p);
if ($m) {
my $block_start = $p;
$p = $m->{to};
@@ -59,7 +59,7 @@ sub term_block {
if ( $ws ) {
$p = $ws->{to};
}
- my $cont = Perlito5::Expression->term_curly($str, $p);
+ my $cont = Perlito5::Grammar::Expression->term_curly($str, $p);
die "syntax error" unless $cont;
warn "continue!";
@@ -74,7 +74,7 @@ sub term_block {
# TODO - this is not recognized as a syntax error: { 123 => 4 }{2}
$v = Perlito5::AST::Lit::Block->new( stmts => $v->[2], sig => $v->[3] );
- $v = Perlito5::Expression::block_or_hash($v)
+ $v = Perlito5::Grammar::Expression::block_or_hash($v)
unless $has_continue || $block_name;
if ( ref($v) eq 'Perlito5::AST::Lit::Block' ) {
@@ -115,7 +115,7 @@ token named_sub_def {
$MATCH->{_tmp} = Perlito5::Match::flat($MATCH->{"Perlito5::Grammar.exp_stmts"});
}
|
- <.Perlito5::Expression.statement_parse>
+ <.Perlito5::Grammar::Expression.statement_parse>
{
die 'Illegal declaration of subroutine \'', Perlito5::Match::flat($MATCH->{"Perlito5::Grammar.ident"}), '\''
}
@@ -187,8 +187,8 @@ token term_anon_sub {
token term_do {
# Note: this is do-block; do-string is parsed as a normal subroutine
- 'do' <.Perlito5::Grammar::Space.ws> <before '{'> <Perlito5::Expression.statement_parse>
- { $MATCH->{capture} = [ 'term', Perlito5::AST::Do->new( block => Perlito5::Match::flat($MATCH->{'Perlito5::Expression.statement_parse'}) ) ] }
+ 'do' <.Perlito5::Grammar::Space.ws> <before '{'> <Perlito5::Grammar::Expression.statement_parse>
+ { $MATCH->{capture} = [ 'term', Perlito5::AST::Do->new( block => Perlito5::Match::flat($MATCH->{'Perlito5::Grammar::Expression.statement_parse'}) ) ] }
};
token args_sig {
Oops, something went wrong.

0 comments on commit 3255126

Please sign in to comment.