aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/langs.md8
-rw-r--r--docs/paths.md2
-rw-r--r--environment.c8
-rw-r--r--examples/base64/base64.tm4
-rw-r--r--examples/colorful/README.md2
-rw-r--r--examples/colorful/colorful.tm14
-rw-r--r--examples/tomodeps/tomodeps.tm4
-rw-r--r--test/lang.tm4
-rw-r--r--typecheck.c2
9 files changed, 24 insertions, 24 deletions
diff --git a/docs/langs.md b/docs/langs.md
index f087b31c..0e6242db 100644
--- a/docs/langs.md
+++ b/docs/langs.md
@@ -18,7 +18,7 @@ lang HTML:
$/"/ = "&quot",
$/'/ = "'",
})
- return HTML.without_escaping(t)
+ return HTML.from_text(t)
func paragraph(content:HTML -> HTML):
return $HTML"<p>$content</p>"
@@ -75,7 +75,7 @@ instead of building a global function called `execute()` that takes a
```tomo
lang Sh:
convert(text:Text -> Sh):
- return Sh.without_escaping("'" ++ text:replace($/'/, "''") ++ "'")
+ return Sh.from_text("'" ++ text:replace($/'/, "''") ++ "'")
func execute(sh:Sh -> Text):
...
@@ -94,11 +94,11 @@ another type's block or at the top level.
```tomo
lang Sh:
convert(text:Text -> Sh):
- return Sh.without_escaping("'" ++ text:replace($/'/, "''") ++ "'")
+ return Sh.from_text("'" ++ text:replace($/'/, "''") ++ "'")
struct Foo(x,y:Int):
convert(f:Foo -> Sh):
- return Sh.without_escaping("$(f.x),$(f.y)")
+ return Sh.from_text("$(f.x),$(f.y)")
convert(texts:[Text] -> Sh):
return $Sh" ":join([Sh(t) for t in texts])
diff --git a/docs/paths.md b/docs/paths.md
index e39a42ce..6e8d6fc6 100644
--- a/docs/paths.md
+++ b/docs/paths.md
@@ -33,7 +33,7 @@ not be trustworthy and interpret that value as a single path component name,
i.e. the name of a directory or file. If a user were to supply a value like
`..` or `foo/baz`, it would risk navigating into a directory other than
intended. Paths can be created from text with slashes using
-`Path.without_escaping(text)` if you need to use arbitrary text as a file path.
+`Path.from_text(text)` if you need to use arbitrary text as a file path.
## Path Methods
diff --git a/environment.c b/environment.c
index e09ef75a..476cd69d 100644
--- a/environment.c
+++ b/environment.c
@@ -411,7 +411,7 @@ env_t *new_compilation_unit(CORD libname)
{"from_c_string", "Text$from_str", "func(str:CString -> Text?)"},
{"from_codepoint_names", "Text$from_codepoint_names", "func(codepoint_names:[Text] -> Text?)"},
{"from_codepoints", "Text$from_codepoints", "func(codepoints:[Int32] -> Text)"},
- {"without_escaping", "Path$cleanup", "func(text:Text -> Path)"},
+ {"from_text", "Path$cleanup", "func(text:Text -> Path)"},
{"has", "Text$has", "func(text:Text, pattern:Pattern -> Bool)"},
{"join", "Text$join", "func(glue:Text, pieces:[Text] -> Text)"},
{"left_pad", "Text$left_pad", "func(text:Text, count:Int, pad=\" \" -> Text)"},
@@ -588,18 +588,18 @@ env_t *new_compilation_unit(CORD libname)
ADD_CONSTRUCTORS("Thread", {"Thread$new", "func(fn:func() -> Thread)"});
#undef ADD_CONSTRUCTORS
- set_binding(namespace_env(env, "Shell"), "without_escaping",
+ set_binding(namespace_env(env, "Shell"), "from_text",
Type(FunctionType, .args=new(arg_t, .name="text", .type=TEXT_TYPE),
.ret=Type(TextType, .lang="Shell", .env=namespace_env(env, "Shell"))),
"(Shell_t)");
- set_binding(namespace_env(env, "Path"), "without_escaping",
+ set_binding(namespace_env(env, "Path"), "from_text",
Type(FunctionType, .args=new(arg_t, .name="text", .type=TEXT_TYPE),
.ret=Type(TextType, .lang="Path", .env=namespace_env(env, "Path"))),
"Path$cleanup");
- set_binding(namespace_env(env, "Pattern"), "without_escaping",
+ set_binding(namespace_env(env, "Pattern"), "from_text",
Type(FunctionType, .args=new(arg_t, .name="text", .type=TEXT_TYPE),
.ret=Type(TextType, .lang="Pattern", .env=namespace_env(env, "Pattern"))),
"(Pattern_t)");
diff --git a/examples/base64/base64.tm b/examples/base64/base64.tm
index 4e4cc8b1..fadfed20 100644
--- a/examples/base64/base64.tm
+++ b/examples/base64/base64.tm
@@ -59,7 +59,7 @@ lang Base64:
output[dest+2] = _EQUAL_BYTE
output[dest+3] = _EQUAL_BYTE
- return Base64.without_escaping(Text.from_bytes(output[]) or return none)
+ return Base64.from_text(Text.from_bytes(output[]) or return none)
func decode_text(b64:Base64 -> Text?):
return Text.from_bytes(b64:decode_bytes() or return none)
@@ -90,7 +90,7 @@ lang Base64:
func main(input=(/dev/stdin), decode=no):
if decode:
- b := Base64.without_escaping(input:read()!)
+ b := Base64.from_text(input:read()!)
say(b:decode_text()!)
else:
text := input:read()!
diff --git a/examples/colorful/README.md b/examples/colorful/README.md
index e0572bac..5f6ef8a4 100644
--- a/examples/colorful/README.md
+++ b/examples/colorful/README.md
@@ -76,7 +76,7 @@ lang Markdown:
$/*{..}*/="@(i:\1)",
$/[?](?)/="@(blue,underline:\1)",
})
- return Colorful.without_escaping(text)
+ return Colorful.from_text(text)
func colorful(md:Markdown -> Colorful):
return $Colorful"$md"
diff --git a/examples/colorful/colorful.tm b/examples/colorful/colorful.tm
index bcc95eb8..e5baf4ac 100644
--- a/examples/colorful/colorful.tm
+++ b/examples/colorful/colorful.tm
@@ -9,10 +9,10 @@ CSI := "$\033["
lang Colorful:
convert(text:Text -> Colorful):
text = text:replace_all({$/@/="@(at)", $/(/="@(lparen)", $/)/="@(rparen)"})
- return Colorful.without_escaping(text)
+ return Colorful.from_text(text)
- convert(i:Int -> Colorful): return Colorful.without_escaping("$i")
- convert(n:Num -> Colorful): return Colorful.without_escaping("$n")
+ convert(i:Int -> Colorful): return Colorful.from_text("$i")
+ convert(n:Num -> Colorful): return Colorful.from_text("$n")
func for_terminal(c:Colorful -> Text):
return CSI ++ "m" ++ _for_terminal(c, _TermState())
@@ -23,7 +23,7 @@ lang Colorful:
func main(texts:[Text], files=[:Path], by_line=no):
for i,text in texts:
- colorful := Colorful.without_escaping(text)
+ colorful := Colorful.from_text(text)
colorful:print(newline=no)
if i == texts.length: say("")
else: say(" ", newline=no)
@@ -34,10 +34,10 @@ func main(texts:[Text], files=[:Path], by_line=no):
for file in files:
if by_line:
for line in file:by_line() or exit("Could not read file: $(file.text)"):
- colorful := Colorful.without_escaping(line)
+ colorful := Colorful.from_text(line)
colorful:print()
else:
- colorful := Colorful.without_escaping(file:read() or exit("Could not read file: $(file.text)"))
+ colorful := Colorful.from_text(file:read() or exit("Could not read file: $(file.text)"))
colorful:print(newline=no)
@@ -169,7 +169,7 @@ func _add_ansi_sequences(text:Text, prev_state:_TermState -> Text):
else if text == "@" or text == "at": return "@"
parts := (
text:matches($/{0+..}:{0+..}/) or
- return "@("++_for_terminal(Colorful.without_escaping(text), prev_state)++")"
+ return "@("++_for_terminal(Colorful.from_text(text), prev_state)++")"
)
attributes := parts[1]:split($/{0+space},{0+space}/)
new_state := prev_state
diff --git a/examples/tomodeps/tomodeps.tm b/examples/tomodeps/tomodeps.tm
index 48c026e9..93e3eb42 100644
--- a/examples/tomodeps/tomodeps.tm
+++ b/examples/tomodeps/tomodeps.tm
@@ -18,7 +18,7 @@ func _get_file_dependencies(file:Path -> {Dependency}):
if lines := file:by_line():
for line in lines:
if line:matches($/use {..}.tm/):
- file_import := Path.without_escaping(line:replace($/use {..}/, "\1")):resolved(relative_to=file)
+ file_import := Path.from_text(line:replace($/use {..}/, "\1")):resolved(relative_to=file)
deps:add(Dependency.File(file_import))
else if line:matches($/use {id}/):
module_name := line:replace($/use {..}/, "\1")
@@ -103,7 +103,7 @@ func main(files:[Text]):
for arg in files:
if arg:matches($/{..}.tm/):
- path := Path.without_escaping(arg):resolved()
+ path := Path.from_text(arg):resolved()
dependencies := get_dependency_graph(File(path))
draw_tree(File(path), dependencies)
else if arg:matches($/{id}/):
diff --git a/test/lang.tm b/test/lang.tm
index 29936a62..2aebf8e0 100644
--- a/test/lang.tm
+++ b/test/lang.tm
@@ -9,10 +9,10 @@ lang HTML:
$/'/="&#39;",
})
- return HTML.without_escaping(t)
+ return HTML.from_text(t)
convert(i:Int->HTML):
- return HTML.without_escaping("$i")
+ return HTML.from_text("$i")
func paragraph(content:HTML->HTML):
return $HTML"<p>$content</p>"
diff --git a/typecheck.c b/typecheck.c
index c69432de..c5ca64c1 100644
--- a/typecheck.c
+++ b/typecheck.c
@@ -420,7 +420,7 @@ void bind_statement(env_t *env, ast_t *statement)
type_t *type = Type(TextType, .lang=def->name, .env=ns_env);
Table$str_set(env->types, def->name, type);
- set_binding(ns_env, "without_escaping",
+ set_binding(ns_env, "from_text",
Type(FunctionType, .args=new(arg_t, .name="text", .type=TEXT_TYPE), .ret=type),
CORD_all("(", namespace_prefix(env, env->namespace), def->name, "$$type)"));