aboutsummaryrefslogtreecommitdiff
path: root/nomsu.moon
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-04-27 16:45:11 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-04-27 16:45:35 -0700
commitb54829de363f67a8a6f6131ceb0eb27aa09d4292 (patch)
treec03e3a7ad9a5cd58d0055b262e0ddf1bca89ba97 /nomsu.moon
parent6fecb5d3950949d3bcf232f74283229248c21247 (diff)
Better text interpolation/handling of "\". Also added syntax support for
(statement; statement)
Diffstat (limited to 'nomsu.moon')
-rwxr-xr-xnomsu.moon7
1 files changed, 3 insertions, 4 deletions
diff --git a/nomsu.moon b/nomsu.moon
index 9441414..7e94ecd 100755
--- a/nomsu.moon
+++ b/nomsu.moon
@@ -35,7 +35,6 @@ debug_getinfo = debug.getinfo
-- Do a pass on all actions to enforce parameters-are-nouns heuristic
-- Maybe do some sort of lazy definitions of actions that defer until they're used in code
-- Add a ((%x foo %y) where {x:"asdf", y:"fdsa"}) compile-time action for substitution
--- Allow plain text backslash like: "\n" in indented text without requiring "\\n"
-- Maybe support some kind of regex action definitions like "foo %first (and %next)*"?
-- Re-implement nomsu-to-lua comment translation?
@@ -155,9 +154,9 @@ NOMSU_DEFS = with {}
text_loc = lpeg.userdata.source_code.source\sub(pos,pos)
line_no = text_loc\get_line_number!
src = FILE_CACHE[text_loc.filename]
- prev_line = src\sub(LINE_STARTS[src][line_no-1] or 1, LINE_STARTS[src][line_no]-1)
- err_line = src\sub(LINE_STARTS[src][line_no], (LINE_STARTS[src][line_no+1] or 0)-1)
- next_line = src\sub(LINE_STARTS[src][line_no+1] or -1, (LINE_STARTS[src][line_no+2] or 0)-1)
+ prev_line = src\sub(LINE_STARTS[src][line_no-1] or 1, LINE_STARTS[src][line_no]-2)
+ err_line = src\sub(LINE_STARTS[src][line_no], (LINE_STARTS[src][line_no+1] or 0)-2)
+ next_line = src\sub(LINE_STARTS[src][line_no+1] or -1, (LINE_STARTS[src][line_no+2] or 0)-2)
pointer = ("-")\rep(pos-LINE_STARTS[src][line_no]) .. "^"
err_msg = (err_msg or "Parse error").." in #{lpeg.userdata.source_code.source.filename} on line #{line_no}:\n"
err_msg ..="\n#{prev_line}\n#{err_line}\n#{pointer}\n#{next_line}\n"