diff --git a/metalua/compiler/ast_to_src.mlua b/metalua/compiler/ast_to_src.mlua index 65283c6..77969c3 100644 --- a/metalua/compiler/ast_to_src.mlua +++ b/metalua/compiler/ast_to_src.mlua @@ -126,7 +126,7 @@ local op_preprec = { { "concat" }, { "add", "sub" }, { "mul", "div", "mod" }, - { "unary", "not", "len" }, + { "unary", "not", "len", "unm" }, { "pow" }, { "index" } } @@ -149,7 +149,7 @@ local op_symbol = { div = " / ", mod = " % ", pow = " ^ ", concat = " .. ", eq = " == ", ne = " ~= ", lt = " < ", le = " <= ", ["and"] = " and ", - ["or"] = " or ", ["not"] = "not ", len = "# " } + ["or"] = " or ", ["not"] = "not ", len = "# ", unm = "- "} -------------------------------------------------------------------------------- -- Accumulate the source representation of AST `node' in diff --git a/metalua/grammar/lexer.lua b/metalua/grammar/lexer.lua index 0a58058..0980bfb 100644 --- a/metalua/grammar/lexer.lua +++ b/metalua/grammar/lexer.lua @@ -382,6 +382,8 @@ function lexer :extract_short_string() if x == '\\' then if y == 'z' then -- Lua 5.2 \z j = self.src :match ("^%s*()", j+1) + elseif y == '\r' then -- Only for windows \\\r\n case + j = self.src :match("^[\n]+()", j+1) else j=j+1 -- escaped char end