xsawyerx / guacamole

Guacamole is a parser toolkit for Standard Perl. It provides fully static BNF-based parsing capability to a reasonable subset of Perl.
https://metacpan.org/pod/Guacamole
20 stars 8 forks source link

LABEL not allowed in loop statements #120

Closed wollmers closed 2 years ago

wollmers commented 2 years ago

Example:

PATH: for my $path (0..1) {
    next PATH unless ($path > 0);
    print '$path: ',$path, "\n";
}

Throws:

$ perl ternary.pl
File 'ternary.pl' does not pass Standard Perl.
Parser says:
> Error in SLIF parse: No lexeme found at line 31, column 5
> * String before error: ) : {}, ref( $class || $class )\n    );\n}\n\nPATH
> * The error was at line 31, column 5, and at character 0x003a ':', ...
> * here: : for my $path (0..1) {\n    next PATH unless ($pa
> Marpa::R2 exception at /Users/helmut/perl5/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0/Guacamole.pm line 2103.
> 
> Failed to parse past: PATH (char 122, length 1), expected LParen,OpArrow,PackageSep at /Users/helmut/perl5/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0/Guacamole.pm line 2119.
$path: 1

Label is defined in lib/Guacamole.pm

Label ::= IdentComp Colon

but nut used in the grammar of the LoopStatements.

xsawyerx commented 2 years ago

Labels should be supported in front of every statement since you can goto them from anywhere:

goto NEXT;
FIRST: print "no\n";
NEXT:
print "yes\n";
xsawyerx commented 2 years ago

Closing this in favor of the earliest ticket still open: supporting labels. :) #16.