make assembler use \\ instead of / for newlines
This commit is contained in:
@@ -219,6 +219,7 @@ end
|
||||
local function preprocessCode(code)
|
||||
code = "\n"..code.."\n"
|
||||
|
||||
-- apply brace labels and scoped labels
|
||||
local curscope = ""
|
||||
local codet = {}
|
||||
local wordt = {}
|
||||
@@ -245,6 +246,7 @@ local function preprocessCode(code)
|
||||
|
||||
code = "\n"..table.concat(codet).."\n"
|
||||
|
||||
-- apply function macros
|
||||
local funcmacros = {}
|
||||
code = code:gsub(".define ([%.a-zA-Z0-9_]+)%(([^%)]+)%) ([^\n]+)", function(name, args, repl)
|
||||
local argt = separateCommas(args)
|
||||
@@ -266,6 +268,7 @@ local function preprocessCode(code)
|
||||
end)
|
||||
for name, replf in pairs(funcmacros) do code = code:gsub("([^a-zA-Z0-9_])"..name.." *%(([^%)]+)%)", replf) end
|
||||
|
||||
-- apply simple macros
|
||||
local simplemacros = {}
|
||||
code = code:gsub("%.define +([%.a-zA-Z0-9_]+) +([^\n]+)", function(name, repl)
|
||||
assert(not simplemacros[name], "Redefinition of macro "..name)
|
||||
@@ -279,9 +282,10 @@ local function preprocessCode(code)
|
||||
invoc = invoc+1
|
||||
return b..(repl:gsub("(_BRACE_[0-9]+_)", "%1"..invoc.."_"))..a
|
||||
end)
|
||||
print(name, code)
|
||||
end
|
||||
|
||||
code = code:gsub("\\", "\n")
|
||||
code = code:gsub("\\\\", "\n")
|
||||
|
||||
local uexprs = {}
|
||||
|
||||
@@ -355,14 +359,15 @@ local function prefixCode(code, fn) -- fix strings, add line numbers
|
||||
end
|
||||
|
||||
out(".ln 1"); out("\n");
|
||||
for i = 1, #code do
|
||||
local i = 1
|
||||
while i <= #code do
|
||||
local c = code:sub(i, i)
|
||||
local cn = code:sub(i+1, i+1)
|
||||
local cp = code:sub(i-1, i-1)
|
||||
|
||||
if state=="code" then
|
||||
if c=="\r" then
|
||||
elseif c=="\n" or (c=="/" and cn~="/" and cn~="*") then
|
||||
elseif c=="\n" then -- (c=="/" and cn~="/" and cn~="*")
|
||||
linenum = linenum+1
|
||||
if not skipnl then out("\n") out(".ln "..linenum); out("\n"); end
|
||||
newline()
|
||||
@@ -413,6 +418,8 @@ local function prefixCode(code, fn) -- fix strings, add line numbers
|
||||
state = "string"
|
||||
end
|
||||
end
|
||||
|
||||
i = i+1
|
||||
end
|
||||
assert(#bracestack==0, "unclosed brace")
|
||||
local code2 = table.concat(outt)
|
||||
|
||||
Reference in New Issue
Block a user