From 7ccc2b180fe7c35bec5a8f19171caee347a26ba5 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Wed, 20 Apr 2016 01:41:44 -0700 Subject: [PATCH] rename "defines" to "variables" this follows bass' terminology: constants don't care where they're defined, but can never be changed. variables must be defined before use, but can be redefined. defines aren't necessarily numbers. bass: https://github.com/ARM9/bass --- lips/Lexer.lua | 4 ++-- lips/Preproc.lua | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lips/Lexer.lua b/lips/Lexer.lua index 54d68b4..9d9f052 100644 --- a/lips/Lexer.lua +++ b/lips/Lexer.lua @@ -350,11 +350,11 @@ function Lexer:lex(_yield) self:nextc() local buff = self:read_chars('[%w_]') if self.chr ~= ']' then - self:error('invalid define name') + self:error('invalid variable name') end self:nextc() if self.chr ~= ':' then - self:error('define requires a colon') + self:error('expected a colon after closing bracket') end self:nextc() yield('DEF', buff) diff --git a/lips/Preproc.lua b/lips/Preproc.lua index 3889e6e..3027cd1 100644 --- a/lips/Preproc.lua +++ b/lips/Preproc.lua @@ -35,11 +35,11 @@ end function Preproc:process(tokens) self.tokens = tokens - local defines = {} + local variables = {} local plus_labels = {} -- constructed forwards local minus_labels = {} -- constructed backwards - -- first pass: resolve unary ops, defines, and collect relative labels + -- first pass: resolve unary ops, variables, and collect relative labels local new_tokens = {} self.i = 0 while self.i < #self.tokens do @@ -64,14 +64,14 @@ function Preproc:process(tokens) elseif t.tt == 'DEF' then local t2 = self:advance() if t2.tt ~= 'NUM' then - self:error('expected number for define') + self:error('expected number for variable') end - defines[t.tok] = t2.tok + variables[t.tok] = t2.tok elseif t.tt == 'DEFSYM' then local tt = 'NUM' - local tok = defines[t.tok] + local tok = variables[t.tok] if tok == nil then - self:error('undefined define') -- uhhh nice wording + self:error('undefined variable') end insert(new_tokens, self:token(tt, tok * sign)) elseif t.tt == 'RELLABEL' then