diff options
Diffstat (limited to 'core/text.nom')
| -rw-r--r-- | core/text.nom | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/core/text.nom b/core/text.nom index 8213988..d877de7 100644 --- a/core/text.nom +++ b/core/text.nom @@ -12,16 +12,16 @@ action [%texts joined with %glue]: return table.concat(text_bits, \%glue) parse [joined %texts, %texts joined] as: %texts joined with "" -compile [capitalized %text, %text capitalized] to {..} - expr:"((\(%text as lua expr)):gsub('%l', string.upper, 1))" +compile [capitalized %text, %text capitalized] to + Lua value "((\(%text as lua expr)):gsub('%l', string.upper, 1))" -compile [%text with %sub instead of %patt, %text s/%patt/%sub] to {..} - expr:"((\(%text as lua expr)):gsub(\(%patt as lua expr), \(%sub as lua expr)))" +compile [%text with %sub instead of %patt, %text s/%patt/%sub] to + Lua value "((\(%text as lua expr)):gsub(\(%patt as lua expr), \(%sub as lua expr)))" # TODO: figure out whether indent/dedent should affect first line -compile [indented %text, %text indented] to {expr:"((\%text):gsub('\\n','\\n'..(' ')))"} -compile [dedented %obj, %obj dedented] to {expr:"nomsu:dedent(\(%obj as lua expr))"} -compile [%text indented %n times] to {expr:"((\%text):gsub('\\n','\\n'..(' '):rep(\%n)))"} +compile [indented %text, %text indented] to: Lua value "((\%text):gsub('\\n','\\n'..(' ')))" +compile [dedented %obj, %obj dedented] to: Lua value "nomsu:dedent(\(%obj as lua expr))" +compile [%text indented %n times] to: Lua value "((\%text):gsub('\\n','\\n'..(' '):rep(\%n)))" # Text literals lua> ".." @@ -32,7 +32,7 @@ lua> ".." }; for name, e in pairs(escapes) do local lua = "'"..e.."'"; - nomsu:define_compile_action(name, \(!! code location !!), function() return {expr=lua}; end); + nomsu:define_compile_action(name, \(!! code location !!), function(tree) return Lua.Value(tree.source, lua); end); end local colors = { ["reset color"]="\\\\27[0m", bright="\\\\27[1m", dim="\\\\27[2m", underscore="\\\\27[4m", @@ -47,9 +47,9 @@ lua> ".." for name, c in pairs(colors) do local color = "'"..c.."'"; local reset = "'"..colors["reset color"].."'"; - nomsu:define_compile_action(name, \(!! code location !!), function() return {expr=color}; end); + nomsu:define_compile_action(name, \(!! code location !!), function(tree) return Lua.Value(tree.source, color); end); nomsu:define_compile_action(name.." %", \(!! code location !!), function(\%) - return {expr=color..".."..nomsu:tree_to_lua(\%).expr..".."..reset}; + return Lua.Value(tree.source, color, "..", nomsu:tree_to_lua(\%), "..", reset); end); end end |
