]> git.lizzy.rs Git - metalua.git/commitdiff
fixed trycatch
authorFabien Fleutot <metalua@gmail.com>
Mon, 2 Feb 2009 20:03:15 +0000 (21:03 +0100)
committerFabien Fleutot <metalua@gmail.com>
Mon, 2 Feb 2009 20:03:15 +0000 (21:03 +0100)
src/lib/metalua/extension/match.mlua
src/lib/metalua/extension/trycatch.mlua
src/samples/trycatch_test.mlua

index 2e747efa963079a36f45b2c13a0bd218406afd98..3581b0c48e8cf55cab6ef25111509a5786133332 100644 (file)
@@ -174,13 +174,16 @@ function regexp_pattern_element_builder (pattern, term, cfg)
    assert (regexp.tag=="String", 
            "Left hand side operand for '/' in a pattern must be "..
            "a literal string representing a regular expression")
-   assert (sub_pattern.tag=="Table",
-           "Right hand side operand for '/' in a pattern must be "..
-           "an identifier or a list of identifiers")
-   for x in ivalues(sub_pattern) do
-      assert (x.tag=="Id" or x.tag=='Dots',
-              "Right hand side operand for '/' in a pattern must be "..
-              "a list of identifiers")
+   if sub_pattern.tag=="Table" then
+      for x in ivalues(sub_pattern) do
+        assert (x.tag=="Id" or x.tag=='Dots',
+                "Right hand side operand for '/' in a pattern must be "..
+                "a list of identifiers")
+      end
+   else
+      assert (sub_pattern.tag=="Id",
+             "Right hand side operand for '/' in a pattern must be "..
+              "an identifier or a list of identifiers")
    end
 
    -- Regexp patterns can only match strings
index 7c7e4d8e4c60c3805183c2af5fe2b4eff78fa8bb..5466a07f6fe80718ddd7ed2b989ece9648f2cce7 100644 (file)
 -{ extension 'H' }
 -{ extension 'log' }
 
-require 'metalua.extension.match'
-
 -- Get match parsers and builder, for catch cases handling:
-local match_alpha = require 'extension.match'
+local match_alpha = require 'metalua.extension.match'
 local H = H:new{side='inside', alpha = match_alpha }
 
 -- We'll need to track rogue return statements:
index aff10c46c786a0b029d3d64bcda56dbf7cfe2dce..fa4f671816b2890817b9b61bab43c3c55ecbd550 100644 (file)
@@ -32,7 +32,7 @@ print "4) error, with a finally"
 try
    print "   Hi"
    error "bang"
-catch "bang"/_ then
+catch "bang"/{_} then
    print "   Bang caught"
 finally
    print "   Finally OK"
@@ -47,7 +47,7 @@ try
    catch "some_other_error" then
       assert (false, "mismatch, this must not happen")
    end
-catch "some_error"/x then
+   catch "some_error"/{x} then
    printf("   Successfully caught %q across a try that didn't catch", x)
 catch x then
    assert (false, "We shouldn't reach this catch-all")