1
0
mirror of https://github.com/g012/l65.git synced 2024-06-11 10:29:27 +00:00

Added directive switch to enable/disable asm syntax.

This commit is contained in:
g012 2017-09-05 00:05:02 +02:00
parent 1fb4b13bde
commit 262a5aa53c
2 changed files with 19 additions and 5 deletions

View File

@ -13,6 +13,10 @@ xyz = 1 << 2
x:f() x:f()
::lualabel:: ::lualabel::
syntax6502_off
lda = 5 if lda < 6 then print('yep') end
syntax6502_on
section "waitForIntim" section "waitForIntim"
-- n_{ a=INTIM } ? -- n_{ a=INTIM } ?
--lda(INTIM) -- or a=INTIM --lda(INTIM) -- or a=INTIM

20
l65.lua
View File

@ -1,8 +1,8 @@
#!/usr/bin/env lua #!/usr/bin/env lua
local function lookupify(tb, dst, val) local function lookupify(tb, dst, not_val)
if not dst then dst = tb end if not dst then dst = tb end
if not val then val = true end local val = not not_val
for _, v in pairs(tb) do for _, v in pairs(tb) do
dst[v] = val dst[v] = val
end end
@ -49,7 +49,7 @@ local Keywords_6502 = {
local syntax6502_on local syntax6502_on
local function syntax6502(on) local function syntax6502(on)
syntax6502_on = on syntax6502_on = on
lookupify(Keywords_6502, Keywords, on) lookupify(Keywords_6502, Keywords, not on)
end end
syntax6502(true) syntax6502(true)
@ -410,7 +410,14 @@ local function LexLua(src)
if Keywords[dat] then if Keywords[dat] then
toEmit = {Type = 'Keyword', Data = dat} toEmit = {Type = 'Keyword', Data = dat}
else else
toEmit = {Type = 'Ident', Data = dat} if dat == 'syntax6502_on' then
syntax6502(true)
toEmit = {Type = 'Symbol', Data = ';'}
elseif dat == 'syntax6502_off' then
syntax6502(false)
toEmit = {Type = 'Symbol', Data = ';'}
else toEmit = {Type = 'Ident', Data = dat}
end
end end
elseif Digits[c] or (peek() == '.' and Digits[peek(1)]) then elseif Digits[c] or (peek() == '.' and Digits[peek(1)]) then
@ -1119,13 +1126,14 @@ local function ParseLua(src)
end end
-- label declarations -- label declarations
if not stat then
if tok:ConsumeSymbol('@', tokenList) then if tok:ConsumeSymbol('@', tokenList) then
if not tok:Is('Ident') then return false, GenerateError("<ident> expected.") end if not tok:Is('Ident') then return false, GenerateError("<ident> expected.") end
local label_name = tok:Get(tokenList) local label_name = tok:Get(tokenList)
opcode_tok = tokenList[1] opcode_tok = tokenList[1]
label_name = as_string_expr(label_name, label_name.Data) label_name = as_string_expr(label_name, label_name.Data)
stat = emit_call('label', label_name) stat = emit_call('label', label_name)
end end end
-- 6502 opcodes -- 6502 opcodes
if not stat then if not stat then
@ -2018,6 +2026,8 @@ end
local function splitFilename(name) local function splitFilename(name)
if name:find(".") then if name:find(".") then
local p, ext = name:match("()%.([^%.]*)$") local p, ext = name:match("()%.([^%.]*)$")