From 071169df488b17cbaf02700508567d4e94208390 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Thu, 14 Apr 2016 07:33:33 -0700 Subject: [PATCH] redo internal paths/requires --- README.md | 3 ++- lips/Dumper.lua | 5 +++-- lips/Lexer.lua | 5 +++-- lips/Muncher.lua | 7 ++++--- lips/Parser.lua | 17 +++++++++-------- lips/Preproc.lua | 9 +++++---- lips/Token.lua | 3 ++- lips/init.lua | 5 +++-- lips/overrides.lua | 5 +++-- 9 files changed, 34 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 657fb3a..d7ed53b 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,9 @@ Even this README is incomplete. Copy the lips directory to somewhere Lua's `package.path` can find it. If you're using it locally, you will need to write something like: ``` -package.path = package.path..";./?/init.lua" +package.path = package.path.."?/init.lua" ``` +or `require "lips.init"` directly. You can then use it as such: [example.lua][elua] — [example.asm][easm] diff --git a/lips/Dumper.lua b/lips/Dumper.lua index c02345e..23a36da 100644 --- a/lips/Dumper.lua +++ b/lips/Dumper.lua @@ -2,8 +2,9 @@ local floor = math.floor local format = string.format local insert = table.insert -local data = require "lips.data" -local util = require "lips.util" +local path = string.gsub(..., "[^.]+$", "") +local data = require(path.."data") +local util = require(path.."util") local bitrange = util.bitrange diff --git a/lips/Lexer.lua b/lips/Lexer.lua index 29e9bfe..5d2e920 100644 --- a/lips/Lexer.lua +++ b/lips/Lexer.lua @@ -4,8 +4,9 @@ local find = string.find local format = string.format local insert = table.insert -local data = require "lips.data" -local util = require "lips.util" +local path = string.gsub(..., "[^.]+$", "") +local data = require(path.."data") +local util = require(path.."util") local simple_escapes = { ['0'] = 0x00, diff --git a/lips/Muncher.lua b/lips/Muncher.lua index c0ab378..b46753f 100644 --- a/lips/Muncher.lua +++ b/lips/Muncher.lua @@ -1,9 +1,10 @@ local format = string.format local insert = table.insert -local data = require "lips.data" -local util = require "lips.util" -local Token = require "lips.Token" +local path = string.gsub(..., "[^.]+$", "") +local data = require(path.."data") +local util = require(path.."util") +local Token = require(path.."Token") local arg_types = { NUM = true, diff --git a/lips/Parser.lua b/lips/Parser.lua index 2a760d0..aca36d3 100644 --- a/lips/Parser.lua +++ b/lips/Parser.lua @@ -1,13 +1,14 @@ local insert = table.insert -local data = require "lips.data" -local util = require "lips.util" -local overrides = require "lips.overrides" -local Token = require "lips.Token" -local Lexer = require "lips.Lexer" -local Dumper = require "lips.Dumper" -local Muncher = require "lips.Muncher" -local Preproc = require "lips.Preproc" +local path = string.gsub(..., "[^.]+$", "") +local data = require(path.."data") +local util = require(path.."util") +local overrides = require(path.."overrides") +local Token = require(path.."Token") +local Lexer = require(path.."Lexer") +local Dumper = require(path.."Dumper") +local Muncher = require(path.."Muncher") +local Preproc = require(path.."Preproc") local Parser = util.Class(Muncher) function Parser:init(writer, fn, options) diff --git a/lips/Preproc.lua b/lips/Preproc.lua index 89116e8..3889e6e 100644 --- a/lips/Preproc.lua +++ b/lips/Preproc.lua @@ -1,9 +1,10 @@ local insert = table.insert -local data = require "lips.data" -local util = require "lips.util" -local Muncher = require "lips.Muncher" -local Token = require "lips.Token" +local path = string.gsub(..., "[^.]+$", "") +local data = require(path.."data") +local util = require(path.."util") +local Muncher = require(path.."Muncher") +local Token = require(path.."Token") local abs = math.abs diff --git a/lips/Token.lua b/lips/Token.lua index 7978fec..5054de0 100644 --- a/lips/Token.lua +++ b/lips/Token.lua @@ -1,4 +1,5 @@ -local util = require "lips.util" +local path = string.gsub(..., "[^.]+$", "") +local util = require(path.."util") local Token = util.Class() function Token:init(...) diff --git a/lips/init.lua b/lips/init.lua index 74bc83b..9ae6f28 100644 --- a/lips/init.lua +++ b/lips/init.lua @@ -10,8 +10,9 @@ local lips = { ]], } -local util = require "lips.util" -local Parser = require "lips.Parser" +local path = string.gsub(..., "%.init$", "").."." +local util = require(path.."util") +local Parser = require(path.."Parser") function lips.word_writer() local buff = {} diff --git a/lips/overrides.lua b/lips/overrides.lua index 28ec0c0..fa59930 100644 --- a/lips/overrides.lua +++ b/lips/overrides.lua @@ -1,7 +1,8 @@ local insert = table.insert -local data = require "lips.data" -local util = require "lips.util" +local path = string.gsub(..., "[^.]+$", "") +local data = require(path.."data") +local util = require(path.."util") local instructions = data.instructions