From bf60ac28c5ab128a15d1b0a2d5f1021dbe7081fd Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 3 May 2018 21:56:07 -0700 Subject: Overhaul with smaller, more concise codebase around defining actions/macros, and deleting some dead code. --- core/text.nom | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'core/text.nom') diff --git a/core/text.nom b/core/text.nom index 835ef87..465e3f6 100644 --- a/core/text.nom +++ b/core/text.nom @@ -18,11 +18,6 @@ compile [capitalized %text, %text capitalized] to 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: 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> ".." do @@ -32,7 +27,7 @@ lua> ".." }; for name, e in pairs(escapes) do local lua = "'"..e.."'"; - nomsu:define_compile_action(name, \(!! code location !!), function(tree) return Lua.Value(tree.source, lua); end); + nomsu:define_compile_action(name, 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,8 +42,8 @@ lua> ".." for name, c in pairs(colors) do local color = "'"..c.."'"; local reset = "'"..colors["reset color"].."'"; - nomsu:define_compile_action(name, \(!! code location !!), function(tree) return Lua.Value(tree.source, color); end); - nomsu:define_compile_action(name.." %", \(!! code location !!), function(\%) + nomsu:define_compile_action(name, function(tree) return Lua.Value(tree.source, color); end); + nomsu:define_compile_action(name.." %", function(\%) return Lua.Value(tree.source, color, "..", \%:as_lua(nomsu), "..", reset); end); end -- cgit v1.2.3