]> git.lizzy.rs Git - metalua.git/blobdiff - src/compiler/mlp_expr.lua
Merge branch 'better-errors' into 0.5-branch
[metalua.git] / src / compiler / mlp_expr.lua
index 213ccde22ec172ba6e4288b0691eefcf00b728bb..7e98a30681b4269faa8d6c0beffd6106204266f9 100644 (file)
@@ -109,8 +109,16 @@ local _func_val = function (lx) return func_val(lx) end
 function id_or_literal (lx)
    local a = lx:next()
    if a.tag~="Id" and a.tag~="String" and a.tag~="Number" then
-      gg.parse_error (lx, "Unexpected expr token %s",
-                      _G.table.tostring (a, 'nohash'))
+      local msg
+      if a.tag=='Eof' then
+         msg = "End of file reached when an expression was expected"
+      elseif a.tag=='Keyword' then
+         msg = "An expression was expected, and `"..a[1]..
+            "' can't start an expression"
+      else
+         msg = "Unexpected expr token " .. _G.table.tostring (a, 'nohash')
+      end
+      gg.parse_error (lx, msg)
    end
    return a
 end