Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Perlito5 - rename module Perlito5::Grammar::Regex to Perlito5::Gramma…
…r::Regex6
  • Loading branch information
fglock committed Apr 16, 2014
1 parent 20a798b commit 66a686c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 32 deletions.
40 changes: 20 additions & 20 deletions perlito5.pl
Expand Up @@ -2997,9 +2997,9 @@ sub Perlito5::Grammar::opt_continue_block {
}
# use Perlito5::Grammar::Control
package main;
package Perlito5::Grammar::Regex;
package Perlito5::Grammar::Regex6;
# use Perlito5::Grammar::Precedence
sub Perlito5::Grammar::Regex::token {
sub Perlito5::Grammar::Regex6::token {
my $grammar = $_[0];
my $str = $_[1];
my $pos = $_[2];
Expand All @@ -3024,25 +3024,25 @@ sub Perlito5::Grammar::Regex::token {
0
}
}) && ('{' eq substr($str, $MATCH->{'to'}, 1) && ($MATCH->{'to'} = 1 + $MATCH->{'to'})) && (do {
my $m2 = Perlito5::Grammar::Regex->rule($str, $MATCH->{'to'});
my $m2 = Perlito5::Grammar::Regex6->rule($str, $MATCH->{'to'});
if ($m2) {
$MATCH->{'to'} = $m2->{'to'};
$MATCH->{'Perlito5::Grammar::Regex.rule'} = $m2;
$MATCH->{'Perlito5::Grammar::Regex6.rule'} = $m2;
1
}
else {
0
}
}) && ('}' eq substr($str, $MATCH->{'to'}, 1) && ($MATCH->{'to'} = 1 + $MATCH->{'to'})) && (do {
$MATCH->{'str'} = $str;
my $source = Perlito5::Match::flat($MATCH->{'Perlito5::Grammar.ident'}) . '{ ' . 'my $grammar = $_[0]; ' . 'my $str = $_[1]; ' . 'my $pos = $_[2]; ' . 'my $MATCH = { str => $str, from => $pos, to => $pos }; ' . 'my $tmp = ( ' . Perlito5::Match::flat($MATCH->{'Perlito5::Grammar::Regex.rule'})->emit_perl5() . '); ' . '$tmp ? $MATCH : 0; ' . '}';
my $source = Perlito5::Match::flat($MATCH->{'Perlito5::Grammar.ident'}) . '{ ' . 'my $grammar = $_[0]; ' . 'my $str = $_[1]; ' . 'my $pos = $_[2]; ' . 'my $MATCH = { str => $str, from => $pos, to => $pos }; ' . 'my $tmp = ( ' . Perlito5::Match::flat($MATCH->{'Perlito5::Grammar::Regex6.rule'})->emit_perl5() . '); ' . '$tmp ? $MATCH : 0; ' . '}';
my $ast = Perlito5::Grammar::Block->named_sub_def($source, 0);
$MATCH->{'capture'} = Perlito5::Match::flat($ast);
1
})));
$tmp ? $MATCH : 0
}
sub Perlito5::Grammar::Regex::term_token {
sub Perlito5::Grammar::Regex6::term_token {
my $grammar = $_[0];
my $str = $_[1];
my $pos = $_[2];
Expand Down Expand Up @@ -3074,17 +3074,17 @@ sub Perlito5::Grammar::Regex::term_token {
$tmp ? $MATCH : 0
}
Perlito5::Grammar::Precedence::add_term('token', sub {
Perlito5::Grammar::Regex->term_token($_[0], $_[1])
Perlito5::Grammar::Regex6->term_token($_[0], $_[1])
});
sub Perlito5::Grammar::Regex::any {
sub Perlito5::Grammar::Regex6::any {
my $grammar = $_[0];
my $str = $_[1];
my $pos = $_[2];
my $MATCH = {'str' => $str, 'from' => $pos, 'to' => $pos};
my $tmp = (('' ne substr($str, $MATCH->{'to'}, 1) && ($MATCH->{'to'} = 1 + $MATCH->{'to'})));
$tmp ? $MATCH : 0
}
sub Perlito5::Grammar::Regex::literal {
sub Perlito5::Grammar::Regex6::literal {
my $grammar = $_[0];
my $str = $_[1];
my $pos = $_[2];
Expand Down Expand Up @@ -3122,7 +3122,7 @@ sub Perlito5::Grammar::Regex::literal {
}));
$tmp ? $MATCH : 0
}
sub Perlito5::Grammar::Regex::metasyntax_exp {
sub Perlito5::Grammar::Regex6::metasyntax_exp {
my $grammar = $_[0];
my $str = $_[1];
my $pos = $_[2];
Expand Down Expand Up @@ -3198,7 +3198,7 @@ sub Perlito5::Grammar::Regex::metasyntax_exp {
}));
$tmp ? $MATCH : 0
}
sub Perlito5::Grammar::Regex::string_code {
sub Perlito5::Grammar::Regex6::string_code {
my $grammar = $_[0];
my $str = $_[1];
my $pos = $_[2];
Expand Down Expand Up @@ -3262,7 +3262,7 @@ sub Perlito5::Grammar::Regex::string_code {
}));
$tmp ? $MATCH : 0
}
sub Perlito5::Grammar::Regex::parsed_code {
sub Perlito5::Grammar::Regex6::parsed_code {
my $grammar = $_[0];
my $str = $_[1];
my $pos = $_[2];
Expand All @@ -3283,7 +3283,7 @@ sub Perlito5::Grammar::Regex::parsed_code {
})));
$tmp ? $MATCH : 0
}
sub Perlito5::Grammar::Regex::rule_term {
sub Perlito5::Grammar::Regex6::rule_term {
my $grammar = $_[0];
my $str = $_[1];
my $pos = $_[2];
Expand Down Expand Up @@ -3498,7 +3498,7 @@ sub Perlito5::Grammar::Regex::rule_term {
}));
$tmp ? $MATCH : 0
}
sub Perlito5::Grammar::Regex::quant_exp {
sub Perlito5::Grammar::Regex6::quant_exp {
my $grammar = $_[0];
my $str = $_[1];
my $pos = $_[2];
Expand All @@ -3517,7 +3517,7 @@ sub Perlito5::Grammar::Regex::quant_exp {
}));
$tmp ? $MATCH : 0
}
sub Perlito5::Grammar::Regex::quantifier {
sub Perlito5::Grammar::Regex6::quantifier {
my $grammar = $_[0];
my $str = $_[1];
my $pos = $_[2];
Expand Down Expand Up @@ -3591,7 +3591,7 @@ sub Perlito5::Grammar::Regex::quantifier {
})));
$tmp ? $MATCH : 0
}
sub Perlito5::Grammar::Regex::concat_list {
sub Perlito5::Grammar::Regex6::concat_list {
my $grammar = $_[0];
my $str = $_[1];
my $pos = $_[2];
Expand Down Expand Up @@ -3647,7 +3647,7 @@ sub Perlito5::Grammar::Regex::concat_list {
}));
$tmp ? $MATCH : 0
}
sub Perlito5::Grammar::Regex::concat_exp {
sub Perlito5::Grammar::Regex6::concat_exp {
my $grammar = $_[0];
my $str = $_[1];
my $pos = $_[2];
Expand All @@ -3669,7 +3669,7 @@ sub Perlito5::Grammar::Regex::concat_exp {
})));
$tmp ? $MATCH : 0
}
sub Perlito5::Grammar::Regex::or_list_exp {
sub Perlito5::Grammar::Regex6::or_list_exp {
my $grammar = $_[0];
my $str = $_[1];
my $pos = $_[2];
Expand Down Expand Up @@ -3725,7 +3725,7 @@ sub Perlito5::Grammar::Regex::or_list_exp {
}));
$tmp ? $MATCH : 0
}
sub Perlito5::Grammar::Regex::rule {
sub Perlito5::Grammar::Regex6::rule {
my $grammar = $_[0];
my $str = $_[1];
my $pos = $_[2];
Expand Down Expand Up @@ -3770,7 +3770,7 @@ sub Perlito5::Grammar::Regex::rule {
})));
$tmp ? $MATCH : 0
}
# use Perlito5::Grammar::Regex
# use Perlito5::Grammar::Regex6
# use Perlito5::Grammar::Precedence
package main;
undef();
Expand Down
2 changes: 1 addition & 1 deletion src5/lib/Perlito5/Emitter/Token.pm
Expand Up @@ -336,7 +336,7 @@ Perlito5::Emitter::Token - Code generator for Perlito Perl 5 grammar
=head1 DESCRIPTION
This module generates Perl 5 code for the Regex compiler.
This module generates Perl 5 code for the Regex6 compiler.
=head1 AUTHORS
Expand Down
2 changes: 1 addition & 1 deletion src5/lib/Perlito5/Grammar/Precedence.pm
Expand Up @@ -362,7 +362,7 @@ sub precedence_parse {
# the parsing process is based on Perl 6:
# "Perl 6 "sandwiches" an operator-precedence parser in between two Recursive descent parsers"
#
# see the "token" implementation for the recursive descent parser (Perlito5::Grammar::Regex)
# see the "token" implementation for the recursive descent parser (Perlito5::Grammar::Regex6)
#
# http://en.wikipedia.org/wiki/Operator-precedence_parser
# http://en.wikipedia.org/wiki/Shunting-yard_algorithm
Expand Down
@@ -1,4 +1,4 @@
package Perlito5::Grammar::Regex;
package Perlito5::Grammar::Regex6;

use Perlito5::Grammar::Precedence;

Expand All @@ -20,18 +20,18 @@ use Perlito5::Grammar::Precedence;

token token {
<Perlito5::Grammar.ident> <.Perlito5::Grammar::Space.opt_ws> \{
<Perlito5::Grammar::Regex.rule>
<Perlito5::Grammar::Regex6.rule>
\}
{
#say 'Token was compiled into: ', Perlito5::Match::flat(($MATCH->{"Perlito5::Grammar::Regex.rule"}))->perl;
#say 'Token was compiled into: ', Perlito5::Match::flat(($MATCH->{"Perlito5::Grammar::Regex6.rule"}))->perl;
my $source = Perlito5::Match::flat($MATCH->{"Perlito5::Grammar.ident"})
. '{ ' .
'my $grammar = $_[0]; ' .
'my $str = $_[1]; ' .
'my $pos = $_[2]; ' .
'my $MATCH = { str => $str, from => $pos, to => $pos }; ' .
'my $tmp = ( ' .
Perlito5::Match::flat($MATCH->{"Perlito5::Grammar::Regex.rule"})->emit_perl5() .
Perlito5::Match::flat($MATCH->{"Perlito5::Grammar::Regex6.rule"})->emit_perl5() .
'); ' .
'$tmp ? $MATCH : 0; '
. '}';
Expand All @@ -47,7 +47,7 @@ token term_token {
{ $MATCH->{capture} = [ 'term', Perlito5::Match::flat($MATCH->{token}) ] }
};

Perlito5::Grammar::Precedence::add_term( 'token', sub { Perlito5::Grammar::Regex->term_token($_[0], $_[1]) } );
Perlito5::Grammar::Precedence::add_term( 'token', sub { Perlito5::Grammar::Regex6->term_token($_[0], $_[1]) } );


# this is the "grammar grammar"
Expand Down Expand Up @@ -189,16 +189,16 @@ token rule {
=head1 NAME
Perlito5::Grammar::Regex - Grammar for Perlito Grammar
Perlito5::Grammar::Regex6 - Grammar for Perlito Grammar
=head1 SYNOPSIS
my $match = Perlito5::Grammar::Regex->rule( $source, $pos );
Perlito5::Match::flat($match); # generated Regex AST
my $match = Perlito5::Grammar::Regex6->rule( $source, $pos );
Perlito5::Match::flat($match); # generated Regex6 AST
=head1 DESCRIPTION
This module generates a syntax tree for the Regex compiler.
This module generates a syntax tree for the Regex6 compiler.
This is not useful during runtime, and this module should never be loaded in the compiled programs.
Expand Down
2 changes: 1 addition & 1 deletion src5/util/perlito5.pl
Expand Up @@ -5,7 +5,7 @@ package Perlito5;
use Perlito5::Emitter::Token;
use Perlito5::Grammar::Expression;
use Perlito5::Grammar::Control;
use Perlito5::Grammar::Regex;
use Perlito5::Grammar::Regex6;
use Perlito5::Grammar::Precedence;
use Perlito5::Grammar;
use Perlito5::Macro;
Expand Down

0 comments on commit 66a686c

Please sign in to comment.