diff --git a/nomsu.peg b/nomsu.peg index 38db312..ee0acb0 100644 --- a/nomsu.peg +++ b/nomsu.peg @@ -45,12 +45,11 @@ noindex_inline_expression: ) inline_expression: index_chain / noindex_inline_expression indented_expression: - indented_text / indented_nomsu / indented_list / indented_dict / {| + indented_text / indented_nomsu / indented_list / indented_dict / ({| ("(..)" / ":")? nl_indent (comment nl_nodent)* (block / action / expression) (!! [^%nl]+ -> "Unexpected character while parsing indented expression" !!)? - {:is_halfblock: ''->'yep' :} - |} + |} -> unpack) expression: inline_expression / (":" %ws* diff --git a/parser.lua b/parser.lua index 979a29f..a4d2a90 100644 --- a/parser.lua +++ b/parser.lua @@ -26,6 +26,7 @@ do _with_0.nl = P("\r") ^ -1 * P("\n") _with_0.ws = S(" \t") _with_0.tonumber = tonumber + _with_0.unpack = unpack or table.unpack local string_escapes = { n = "\n", t = "\t", @@ -91,34 +92,6 @@ setmetatable(NOMSU_DEFS, { value.source = Source(_with_0.filename, _with_0.start + start - 1, _with_0.start + stop - 1) end end - while true do - local found = false - for i = #value, 1, -1 do - local _continue_0 = false - repeat - if not (type(value[i]) == 'table') then - _continue_0 = true - break - end - if value[i].is_halfblock then - found = true - local hb = remove(value, i) - for _index_0 = 1, #hb do - local v = hb[_index_0] - insert(value, i, v) - i = i + 1 - end - end - _continue_0 = true - until true - if not _continue_0 then - break - end - end - if not (found) then - break - end - end local comments = { } for i = #value, 1, -1 do local _continue_0 = false diff --git a/parser.moon b/parser.moon index 1591161..78aa042 100644 --- a/parser.moon +++ b/parser.moon @@ -14,6 +14,7 @@ NOMSU_DEFS = with {} .nl = P("\r")^-1 * P("\n") .ws = S(" \t") .tonumber = tonumber + .unpack = unpack or table.unpack string_escapes = n:"\n", t:"\t", b:"\b", a:"\a", v:"\v", f:"\f", r:"\r" digit, hex = R('09'), R('09','af','AF') .escaped_char = (P("\\")*S("xX")*C(hex*hex)) / => string.char(tonumber(@, 16)) @@ -58,17 +59,6 @@ setmetatable(NOMSU_DEFS, {__index:(key)=> if userdata.source with userdata.source value.source = Source(.filename, .start + start-1, .start + stop-1) - while true - found = false - for i=#value,1,-1 - continue unless type(value[i]) == 'table' - if value[i].is_halfblock - found = true - hb = remove(value, i) - for v in *hb - insert value, i, v - i += 1 - break unless found comments = {} for i=#value,1,-1 continue unless type(value[i]) == 'table'