Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: c5cd4cde3d
Fetching contributors…

Cannot retrieve contributors at this time

358 lines (328 sloc) 15.78 kb
# Do not edit this file - Generated by Perlito6 9.0
use v5;
use utf8;
use strict;
use warnings;
no warnings ('redefine', 'once', 'void', 'uninitialized', 'misc', 'recursion');
use Perlito6::Perl5::Runtime;
use Perlito6::Perl5::Prelude;
our $MATCH = Perlito6::Match->new();
{
package GLOBAL;
sub new { shift; bless { @_ }, "GLOBAL" }
# use v6
;
{
package Rul;
sub new { shift; bless { @_ }, "Rul" }
sub constant {
my $str = $_[0];
((my $len) = Main::chars($str, ));
if (($str eq chr(92))) {
($str = chr(92) . chr(92))
};
if (($str eq chr(39))) {
($str = chr(92) . chr(39))
};
if (($len)) {
('( ' . chr(39) . $str . chr(39) . ' eq substr( ' . chr(36) . 'str, ' . chr(36) . 'MATCH.to, ' . $len . ') ' . chr(38) . chr(38) . ' ( ' . chr(36) . 'MATCH.to ' . chr(61) . ' ' . $len . ' + ' . chr(36) . 'MATCH.to )' . ')')
}
else {
return scalar ('1')
}
}
}
;
{
package Rul::Quantifier;
sub new { shift; bless { @_ }, "Rul::Quantifier" }
sub term { $_[0]->{term} };
sub quant { $_[0]->{quant} };
sub greedy { $_[0]->{greedy} };
sub ws1 { $_[0]->{ws1} };
sub ws2 { $_[0]->{ws2} };
sub ws3 { $_[0]->{ws3} };
sub emit_perl6 {
my $self = $_[0];
if (((($self->{quant} eq '')) && (($self->{greedy} eq '')))) {
return scalar ($self->{term}->emit_perl6())
};
if (((($self->{quant} eq '+')) && (($self->{greedy} eq '')))) {
$self->{term}->set_captures_to_array();
return scalar (('(do ' . chr(123) . ' ' . 'my ' . chr(36) . 'last_match_null ' . chr(61) . ' 0' . chr(59) . ' ' . 'my ' . chr(36) . 'last_pos ' . chr(61) . ' ' . chr(36) . 'MATCH.to' . chr(59) . ' ' . 'my ' . chr(36) . 'count ' . chr(61) . ' 0' . chr(59) . ' ' . 'while ' . $self->{term}->emit_perl6() . ' ' . chr(38) . chr(38) . ' (' . chr(36) . 'last_match_null < 2) ' . chr(123) . ' ' . 'if ' . chr(36) . 'last_pos ' . chr(61) . chr(61) . ' ' . chr(36) . 'MATCH.to() ' . chr(123) . ' ' . chr(36) . 'last_match_null ' . chr(61) . ' ' . chr(36) . 'last_match_null + 1' . chr(59) . ' ' . chr(125) . ' ' . 'else ' . chr(123) . ' ' . chr(36) . 'last_match_null ' . chr(61) . ' 0' . chr(59) . ' ' . chr(125) . chr(59) . ' ' . chr(36) . 'last_pos ' . chr(61) . ' ' . chr(36) . 'MATCH.to' . chr(59) . ' ' . chr(36) . 'count ' . chr(61) . ' ' . chr(36) . 'count + 1' . chr(59) . ' ' . chr(125) . chr(59) . ' ' . chr(36) . 'MATCH.to ' . chr(61) . ' ' . chr(36) . 'last_pos' . chr(59) . ' ' . chr(36) . 'count > 0' . chr(59) . ' ' . chr(125) . ')'))
};
if (((($self->{quant} eq '*')) && (($self->{greedy} eq '')))) {
$self->{term}->set_captures_to_array();
return scalar (('(do ' . chr(123) . ' ' . 'my ' . chr(36) . 'last_match_null ' . chr(61) . ' 0' . chr(59) . ' ' . 'my ' . chr(36) . 'last_pos ' . chr(61) . ' ' . chr(36) . 'MATCH.to' . chr(59) . ' ' . 'while ' . $self->{term}->emit_perl6() . ' ' . chr(38) . chr(38) . ' (' . chr(36) . 'last_match_null < 2) ' . chr(123) . ' ' . 'if ' . chr(36) . 'last_pos ' . chr(61) . chr(61) . ' ' . chr(36) . 'MATCH.to() ' . chr(123) . ' ' . chr(36) . 'last_match_null ' . chr(61) . ' ' . chr(36) . 'last_match_null + 1' . chr(59) . ' ' . chr(125) . ' ' . 'else ' . chr(123) . ' ' . chr(36) . 'last_match_null ' . chr(61) . ' 0' . chr(59) . ' ' . chr(125) . chr(59) . ' ' . chr(36) . 'last_pos ' . chr(61) . ' ' . chr(36) . 'MATCH.to' . chr(59) . ' ' . chr(125) . chr(59) . ' ' . chr(36) . 'MATCH.to ' . chr(61) . ' ' . chr(36) . 'last_pos' . chr(59) . ' ' . '1 ' . chr(125) . ')'))
};
if (((($self->{quant} eq chr(63))) && (($self->{greedy} eq '')))) {
$self->{term}->set_captures_to_array();
return scalar (('(do ' . chr(123) . ' ' . 'my ' . chr(36) . 'last_pos ' . chr(61) . ' ' . chr(36) . 'MATCH.to' . chr(59) . ' ' . 'if ' . chr(33) . '(do ' . chr(123) . $self->{term}->emit_perl6() . chr(125) . ') ' . chr(123) . ' ' . chr(36) . 'MATCH.to ' . chr(61) . ' ' . chr(36) . 'last_pos' . chr(59) . ' ' . chr(125) . chr(59) . ' ' . '1 ' . chr(125) . ')'))
};
warn(('Rul::Quantifier: ' . Main::perl($self, ) . (' not implemented')));
$self->{term}->emit_perl6()
};
sub set_captures_to_array {
my $self = $_[0];
$self->{term}->set_captures_to_array()
}
}
;
{
package Rul::Or;
sub new { shift; bless { @_ }, "Rul::Or" }
sub or_list { $_[0]->{or_list} };
sub emit_perl6 {
my $self = $_[0];
('(do ' . chr(123) . ' ' . 'my ' . chr(36) . 'pos1 ' . chr(61) . ' ' . chr(36) . 'MATCH.to' . chr(59) . ' (do ' . chr(123) . ' ' . Main::join(([ map { $_->emit_perl6() } @{( (defined $self->{or_list} ? $self->{or_list} : ($self->{or_list} ||= bless([], 'ARRAY'))) )} ]), chr(125) . ') ' . chr(124) . chr(124) . ' (do ' . chr(123) . ' ' . chr(36) . 'MATCH.to ' . chr(61) . ' ' . chr(36) . 'pos1' . chr(59) . ' ') . chr(125) . ') ' . chr(125) . ')')
};
sub set_captures_to_array {
my $self = $_[0];
[ map { $_->set_captures_to_array() } @{( (defined $self->{or_list} ? $self->{or_list} : ($self->{or_list} ||= bless([], 'ARRAY'))) )} ]
}
}
;
{
package Rul::Concat;
sub new { shift; bless { @_ }, "Rul::Concat" }
sub concat { $_[0]->{concat} };
sub emit_perl6 {
my $self = $_[0];
('(' . Main::join(([ map { $_->emit_perl6() } @{( (defined $self->{concat} ? $self->{concat} : ($self->{concat} ||= bless([], 'ARRAY'))) )} ]), ' ' . chr(38) . chr(38) . ' ') . ')')
};
sub set_captures_to_array {
my $self = $_[0];
[ map { $_->set_captures_to_array() } @{( (defined $self->{concat} ? $self->{concat} : ($self->{concat} ||= bless([], 'ARRAY'))) )} ]
}
}
;
{
package Rul::Subrule;
sub new { shift; bless { @_ }, "Rul::Subrule" }
sub metasyntax { $_[0]->{metasyntax} };
sub captures { $_[0]->{captures} };
sub emit_perl6 {
my $self = $_[0];
((my $meth) = (((1 + index($self->{metasyntax}, '.'))) ? $self->{metasyntax} : ((chr(36) . 'grammar.' . $self->{metasyntax}))));
(my $code);
if (($self->{captures} == 1)) {
($code = ('if ' . chr(36) . 'm2 ' . chr(123) . ' ' . chr(36) . 'MATCH.to ' . chr(61) . ' ' . chr(36) . 'm2.to' . chr(59) . ' ' . chr(36) . 'MATCH' . chr(123) . chr(39) . $self->{metasyntax} . chr(39) . chr(125) . ' ' . chr(61) . ' ' . chr(36) . 'm2' . chr(59) . ' 1 ' . chr(125) . ' else ' . chr(123) . ' False ' . chr(125) . chr(59) . ' '))
}
else {
if (($self->{captures} > 1)) {
($code = ('if ' . chr(36) . 'm2 ' . chr(123) . ' ' . chr(36) . 'MATCH.to ' . chr(61) . ' ' . chr(36) . 'm2.to' . chr(59) . ' ' . 'if exists ' . chr(36) . 'MATCH' . chr(123) . chr(39) . $self->{metasyntax} . chr(39) . chr(125) . ' ' . chr(123) . ' ' . '(' . chr(36) . 'MATCH' . chr(123) . chr(39) . $self->{metasyntax} . chr(39) . chr(125) . ').push( ' . chr(36) . 'm2 )' . chr(59) . ' ' . chr(125) . ' ' . 'else ' . chr(123) . ' ' . chr(36) . 'MATCH' . chr(123) . chr(39) . $self->{metasyntax} . chr(39) . chr(125) . ' ' . chr(61) . ' [ ' . chr(36) . 'm2 ]' . chr(59) . ' ' . chr(125) . chr(59) . ' ' . '1 ' . chr(125) . ' else ' . chr(123) . ' False ' . chr(125) . chr(59) . ' '))
}
else {
($code = 'if ' . chr(36) . 'm2 ' . chr(123) . ' ' . chr(36) . 'MATCH.to ' . chr(61) . ' ' . chr(36) . 'm2.to' . chr(59) . ' 1 ' . chr(125) . ' else ' . chr(123) . ' False ' . chr(125) . chr(59) . ' ')
}
};
('(do ' . chr(123) . ' ' . 'my ' . chr(36) . 'm2 ' . chr(61) . ' ' . $meth . '(' . chr(36) . 'str, ' . chr(36) . 'MATCH.to)' . chr(59) . ' ' . $code . chr(125) . ')')
};
sub set_captures_to_array {
my $self = $_[0];
if (($self->{captures} > 0)) {
($self->{captures} = ($self->{captures} + 1))
}
}
}
;
{
package Rul::Var;
sub new { shift; bless { @_ }, "Rul::Var" }
sub sigil { $_[0]->{sigil} };
sub twigil { $_[0]->{twigil} };
sub name { $_[0]->{name} };
sub emit_perl6 {
my $self = $_[0];
((my $table) = do {
(my $Hash_a = bless {}, 'HASH');
($Hash_a->{chr(36)} = chr(36));
($Hash_a->{chr(64)} = chr(36) . 'List_');
($Hash_a->{chr(37)} = chr(36) . 'Hash_');
($Hash_a->{chr(38)} = chr(36) . 'Code_');
$Hash_a
});
($table->{$self->{sigil}} . $self->{name})
}
}
;
{
package Rul::Constant;
sub new { shift; bless { @_ }, "Rul::Constant" }
sub constant { $_[0]->{constant} };
sub emit_perl6 {
my $self = $_[0];
((my $str) = $self->{constant});
Rul::constant($str)
};
sub set_captures_to_array {
my $self = $_[0];
}
}
;
{
package Rul::Dot;
sub new { shift; bless { @_ }, "Rul::Dot" }
sub emit_perl6 {
my $self = $_[0];
('( ' . chr(39) . chr(39) . ' ne substr( ' . chr(36) . 'str, ' . chr(36) . 'MATCH.to, 1 ) ' . chr(38) . chr(38) . ' (' . chr(36) . 'MATCH.to ' . chr(61) . ' 1 + ' . chr(36) . 'MATCH.to)' . ')')
};
sub set_captures_to_array {
my $self = $_[0];
}
}
;
{
package Rul::SpecialChar;
sub new { shift; bless { @_ }, "Rul::SpecialChar" }
sub char { $_[0]->{char} };
sub emit_perl6 {
my $self = $_[0];
((my $char) = $self->{char});
if (($char eq 'n')) {
return scalar (Rul::Subrule->new(('metasyntax' => 'is_newline'), ('captures' => 0))->emit_perl6())
};
if (($char eq 'N')) {
return scalar (Rul::Subrule->new(('metasyntax' => 'not_newline'), ('captures' => 0))->emit_perl6())
};
if (($char eq 'd')) {
return scalar (Rul::Subrule->new(('metasyntax' => 'digit'), ('captures' => 0))->emit_perl6())
};
if (($char eq 's')) {
return scalar (Rul::Subrule->new(('metasyntax' => 'space'), ('captures' => 0))->emit_perl6())
};
if (($char eq 't')) {
return scalar (Rul::constant(chr(9)))
};
return scalar (Rul::constant($char))
};
sub set_captures_to_array {
my $self = $_[0];
}
}
;
{
package Rul::Block;
sub new { shift; bless { @_ }, "Rul::Block" }
sub closure { $_[0]->{closure} };
sub emit_perl6 {
my $self = $_[0];
('((do ' . chr(123) . ' ' . $self->{closure} . ' ' . chr(125) . ') ' . chr(124) . chr(124) . ' 1)')
};
sub set_captures_to_array {
my $self = $_[0];
}
}
;
{
package Rul::InterpolateVar;
sub new { shift; bless { @_ }, "Rul::InterpolateVar" }
sub var { $_[0]->{var} };
sub emit_perl6 {
my $self = $_[0];
Main::say((chr(35) . ' TODO: interpolate var ' . $self->{var}->emit_perl6() . ''));
die()
};
sub set_captures_to_array {
my $self = $_[0];
}
}
;
{
package Rul::NamedCapture;
sub new { shift; bless { @_ }, "Rul::NamedCapture" }
sub rule_exp { $_[0]->{rule_exp} };
sub capture_ident { $_[0]->{capture_ident} };
sub emit_perl6 {
my $self = $_[0];
Main::say((chr(35) . ' TODO: named capture ' . $self->{capture_ident} . ' ' . chr(61) . ' ' . $self->{rule_exp}->emit_perl6() . ''));
die()
};
sub set_captures_to_array {
my $self = $_[0];
Main::say(chr(35) . ' TODO: named capture ')
}
}
;
{
package Rul::Before;
sub new { shift; bless { @_ }, "Rul::Before" }
sub rule_exp { $_[0]->{rule_exp} };
sub emit_perl6 {
my $self = $_[0];
('(do ' . chr(123) . ' ' . 'my ' . chr(36) . 'tmp ' . chr(61) . ' ' . chr(36) . 'MATCH' . chr(59) . ' ' . chr(36) . 'MATCH ' . chr(61) . ' Perlito6::Match.new( ' . chr(39) . 'str' . chr(39) . ' ' . chr(61) . '> ' . chr(36) . 'str, ' . chr(39) . 'from' . chr(39) . ' ' . chr(61) . '> ' . chr(36) . 'tmp.to, ' . chr(39) . 'to' . chr(39) . ' ' . chr(61) . '> ' . chr(36) . 'tmp.to, ' . chr(39) . 'bool' . chr(39) . ' ' . chr(61) . '> 1 )' . chr(59) . ' ' . chr(36) . 'MATCH.bool ' . chr(61) . ' ' . $self->{rule_exp}->emit_perl6() . chr(59) . ' ' . chr(36) . 'tmp.bool ' . chr(61) . ' ' . chr(63) . chr(36) . 'MATCH' . chr(59) . ' ' . chr(36) . 'MATCH ' . chr(61) . ' ' . chr(36) . 'tmp' . chr(59) . ' ' . chr(63) . chr(36) . 'MATCH' . chr(59) . ' ' . chr(125) . ')')
};
sub set_captures_to_array {
my $self = $_[0];
}
}
;
{
package Rul::NotBefore;
sub new { shift; bless { @_ }, "Rul::NotBefore" }
sub rule_exp { $_[0]->{rule_exp} };
sub emit_perl6 {
my $self = $_[0];
('(do ' . chr(123) . ' ' . 'my ' . chr(36) . 'tmp ' . chr(61) . ' ' . chr(36) . 'MATCH' . chr(59) . ' ' . chr(36) . 'MATCH ' . chr(61) . ' Perlito6::Match.new( ' . chr(39) . 'str' . chr(39) . ' ' . chr(61) . '> ' . chr(36) . 'str, ' . chr(39) . 'from' . chr(39) . ' ' . chr(61) . '> ' . chr(36) . 'tmp.to, ' . chr(39) . 'to' . chr(39) . ' ' . chr(61) . '> ' . chr(36) . 'tmp.to, ' . chr(39) . 'bool' . chr(39) . ' ' . chr(61) . '> 1 )' . chr(59) . ' ' . chr(36) . 'MATCH.bool ' . chr(61) . ' ' . $self->{rule_exp}->emit_perl6() . chr(59) . ' ' . chr(36) . 'tmp.bool ' . chr(61) . ' ' . chr(33) . chr(36) . 'MATCH' . chr(59) . ' ' . chr(36) . 'MATCH ' . chr(61) . ' ' . chr(36) . 'tmp' . chr(59) . ' ' . chr(63) . chr(36) . 'MATCH' . chr(59) . ' ' . chr(125) . ')')
};
sub set_captures_to_array {
my $self = $_[0];
}
}
;
{
package Rul::NegateCharClass;
sub new { shift; bless { @_ }, "Rul::NegateCharClass" }
sub chars { $_[0]->{chars} };
sub emit_perl6 {
my $self = $_[0];
Main::say(('TODO NegateCharClass'));
die()
}
}
;
{
package Rul::CharClass;
sub new { shift; bless { @_ }, "Rul::CharClass" }
sub chars { $_[0]->{chars} };
sub emit_perl6 {
my $self = $_[0];
Main::say(('TODO CharClass'));
die()
}
}
;
{
package Rul::Capture;
sub new { shift; bless { @_ }, "Rul::Capture" }
sub rule_exp { $_[0]->{rule_exp} };
sub emit_perl6 {
my $self = $_[0];
Main::say(('TODO RulCapture'));
die()
}
}
;
{
package Rul::CaptureResult;
sub new { shift; bless { @_ }, "Rul::CaptureResult" }
sub rule_exp { $_[0]->{rule_exp} };
sub emit_perl6 {
my $self = $_[0];
Main::say(('TODO Rul::CaptureResult'));
die()
}
}
;
{
package Rul::After;
sub new { shift; bless { @_ }, "Rul::After" }
sub rule_exp { $_[0]->{rule_exp} };
sub emit_perl6 {
my $self = $_[0];
Main::say(('TODO Rul::After'));
die()
}
}
}
1;
Jump to Line
Something went wrong with that request. Please try again.