diff --git a/docs/langs.md b/docs/langs.md index 7e1bd7e..0eecb3c 100644 --- a/docs/langs.md +++ b/docs/langs.md @@ -18,7 +18,7 @@ lang HTML: $/"/: """, $/'/: "'", }) - return HTML.from_unsafe_text(t) + return HTML.without_escaping(t) func paragraph(content:HTML)->HTML: return $HTML"

$content

" @@ -75,7 +75,7 @@ instead of building a global function called `execute()` that takes a ```tomo lang Sh: func escape(text:Text)->Sh: - return Sh.from_unsafe_text("'" ++ text:replace($/'/, "''") ++ "'") + return Sh.without_escaping("'" ++ text:replace($/'/, "''") ++ "'") func execute(sh:Sh)->Text: ... diff --git a/docs/paths.md b/docs/paths.md index f53cc97..b1f03ff 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.from_unsafe_text(text)` if you need to use arbitrary text as a file path. +`Path.without_escaping(text)` if you need to use arbitrary text as a file path. ## Path Methods diff --git a/environment.c b/environment.c index 385e27b..0232781 100644 --- a/environment.c +++ b/environment.c @@ -318,7 +318,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"}, - {"from_unsafe_text", "Path$cleanup", "func(text:Text)->Path"}, + {"without_escaping", "Path$cleanup", "func(text:Text)->Path"}, {"has", "Text$has", "func(text:Text, pattern:Pattern)->Bool"}, {"join", "Text$join", "func(glue:Text, pieces:[Text])->Text"}, {"lines", "Text$lines", "func(text:Text)->[Text]"}, @@ -381,18 +381,18 @@ env_t *new_compilation_unit(CORD *libname) } - set_binding(namespace_env(env, "Shell"), "from_unsafe_text", + set_binding(namespace_env(env, "Shell"), "without_escaping", new(binding_t, .type=Type(FunctionType, .args=new(arg_t, .name="text", .type=TEXT_TYPE), .ret=Type(TextType, .lang="Shell", .env=namespace_env(env, "Shell"))), .code="(Shell_t)")); - set_binding(namespace_env(env, "Path"), "from_unsafe_text", + set_binding(namespace_env(env, "Path"), "without_escaping", new(binding_t, .type=Type(FunctionType, .args=new(arg_t, .name="text", .type=TEXT_TYPE), .ret=Type(TextType, .lang="Path", .env=namespace_env(env, "Path"))), .code="Path$cleanup")); - set_binding(namespace_env(env, "Pattern"), "from_unsafe_text", + set_binding(namespace_env(env, "Pattern"), "without_escaping", new(binding_t, .type=Type(FunctionType, .args=new(arg_t, .name="text", .type=TEXT_TYPE), .ret=Type(TextType, .lang="Pattern", .env=namespace_env(env, "Pattern"))), .code="(Pattern_t)")); diff --git a/examples/tomodeps/tomodeps.tm b/examples/tomodeps/tomodeps.tm index 1cd2ee5..9418ba6 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.from_unsafe_text(line:replace($/use {..}/, "\1")):resolved(relative_to=file) + file_import := Path.without_escaping(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.from_unsafe_text(arg):resolved() + path := Path.without_escaping(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 e19c1e2..9a05eb1 100644 --- a/test/lang.tm +++ b/test/lang.tm @@ -9,10 +9,10 @@ lang HTML: $/'/: "'", }) - return HTML.from_unsafe_text(t) + return HTML.without_escaping(t) func escape_int(i:Int)->HTML: - return HTML.from_unsafe_text("$i") + return HTML.without_escaping("$i") func paragraph(content:HTML)->HTML: return $HTML"

$content

" diff --git a/typecheck.c b/typecheck.c index 82eecce..afeac42 100644 --- a/typecheck.c +++ b/typecheck.c @@ -365,7 +365,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, "from_unsafe_text", + set_binding(ns_env, "without_escaping", new(binding_t, .type=Type(FunctionType, .args=new(arg_t, .name="text", .type=TEXT_TYPE), .ret=type), .code=CORD_all("(", namespace_prefix(env->libname, env->namespace), def->name, "_t)")));