From 6c7d53071fc0334482bcb8c349987d19ee01babe Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sun, 13 May 2012 23:14:03 +0100 Subject: Remove files from lexer interface, it's not needed --- lib/lace/lex.lua | 11 ----------- test/test-lace.lex.lua | 18 ------------------ test/test-lace.lex.rules | 5 ----- 3 files changed, 34 deletions(-) delete mode 100644 test/test-lace.lex.rules diff --git a/lib/lace/lex.lua b/lib/lace/lex.lua index 6210a36..f8e5160 100644 --- a/lib/lace/lex.lua +++ b/lib/lace/lex.lua @@ -110,17 +110,6 @@ local function lex_a_ruleset(ruleset, sourcename) return ret end -local function lex_a_file(filename) - local fh, err = sio.open(filename, "r") - if not fh then - return nil, "Unable to open " .. tostring(filename) .. ": " .. tostring(err) - end - local ruleset = fh:read("*a") - fh:close() - return lex_a_ruleset(ruleset, "@" .. filename) -end - return { - file = lex_a_file, string = lex_a_ruleset, } diff --git a/test/test-lace.lex.lua b/test/test-lace.lex.lua index 8f89bf3..5d9d552 100644 --- a/test/test-lace.lex.lua +++ b/test/test-lace.lex.lua @@ -248,24 +248,6 @@ function suite.escape_inside_unclosed_unused() assert(content.lines[1].warnings[2]:find("escape"), "The warning should be about the escape") end -function suite.load_unknown_file() - local ok, msg = lex.file("test/NOT-PRESENT") - assert(not ok, "Managed to lex a non-present file?!") - assert(msg:match 'Unable to open', "Error doesn't seem right") -end - -function suite.load_known_file() - local content = assert(lex.file("test/test-lace.lex.rules")) - assert(content.source == "@test/test-lace.lex.rules") - assert(type(content.lines) == "table", "Lines is not a table") - assert(#content.lines == 5, "There should have been five lines") - assert(content.lines[1].type == "comment", "Line 1 should be a comment") - assert(content.lines[2].type == "comment", "Line 2 should be a comment") - assert(content.lines[3].type == "comment", "Line 3 should be a comment") - assert(content.lines[4].type == "whitespace", "Line 3 should be whitespace") - assert(content.lines[5].type == "rule", "Line 3 should be a rule") -end - local count_ok = 0 for _, testname in ipairs(testnames) do print("Run: " .. testname) diff --git a/test/test-lace.lex.rules b/test/test-lace.lex.rules deleted file mode 100644 index c3acc51..0000000 --- a/test/test-lace.lex.rules +++ /dev/null @@ -1,5 +0,0 @@ --- Trivial ruleset should total 5 lines -// The first three are comments -# The fourth is whitespace and the fifth is a statement of 2 words - - deny "I hate world" -- cgit v1.2.1