From f8805e6deb918aafc125ece46812e64ae121f6bc Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Wed, 13 Jan 2016 11:41:00 -0800 Subject: [PATCH] implement SPACE,HALF directive aliases --- lips/Lexer.lua | 5 ++++- lips/data.lua | 12 +++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lips/Lexer.lua b/lips/Lexer.lua index c5843c2..2e5d1af 100644 --- a/lips/Lexer.lua +++ b/lips/Lexer.lua @@ -335,8 +335,11 @@ function Lexer:lex(_yield) self:nextc() local buff = self:read_chars('[%w]') local up = buff:upper() + if data.directive_aliases[up] then + up = data.directive_aliases[up] + end if not data.all_directives[up] then - self:error('not a directive') + self:error('unknown directive') end if up == 'INC' or up == 'INCASM' or up == 'INCLUDE' then yield('DIR', 'INC') diff --git a/lips/data.lua b/lips/data.lua index 5129589..41656a0 100644 --- a/lips/data.lua +++ b/lips/data.lua @@ -29,13 +29,19 @@ data.fpu_registers = { } data.all_directives = { - 'ALIGN', 'SKIP', + 'ORG', 'ALIGN', 'SKIP', 'ASCII', 'ASCIIZ', - 'BYTE', 'HALFWORD', 'WORD', 'FLOAT', + 'BYTE', 'HALFWORD', 'WORD', --'HEX', -- excluded here due to different syntax 'INC', 'INCASM', 'INCLUDE', 'INCBIN', - 'ORG', + -- these are unlikely to be implemented + 'FLOAT', 'DOUBLE', +} + +data.directive_aliases = { + SPACE = 'SKIP', + HALF = 'HALFWORD', } data.all_registers = {}