From 7d2b7199d87930096b7fd799709fe0105d51eccb Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 9 Nov 2018 14:36:15 -0800 Subject: Lots of cleanups, including expanded use of (... compiles to "text literal") shorthand, deprecating Lua value, and more use of Lua "..." with text interpolations. --- core/text.nom | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'core/text.nom') diff --git a/core/text.nom b/core/text.nom index 38fa08b..1e297aa 100644 --- a/core/text.nom +++ b/core/text.nom @@ -29,17 +29,19 @@ test: %こんにちは = "こんにちは" (% と言う) とは "\(%)世界" assume (%こんにちは と言う) == "こんにちは世界" -(%expr for %match in %text matching %patt) compiles to (..) - Lua value "\ - ..(function() - local ret = _List{} - for \(%match as lua expr) in (\(%text as lua expr)):gmatch(\(..) - %patt as lua expr - ..) do - ret[#ret+1] = \(%expr as lua statements) - end - return ret - end)()" +(%expr for %match in %text matching %patt) compiles to: + define mangler + return (..) + Lua "\ + ..(function() + local \(mangle "comprehension") = _List{} + for \(%match as lua expr) in (\(%text as lua expr)):gmatch(\(..) + %patt as lua expr + ..) do + \(mangle "comprehension")[#\(mangle "comprehension")+1] = \(%expr as lua statements) + end + return \(mangle "comprehension") + end)()" test: assume "\n" == (newline) -- cgit v1.2.3