1
0
mirror of https://github.com/g012/l65.git synced 2024-06-02 12:41:28 +00:00

Added Lua 5.3 binary operators.

This commit is contained in:
g012 2017-09-03 16:10:28 +02:00
parent 9bcb674f2c
commit 9031730490
2 changed files with 1711 additions and 1702 deletions

View File

@ -5,11 +5,18 @@ TIM_VBLANK = 61 -- TIM64T, 3904 cycles = ~ 51 scanlines
TIM_KERNEL = 17 -- T1024T, 17408 cycles = ~229 scanlines
location(0xf000, 0xffff)
if toto ~= 15 then end
abc = 13 ~ 0x7
xyz = 1 << 2
section "waitForIntim"
-- n_{ a=INTIM } ?
--lda(INTIM) -- or a=INTIM
--bne "waitForIntim"
ldx #0xf0
ldx #0b1101
ldy #0xAB - 16 + 0b11011 & 3 | 6 ~ 0xf >> ~3 << 1 // 5
lda #0xac
lda #INTIM

58
l65.lua
View File

@ -22,7 +22,7 @@ local HexDigits = lookupify{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'a', 'B', 'b', 'C', 'c', 'D', 'd', 'E', 'e', 'F', 'f'}
local BinDigits = lookupify{'0', '1'}
local Symbols = lookupify{'+', '-', '*', '/', '^', '%', ',', '{', '}', '[', ']', '(', ')', ';', '#'}
local Symbols = lookupify{'+', '-', '*', '/', '^', '%', ',', '{', '}', '[', ']', '(', ')', ';', '#', '&', '|'}
local Keywords = lookupify{
'and', 'break', 'do', 'else', 'elseif',
@ -474,19 +474,18 @@ local function LexLua(src)
toEmit = {Type = 'Symbol', Data = '['}
end
elseif c == '<' and peek(1) == c then
get() get()
toEmit = {Type = 'Symbol', Data = '<<'}
elseif c == '>' and peek(1) == c then
get() get()
toEmit = {Type = 'Symbol', Data = '>>'}
elseif consume('>=<') then
if consume('=') then
toEmit = {Type = 'Symbol', Data = c..'='}
else
toEmit = {Type = 'Symbol', Data = c}
end
toEmit = {Type = 'Symbol', Data = consume('=') and c..'=' or c}
elseif consume('~') then
if consume('=') then
toEmit = {Type = 'Symbol', Data = '~='}
else
generateError("Unexpected symbol `~` in source.", 2)
end
toEmit = {Type = 'Symbol', Data = consume('=') and '~=' or '~'}
elseif consume('.') then
if consume('.') then
@ -500,11 +499,9 @@ local function LexLua(src)
end
elseif consume(':') then
if consume(':') then
toEmit = {Type = 'Symbol', Data = '::'}
else
toEmit = {Type = 'Symbol', Data = ':'}
end
toEmit = {Type = 'Symbol', Data = consume(':') and '::' or ':'}
elseif consume('/') then
toEmit = {Type = 'Symbol', Data = consume('/') and '//' or '/'}
elseif Symbols[c] then
get()
@ -1006,16 +1003,22 @@ local function ParseLua(src)
end
local unops = lookupify{'-', 'not', '#'}
local unopprio = 8
local unops = lookupify{'-', 'not', '#', '~'}
local unopprio = 12
local priority = {
['+'] = {6,6};
['-'] = {6,6};
['%'] = {7,7};
['/'] = {7,7};
['*'] = {7,7};
['^'] = {10,9};
['..'] = {5,4};
['^'] = {14,13};
['%'] = {11,11};
['//'] = {11,11};
['/'] = {11,11};
['*'] = {11,11};
['+'] = {10,10};
['-'] = {10,10};
['..'] = {9,8};
['>>'] = {7,7};
['<<'] = {7,7};
['&'] = {6,6};
['~'] = {5,5};
['|'] = {4,4};
['=='] = {3,3};
['<'] = {3,3};
['<='] = {3,3};
@ -2068,8 +2071,7 @@ elseif #arg == 2 then
end
--
if arg[1] == arg[2] then
print("Are you SURE you want to overwrite the source file with a minified version?\n"..
"You will be UNABLE to get the original source back!")
print("Are you SURE you want to overwrite the source file?")
while true do
io.write("Confirm (yes/cancel): ")
local msg = io.read('*line')
@ -2091,5 +2093,5 @@ elseif #arg == 2 then
--
else
print("Invalid arguments, Usage:\nLuaMinify source [destination]")
print("Invalid arguments, usage:\nl65 source [destination]")
end