diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-04-24 20:38:25 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-04-24 20:39:18 -0700 |
| commit | ec5d730fa0ac26ace7fdd6a1de5fed9e05c133c0 (patch) | |
| tree | 0f414c109d4fceae47eb23b6c3ca167180d9c6fb /core/metaprogramming.nom | |
| parent | bb31a98a5674a64cb015b843be534dccb24632db (diff) | |
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.
Diffstat (limited to 'core/metaprogramming.nom')
| -rw-r--r-- | core/metaprogramming.nom | 24 |
1 files changed, 21 insertions, 3 deletions
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 |
