From ec5d730fa0ac26ace7fdd6a1de5fed9e05c133c0 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 24 Apr 2018 20:38:25 -0700 Subject: Switched repr() to only return ""-style strings, and not [[]]-style, which helps with indenting generated lua code correctly. Also made a few ergonomic fixes/changes for line breaking. --- core/metaprogramming.nom | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/metaprogramming.nom b/core/metaprogramming.nom index aea756a..f03f8d5 100644 --- a/core/metaprogramming.nom +++ b/core/metaprogramming.nom @@ -11,7 +11,13 @@ immediately: for i, action in ipairs(\%actions.value) do stubs[i] = action:get_stub(true); end - lua:append(repr(stubs), ", ", repr(tree.source:get_line()), ", function(tree"); + stubs = repr(stubs); + if #stubs > 80 then + lua:append("\\n ",stubs,",\\n "); + else + lua:append(stubs,", "); + end + lua:append(repr(tree.source:get_line()), ", function(tree"); local args = {}; for i,tok in ipairs(\%actions.value[1].value) do if tok.type == "Var" then args[#args+1] = nomsu:var_to_lua_identifier(tok.value); end @@ -40,7 +46,13 @@ immediately: for i, action in ipairs(\%actions.value) do stubs[i] = action:get_stub(true); end - lua:append(repr(stubs), ", ", repr(tree.source:get_line()), ", function("); + stubs = repr(stubs); + if #stubs > 80 then + lua:append("\\n ",stubs,",\\n "); + else + lua:append(stubs,", "); + end + lua:append(repr(tree.source:get_line()), ", function("); local args = {}; for i,tok in ipairs(\%actions.value[1].value) do if tok.type == "Var" then args[#args+1] = nomsu:var_to_lua_identifier(tok.value); end @@ -65,7 +77,13 @@ immediately: for i, action in ipairs(\%shorthand.value) do stubs[i] = action:get_stub(true); end - lua:append(repr(stubs), ", ", repr(tree.source:get_line()), ", function(tree"); + stubs = repr(stubs); + if #stubs > 80 then + lua:append("\\n ",stubs,",\\n "); + else + lua:append(stubs,", "); + end + lua:append(repr(tree.source:get_line()), ", function(tree"); local args = {}; for i,tok in ipairs(\%shorthand.value[1].value) do if tok.type == "Var" then args[#args+1] = nomsu:var_to_lua_identifier(tok.value); end -- cgit v1.2.3