New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify parser to allow empty semicolon ';' terminated statement #127
Comments
From @ronaldxsPerl 5 allows empty semicolon terminated statements. perl6 currently The patch is small and passes "make fulltest" under ubuntu and "make The terminator.t test file is vaguely intended for the |
From @ronaldxsempty_stmt.diffIndex: t/spectest_regression.data
===================================================================
--- t/spectest_regression.data (revision 28227)
+++ t/spectest_regression.data (working copy)
@@ -15,6 +15,7 @@
S03-operators/not.t # pure
S03-operators/relational.t # pure
S03-operators/true.t # pure
+S04-statements/terminator.t # pure
S04-statements/try.t
S04-statements/until.t # pure
S04-statements/while.t
Index: src/parser/grammar.pg
===================================================================
--- src/parser/grammar.pg (revision 28227)
+++ src/parser/grammar.pg (working copy)
@@ -151,8 +151,10 @@
rule statementlist {
- [<statement><.eat_terminator> ]*
- {*}
+ | [
+ || ';'
+ || <statement><.eat_terminator>
+ ]* {*}
}
## The eat_terminator detects when we're at a valid
|
From @ronaldxsuse v6; use Test; plan 9; # L<S04/"Statement parsing"/"statement termination"> # the 'empty statement' case responsible for the creation of this test file eval_lives_ok('my $x = 2', 'simple statement no semi'); eval_dies_ok('{my $x = 2;', 'open closure'); |
From @pmichaudOn Tue, Jun 10, 2008 at 01:07:45PM -0700, Ron Schmidt wrote:
Thanks for the patch. In cases of changes to the grammar, however, rule statementlist { So, since Rakudo's current grammar pretty much matches what STD.pm Thanks again! Pm |
The RT System itself - Status changed from 'new' to 'open' |
From @ronaldxs
As far as I can tell, STD.pm handles this problem in "token statement", token statement { |
From @ronaldxsempty_stmt_r2.diffIndex: src/parser/grammar.pg
===================================================================
--- src/parser/grammar.pg (revision 28329)
+++ src/parser/grammar.pg (working copy)
@@ -203,6 +203,7 @@
{*} #= statement_mod_cond
|| {*} #= expr
]
+ | <?before ';'> {*} #= null
}
rule statement_control {
Index: src/parser/actions.pm
===================================================================
--- src/parser/actions.pm (revision 28329)
+++ src/parser/actions.pm (working copy)
@@ -111,6 +111,9 @@
if $key eq 'statement_control' {
$past := $( $<statement_control> );
}
+ elsif $key eq 'null' {
+ $past := PAST::Stmts.new(); # empty stmts seem eliminated by TGE
+ }
else {
my $expr := $( $<expr> );
if $expr.WHAT() eq 'Block' && !$expr.blocktype() {
Index: t/spectest_regression.data
===================================================================
--- t/spectest_regression.data (revision 28329)
+++ t/spectest_regression.data (working copy)
@@ -15,6 +15,7 @@
S03-operators/not.t # pure
S03-operators/relational.t # pure
S03-operators/true.t # pure
+S04-statements/terminator.t # pure
S04-statements/try.t
S04-statements/until.t # pure
S04-statements/while.t
|
From @ronaldxsuse v6; use Test; plan 9; # L<S04/"Statement parsing"/"statement termination"> # the 'empty statement' case responsible for the creation of this test file eval_lives_ok('my $x = 2', 'simple statement no semi'); eval_dies_ok('{my $x = 2;', 'open closure'); |
From @pmichaudApplied in r28597, thanks! Pm |
1 similar comment
From @pmichaudApplied in r28597, thanks! Pm |
@pmichaud - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#55594 (status was 'resolved')
Searchable as RT55594$
The text was updated successfully, but these errors were encountered: