aboutsummaryrefslogtreecommitdiff
path: root/core/text.nom
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-01-14 15:42:48 -0800
committerBruce Hill <bruce@bruce-hill.com>2019-01-14 15:43:24 -0800
commitc1c32688a4afc43f6addb99b8b5fa878944a70e3 (patch)
treec886f21b5b08a9053aa74fcba4b241dae5ede76d /core/text.nom
parent2309b696fc34b24f05f6658b94f9105ca8ee76e4 (diff)
Overhaul in progress, mostly working. Moved all the nomsu packages into
lib/, including core/*. Changes to how nomsu environments and importing work.
Diffstat (limited to 'core/text.nom')
-rw-r--r--core/text.nom78
1 files changed, 0 insertions, 78 deletions
diff --git a/core/text.nom b/core/text.nom
deleted file mode 100644
index 1351af6..0000000
--- a/core/text.nom
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/usr/bin/env nomsu -V6.14
-#
- This file contains some definitions of text escape sequences, including ANSI console
- color codes.
-
-use "core/metaprogramming"
-use "core/operators"
-use "core/control_flow"
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-test:
- assume "\[1, 2, 3]" == "[1, 2, 3]"
- assume "foo = \(1 + 2)!" == "foo = 3!"
- assume ("
- one
- two
- ") == ("
- one
- two
- ")
- assume "nogap" == "nogap"
- assume (["x", "y"], joined with ",") == "x,y"
- assume (["x", "y"], joined) == "xy"
- assume ("BAR", byte 2) == 65
- assume ("BAR", bytes 1 to 2) == [66, 65]
- assume ("asdf", capitalized) == "Asdf"
- assume ("asdf", uppercase) == "ASDF"
- assume ("asdf", with "s" -> "X") == "aXdf"
- assume
- ("
- one
- two
-
- "), lines
- ..== ["one", "two", ""]
-
- ($spec とは $body) parses as ($spec means $body)
-
-test:
- $こんにちは = "こんにちは"
- ($ と言う) とは "\($)世界"
- assume ($こんにちは と言う) == "こんにちは世界"
-
-($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)
- end
- return \(mangle "comprehension")
- end)()
- ")
-
-test:
- assume "\n" == (newline)
-
-test:
- assume (0xDEADBEEF as hex) == "0xDEADBEEF"
-
-externally ($num as hex) means:
- if ($num < 0):
- return ("-0x%X", formatted with (- $num))
- ..else:
- return ("0x%X", formatted with $num)
-
-# Text literals
-$escapes = {
- .nl = "\n", .newline = "\n", .tab = "\t", .bell = "\a", .cr = "\r", ."carriage return" = "\r"
- .backspace = "\b", ."form feed" = "\f", .formfeed = "\f", ."vertical tab" = "\v"
-}
-
-for $name = $str in $escapes:
- with [$lua = (Lua (quote $str))]:
- $(COMPILE RULES).$name = (-> $lua)