Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Perlito5 - parser - fix namespace

  • Loading branch information...
commit 8b342ee0a9bcc3606e97dc4c15b885d8675d5eeb 1 parent 2b905bc
@fglock authored
Showing with 40 additions and 4 deletions.
  1. +18 −1 html/perlito5.js
  2. +16 −1 perlito5.pl
  3. +6 −2 src5/lib/Perlito5/Grammar.pm
View
19 html/perlito5.js
@@ -11652,8 +11652,25 @@ return r;
})()], p5want) }));
})()], 0), function () { return p5context([(function () {
(v_MATCH || (v_MATCH = new p5HashRef({})))._hash_.p5hset('to', (v_pos1));
- return (p5context([p5and(p5context([p5and(('::' == p5pkg["Perlito5::Grammar"].substr([v_str, (v_MATCH || (v_MATCH = new p5HashRef({})))._hash_.p5hget('to'), 2], 0)), function () { return p5context([(v_MATCH || (v_MATCH = new p5HashRef({})))._hash_.p5hset('to', ((2 + p5num((v_MATCH || (v_MATCH = new p5HashRef({})))._hash_.p5hget('to')))))], 0) })], 0), function () { return p5context([(function () {
+ return (p5context([p5and(p5and(p5context([p5and(('::' == p5pkg["Perlito5::Grammar"].substr([v_str, (v_MATCH || (v_MATCH = new p5HashRef({})))._hash_.p5hget('to'), 2], 0)), function () { return p5context([(v_MATCH || (v_MATCH = new p5HashRef({})))._hash_.p5hset('to', ((2 + p5num((v_MATCH || (v_MATCH = new p5HashRef({})))._hash_.p5hget('to')))))], 0) })], 0), function () { return p5context([(function () {
+ var v_m2;
+ (v_m2 = (p5call(v_grammar, "optional_namespace_before_ident", p5list_to_a(v_str, (v_MATCH || (v_MATCH = new p5HashRef({})))._hash_.p5hget('to')), 0)));
+ if ( p5bool(v_m2) ) {
+ (v_MATCH || (v_MATCH = new p5HashRef({})))._hash_.p5hset('to', ((v_m2 || (v_m2 = new p5HashRef({})))._hash_.p5hget('to')));
+ (v_MATCH || (v_MATCH = new p5HashRef({})))._hash_.p5hset('optional_namespace_before_ident', (v_m2));
+ return (p5context([1], p5want));
+ }
+
+ else {
+ return (p5context([0], p5want));
+ }
+ })()], 0) }), function () { return p5context([(function () {
+ var v_name;
+ (v_name = (p5pkg["Perlito5::Match"].flat(p5list_to_a((v_MATCH || (v_MATCH = new p5HashRef({})))._hash_.p5hget('optional_namespace_before_ident')), 0)));
(v_MATCH || (v_MATCH = new p5HashRef({})))._hash_.p5hset('capture', ('main'));
+ if ( (p5str(v_name) != '') ) {
+ (v_MATCH || (v_MATCH = new p5HashRef({})))._hash_.p5hset('capture', ((p5str((v_MATCH || (v_MATCH = new p5HashRef({})))._hash_.p5hget('capture')) + ('::' + p5str(v_name)))));
+ };
return (p5context([1], p5want));
})()], p5want) })], p5want));
})()], 0) }), function () { return p5context([(function () {
View
17 perlito5.pl
@@ -6470,8 +6470,23 @@ sub Perlito5::Grammar::optional_namespace_before_ident {
})))
})) || ((do {
($MATCH->{'to'} = $pos1);
- ((((('::' eq substr($str, $MATCH->{'to'}, 2)) && (($MATCH->{'to'} = (2 + $MATCH->{'to'}))))) && ((do {
+ (((((('::' eq substr($str, $MATCH->{'to'}, 2)) && (($MATCH->{'to'} = (2 + $MATCH->{'to'}))))) && ((do {
+ ((my $m2) = $grammar->optional_namespace_before_ident($str, $MATCH->{'to'}));
+ if ($m2) {
+ ($MATCH->{'to'} = $m2->{'to'});
+ ($MATCH->{'optional_namespace_before_ident'} = $m2);
+ 1
+ }
+ else {
+ 0
+ }
+}))) && ((do {
+ ((my $name) = Perlito5::Match::flat($MATCH->{'optional_namespace_before_ident'}));
($MATCH->{'capture'} = 'main');
+ if (($name ne '')) {
+ ($MATCH->{'capture'} = ($MATCH->{'capture'} . ('::' . $name)))
+ };
+;
1
}))))
}))) || ((do {
View
8 src5/lib/Perlito5/Grammar.pm
@@ -73,8 +73,12 @@ token namespace_before_ident {
token optional_namespace_before_ident {
| <namespace_before_ident> '::'*
{ $MATCH->{capture} = Perlito5::Match::flat($MATCH->{namespace_before_ident}) }
- | '::'
- { $MATCH->{capture} = 'main' }
+ | '::' <optional_namespace_before_ident>
+ {
+ my $name = Perlito5::Match::flat($MATCH->{optional_namespace_before_ident});
+ $MATCH->{capture} = 'main';
+ $MATCH->{capture} .= '::' . $name if $name ne '';
+ }
| ''
{ $MATCH->{capture} = '' }
};
Please sign in to comment.
Something went wrong with that request. Please try again.