]> git.lizzy.rs Git - metalua.git/commitdiff
fixed the parsing of return statements: they wouldn't accept the semicolon in 'return;'
authorfabien <fabien@fabien-ubuntu.(none)>
Wed, 10 Sep 2008 18:30:13 +0000 (20:30 +0200)
committerfabien <fabien@fabien-ubuntu.(none)>
Wed, 10 Sep 2008 18:30:13 +0000 (20:30 +0200)
src/compiler/mlp_stat.lua

index 04b804888eb73a03e37b4414073e3c46caae66e5..cf330e6d3defbad2e428d0847bacc01c5f74447c 100644 (file)
@@ -62,10 +62,17 @@ block = gg.list {
 
 --------------------------------------------------------------------------------
 -- Helper function for "return <expr_list>" parsing.
--- Called when parsing return statements
---------------------------------------------------------------------------------
-local return_expr_list_parser = gg.list { 
-   expr, separators = ",", terminators = block_terminators }
+-- Called when parsing return statements.
+-- The specific test for initial ";" is because it's not a block terminator,
+-- so without itgg.list would choke on "return ;" statements.
+-- We don't make a modified copy of block_terminators because this list
+-- is sometimes modified at runtime, and the return parser would get out of
+-- sync if it was relying on a copy.
+--------------------------------------------------------------------------------
+local return_expr_list_parser = gg.multisequence{
+   { ";" , builder = function() return { } end }, 
+   default = gg.list { 
+      expr, separators = ",", terminators = block_terminators } }
 
 --------------------------------------------------------------------------------
 -- for header, between [for] and [do] (exclusive).