]> git.lizzy.rs Git - metalua.git/commitdiff
fix in default args for gg.multisequence
authorFabien Fleutot <fabien@MacFabien.home>
Sat, 28 Feb 2009 12:31:05 +0000 (13:31 +0100)
committerFabien Fleutot <fabien@MacFabien.home>
Sat, 28 Feb 2009 12:31:05 +0000 (13:31 +0100)
src/compiler/gg.lua

index db0d91c16f9b982f1ccc33eaba41e7980acd40af..baf098a7a8536739a9926b02a3468fe8ca7e97c6 100644 (file)
@@ -266,15 +266,16 @@ function multisequence (p)
    -------------------------------------------------------------------
    function p:add (s)
       -- compile if necessary:
-      local keyword = s[1]
-      if not is_parser(s) then sequence(s) end
-      if is_parser(s) ~= 'sequence' or type(keyword) ~= "string" then 
+      local keyword = type(s)=='table' and s[1]
+      if type(s)=='table' and not is_parser(s) then sequence(s) end
+      if is_parser(s)~='sequence' or type(keyword)~='string' then 
          if self.default then -- two defaults
             error ("In a multisequence parser, all but one sequences "..
                    "must start with a keyword")
          else self.default = s end -- first default
       elseif self.sequences[keyword] then -- duplicate keyword
-         eprintf (" *** Warning: keyword %q overloaded in multisequence ***", keyword)
+         eprintf (" *** Warning: keyword %q overloaded in multisequence ***",
+                  keyword)
          self.sequences[keyword] = s
       else -- newly caught keyword
          self.sequences[keyword] = s