aboutsummaryrefslogtreecommitdiff
path: root/parser.moon
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-06-23 17:22:23 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-06-23 17:22:43 -0700
commit863983202ce4ef92d9e3a296a682535d157c245d (patch)
tree288411a534c8a64542ce1b101b9532cb12f11c7d /parser.moon
parent0d888db6324ecd879ba770880173255b6c3f7ae5 (diff)
Fixed up nomsupath behavior and refactored file stuff into its own file.
Diffstat (limited to 'parser.moon')
-rw-r--r--parser.moon8
1 files changed, 6 insertions, 2 deletions
diff --git a/parser.moon b/parser.moon
index a61b3c1..6fe54e6 100644
--- a/parser.moon
+++ b/parser.moon
@@ -56,7 +56,7 @@ NOMSU_DEFS = with {}
return #src+1
err_pos = start_pos
line_no = pos_to_line(src, err_pos)
- --src = FILE_CACHE[userdata.source.filename]
+ --src = files.read(userdata.source.filename)
line_starts = LINE_STARTS[src]
prev_line = line_no == 1 and "" or src\sub(line_starts[line_no-1] or 1, line_starts[line_no]-2)
err_line = src\sub(line_starts[line_no], (line_starts[line_no+1] or 0)-2)
@@ -100,7 +100,11 @@ NOMSU_PATTERN = do
ident <- [a-zA-Z_][a-zA-Z0-9_]*
comment <- "--" [^%nl]*
]], {set_version: (v) -> Parser.version = tonumber(v)}
- peg_file = io.open("nomsu.peg") or (package.nomsupath and io.open(package.nomsupath.."/nomsu.peg"))
+ peg_file = io.open("nomsu.peg")
+ if not peg_file and package.nomsupath
+ for path in package.nomsupath\gmatch("[^;]+")
+ peg_file = io.open(path.."/nomsu.peg")
+ break if peg_file
assert(peg_file, "could not find nomsu.peg file")
nomsu_peg = peg_tidier\match(peg_file\read('*a'))
peg_file\close!