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
-{ 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:
try
print " Hi"
error "bang"
-catch "bang"/_ then
+catch "bang"/{_} then
print " Bang caught"
finally
print " Finally OK"
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")