Fix some bugs on compiler, debugger and assembler

master
Joachim Stolberg 2022-06-20 19:51:25 +02:00
parent 73f8745537
commit 6ed8125b28
3 changed files with 8 additions and 3 deletions

View File

@ -83,6 +83,10 @@ local function strsplit(s)
return words
end
local function handle_escape_sequence(str)
return string.gsub(str, "\\([0-7][0-7][0-7])", function(s) return "\x00" .. string.char(tonumber(s, 8)) end)
end
local function constant(s)
if s and string.sub(s, 1, 1) == "#" then
if string.sub(s, 2, 2) == "$" then
@ -368,6 +372,7 @@ end
function Asm:decode_ctext(tok)
local codestr = tok[CODESTR]
if codestr:byte(1) == 34 and codestr:byte(-1) == 34 then
codestr = handle_escape_sequence(codestr)
codestr = codestr:gsub('\\0"', '\0\0"')
codestr = codestr:gsub("\\n", "\n")
codestr = codestr:sub(2, -2)

View File

@ -127,7 +127,7 @@ function vm16.compile(pos, filename, readfile, options)
local prs = vm16.BPars:new({pos = pos, readfile = readfile, options = options})
prs:bpars_init()
local sts, res = pcall(prs.scanner, prs, filename, options)
local sts, res = pcall(prs.scanner, prs, filename, options.gen_asm_code)
if not sts then
return false, error_msg(res)
end

View File

@ -1100,8 +1100,8 @@ brnch 37 00A3: "exit"
code 3 0011: 0000
code 4 0012: 01FF 01FF 01FF
code 1 0015: 6572 726F 0072 0000
code 2 0019: 5C31 3233 5C31 3435 0000
code 3 001E: 5C30 3031 5C30 3032 5C30 3033 0000
code 2 0019: 7830 3053 7830 3065 0000
code 3 001E: 7830 3001 7830 3002 7830 3003 0000
#### Debug ####
file 0 0000: "test11.c"
gvar 1 000F: "s0"