From b54829de363f67a8a6f6131ceb0eb27aa09d4292 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 27 Apr 2018 16:45:11 -0700 Subject: Better text interpolation/handling of "\". Also added syntax support for (statement; statement) --- nomsu.moon | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'nomsu.moon') 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" -- cgit v1.2.3