From 0097e306a1e3b53e4cda304aac82b8778036eddf Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 11 Jul 2018 21:17:42 -0400 Subject: - Got rid of "lux text replace-once" and "lux text replace-all" extensions. --- .../common-lisp/procedure/common.jvm.lux | 2 -- .../lang/translation/js/procedure/common.jvm.lux | 36 ++++++---------------- .../luxc/lang/translation/js/runtime.jvm.lux | 7 ----- .../lang/translation/jvm/procedure/common.jvm.lux | 15 --------- .../lang/translation/lua/procedure/common.jvm.lux | 17 ++-------- .../luxc/lang/translation/lua/runtime.jvm.lux | 31 ------------------- .../lang/translation/php/procedure/common.jvm.lux | 10 ------ .../translation/python/procedure/common.jvm.lux | 10 ------ .../lang/translation/r/procedure/common.jvm.lux | 10 ------ .../lang/translation/ruby/procedure/common.jvm.lux | 15 --------- 10 files changed, 11 insertions(+), 142 deletions(-) (limited to 'new-luxc/source/luxc') diff --git a/new-luxc/source/luxc/lang/translation/common-lisp/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/common-lisp/procedure/common.jvm.lux index 3f878319b..6ac2d6a0a 100644 --- a/new-luxc/source/luxc/lang/translation/common-lisp/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/common-lisp/procedure/common.jvm.lux @@ -323,8 +323,6 @@ (install "index" (trinary text//index)) (install "size" (unary _.length)) (install "hash" (unary _.sxhash/1)) - ## (install "replace-once" (trinary text//replace-once)) - ## (install "replace-all" (trinary text//replace-all)) (install "char" (binary text//char)) (install "clip" (trinary text//clip)) ))) diff --git a/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux index d9e64d4a1..05cd0137b 100644 --- a/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux @@ -270,22 +270,13 @@ (format "String.fromCharCode" "(" (int//to-frac inputJS) ")")) ## [[Text]] -(do-template [ ] - [(def: ( inputJS) - Unary - (format inputJS ))] - - [text//size ".length"] - ) - -(do-template [ ] - [(def: ( [subjectJS paramJS]) - Binary - (format subjectJS "." "(" paramJS ")"))] +(def: (text//size inputJS) + Unary + (format inputJS ".length")) - [text//concat "concat"] - [text//contains? "includes"] - ) +(def: (text//concat [subjectJS paramJS]) + Binary + (format subjectJS "." "concat" "(" paramJS ")")) (def: (text//char [subjectJS paramJS]) Binary @@ -296,18 +287,11 @@ Trinary (format "(" subjectJS "," paramJS "," extraJS ")"))] - [text//clip runtimeT.text//clip] - [text//replace-all runtimeT.text//replace-all] + [text//clip runtimeT.text//clip] + [text//index runtimeT.text//index] + ) -(def: (text//replace-once [subjectJS paramJS extraJS]) - Trinary - (format subjectJS ".replace(" paramJS "," extraJS ")")) - -(def: (text//index [textJS partJS startJS]) - Trinary - (format runtimeT.text//index "(" textJS "," partJS "," startJS ")")) - ## [[Math]] (do-template [ ] [(def: ( inputJS) @@ -466,8 +450,6 @@ (install "index" (trinary text//index)) (install "size" (unary text//size)) (install "hash" (unary text//hash)) - (install "replace-once" (trinary text//replace-once)) - (install "replace-all" (trinary text//replace-all)) (install "char" (binary text//char)) (install "clip" (trinary text//clip)) ))) diff --git a/new-luxc/source/luxc/lang/translation/js/runtime.jvm.lux b/new-luxc/source/luxc/lang/translation/js/runtime.jvm.lux index 6039a33c7..267a3e637 100644 --- a/new-luxc/source/luxc/lang/translation/js/runtime.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/js/runtime.jvm.lux @@ -580,12 +580,6 @@ "}") "})")) -(runtime: text//replace-all "replaceAll" - (format "(function " @ "(text,toFind,replaceWith) {" - "var reEscaped = toFind.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');" - "return text.replace(new RegExp(reEscaped, 'g'), replaceWith);" - "})")) - (runtime: text//char "textChar" (format "(function " @ "(text,idx) {" "var result = text.charCodeAt(idx.L);" @@ -610,7 +604,6 @@ Runtime (format __text//index __text//clip - __text//replace-all __text//char __text//hash)) diff --git a/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux index c60c424f5..06909b5d1 100644 --- a/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux @@ -348,9 +348,6 @@ [text//concat ($i.CHECKCAST "java.lang.String") ($i.CHECKCAST "java.lang.String") ($i.INVOKEVIRTUAL "java.lang.String" "concat" ($t.method (list $String) (#.Some $String) (list)) false) id] - [text//contains? ($i.CHECKCAST "java.lang.String") ($i.CHECKCAST "java.lang.String") - ($i.INVOKEVIRTUAL "java.lang.String" "contains" ($t.method (list $CharSequence) (#.Some $t.boolean) (list)) false) - ($i.wrap #$.Boolean)] [text//char ($i.CHECKCAST "java.lang.String") jvm-intI ($i.INVOKESTATIC hostL.runtime-class "text_char" ($t.method (list $String $t.int) (#.Some $Variant) (list)) false) id] @@ -367,16 +364,6 @@ [text//clip ($i.CHECKCAST "java.lang.String") jvm-intI jvm-intI ($i.INVOKESTATIC hostL.runtime-class "text_clip" ($t.method (list $String $t.int $t.int) (#.Some $Variant) (list)) false)] - [text//replace-once ($i.CHECKCAST "java.lang.String") - (<| ($i.INVOKESTATIC "java.util.regex.Pattern" "quote" ($t.method (list $String) (#.Some $String) (list)) false) - ($i.CHECKCAST "java.lang.String")) - ($i.CHECKCAST "java.lang.String") - ($i.INVOKEVIRTUAL "java.lang.String" "replaceFirst" ($t.method (list $String $String) (#.Some $String) (list)) false)] - [text//replace-all ($i.CHECKCAST "java.lang.String") - (<| ($i.INVOKESTATIC "java.util.regex.Pattern" "quote" ($t.method (list $String) (#.Some $String) (list)) false) - ($i.CHECKCAST "java.lang.String")) - ($i.CHECKCAST "java.lang.String") - ($i.INVOKEVIRTUAL "java.lang.String" "replaceAll" ($t.method (list $String $String) (#.Some $String) (list)) false)] ) (def: index-method $.Method ($t.method (list $String $t.int) (#.Some $t.int) (list))) @@ -606,8 +593,6 @@ (install "index" (trinary text//index)) (install "size" (unary text//size)) (install "hash" (unary text//hash)) - (install "replace-once" (trinary text//replace-once)) - (install "replace-all" (trinary text//replace-all)) (install "char" (binary text//char)) (install "clip" (trinary text//clip)) ))) diff --git a/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux index b54829a62..67aa5417a 100644 --- a/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux @@ -284,12 +284,6 @@ Binary (format "(" subjectO " .. " paramO ")")) -(def: (text//contains? [subjectO paramO]) - Binary - (|> (lua.apply "string.find" (list subjectO paramO (lua.int 1) (lua.bool true))) - (lua.= lua.nil) - lua.not)) - (def: (text//char [subjectO paramO]) Binary (runtimeT.text//char subjectO paramO)) @@ -299,15 +293,10 @@ Trinary ( subjectO paramO extraO))] - [text//clip runtimeT.text//clip] - [text//replace-all runtimeT.text//replace-all] - [text//replace-once runtimeT.text//replace-once] + [text//clip runtimeT.text//clip] + [text//index runtimeT.text//index] ) -(def: (text//index [textO partO startO]) - Trinary - (runtimeT.text//index textO partO startO)) - ## [[Math]] (do-template [ ] [(def: ( inputO) @@ -451,8 +440,6 @@ (install "index" (trinary text//index)) (install "size" (unary text//size)) (install "hash" (unary text//hash)) - (install "replace-once" (trinary text//replace-once)) - (install "replace-all" (trinary text//replace-all)) (install "char" (binary text//char)) (install "clip" (trinary text//clip)) ))) diff --git a/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux b/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux index 5a0d62225..9e7dc7422 100644 --- a/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux @@ -201,35 +201,6 @@ (lua.return! none) (lua.return! (some (lua.apply "string.sub" (list text from to)))))))) -(runtime: (text//replace-once text to-find replacement) - (let [find-index (lua.apply "string.find" (list text to-find (lua.int 1) (lua.bool true)))] - (lua.block! (list (lua.local! "findSize" (#.Some (lua.apply "string.len" (list to-find)))) - (lua.local! "parts" (#.Some (lua.array (list)))) - (lua.local! "idx" (#.Some find-index)) - (lua.when! (lua.not (lua.= lua.nil "idx")) - (let [find-pre (lua.apply "string.sub" (list text (lua.int 1) "idx")) - find-post (lua.apply "string.sub" (list text "idx" (lua.+ "idx" "findSize")))] - (lua.block! (list (lua.apply "table.insert" (list "parts" find-pre)) - (lua.apply "table.insert" (list "parts" replacement)) - (lua.set! text find-post))))) - (lua.apply "table.insert" (list "parts" text)) - (lua.return! (lua.apply "table.concat" (list "parts"))))))) - -(runtime: (text//replace-all text to-find replacement) - (let [find-index (lua.apply "string.find" (list text to-find (lua.int 1) (lua.bool true)))] - (lua.block! (list (lua.local! "findSize" (#.Some (lua.apply "string.len" (list to-find)))) - (lua.local! "parts" (#.Some (lua.array (list)))) - (lua.local! "idx" (#.Some find-index)) - (lua.while! (lua.not (lua.= lua.nil "idx")) - (let [find-pre (lua.apply "string.sub" (list text (lua.int 1) (lua.- (lua.int 1) "idx"))) - find-post (lua.apply "string.sub" (list text (lua.+ "findSize" "idx")))] - (lua.block! (list (lua.apply "table.insert" (list "parts" find-pre)) - (lua.apply "table.insert" (list "parts" replacement)) - (lua.set! text find-post) - (lua.set! "idx" find-index))))) - (lua.apply "table.insert" (list "parts" text)) - (lua.return! (lua.apply "table.concat" (list "parts"))))))) - (runtime: (text//char text idx) (lua.block! (list (lua.local! "char" (#.Some (lua.apply "string.byte" (list text idx)))) (lua.if! (lua.= lua.nil "char") @@ -249,8 +220,6 @@ Runtime (format @@text//index @@text//clip - @@text//replace-once - @@text//replace-all @@text//char @@text//hash)) diff --git a/new-luxc/source/luxc/lang/translation/php/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/php/procedure/common.jvm.lux index 73185ff66..8f11d98a3 100644 --- a/new-luxc/source/luxc/lang/translation/php/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/php/procedure/common.jvm.lux @@ -317,14 +317,6 @@ ## Binary ## (runtimeT.text//char subjectO paramO)) -## (def: (text//replace-all [subjectO paramO extraO]) -## Trinary -## (_.send (list paramO extraO) "replace" subjectO)) - -## (def: (text//replace-once [subjectO paramO extraO]) -## Trinary -## (_.send (list paramO extraO (_.int 1)) "replace" subjectO)) - ## (def: (text//clip [subjectO paramO extraO]) ## Trinary ## (runtimeT.text//clip subjectO paramO extraO)) @@ -343,8 +335,6 @@ ## (install "index" (trinary text//index)) ## (install "size" (unary (apply1 (_.global "len")))) ## (install "hash" (unary (apply1 (_.global "hash")))) -## (install "replace-once" (trinary text//replace-once)) -## (install "replace-all" (trinary text//replace-all)) ## (install "char" (binary text//char)) ## (install "clip" (trinary text//clip)) ## ))) diff --git a/new-luxc/source/luxc/lang/translation/python/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/python/procedure/common.jvm.lux index e2ab5113c..7dbeb2ab5 100644 --- a/new-luxc/source/luxc/lang/translation/python/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/python/procedure/common.jvm.lux @@ -337,14 +337,6 @@ Binary (runtimeT.text//char subjectO paramO)) -(def: (text//replace-all [subjectO paramO extraO]) - Trinary - (python.send (list paramO extraO) "replace" subjectO)) - -(def: (text//replace-once [subjectO paramO extraO]) - Trinary - (python.send (list paramO extraO (python.int 1)) "replace" subjectO)) - (def: (text//clip [subjectO paramO extraO]) Trinary (runtimeT.text//clip subjectO paramO extraO)) @@ -363,8 +355,6 @@ (install "index" (trinary text//index)) (install "size" (unary (apply1 (python.global "len")))) (install "hash" (unary (apply1 (python.global "hash")))) - (install "replace-once" (trinary text//replace-once)) - (install "replace-all" (trinary text//replace-all)) (install "char" (binary text//char)) (install "clip" (trinary text//clip)) ))) diff --git a/new-luxc/source/luxc/lang/translation/r/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/r/procedure/common.jvm.lux index 9d4fdce2a..ea85aef1e 100644 --- a/new-luxc/source/luxc/lang/translation/r/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/r/procedure/common.jvm.lux @@ -319,14 +319,6 @@ Binary (runtimeT.text//char subjectO paramO)) -(def: (text//replace-all [textO patternO replacementO]) - Trinary - (r.apply (list patternO replacementO textO) (r.global "gsub"))) - -(def: (text//replace-once [textO patternO replacementO]) - Trinary - (r.apply (list patternO replacementO textO) (r.global "sub"))) - (def: (text//clip [subjectO paramO extraO]) Trinary (runtimeT.text//clip subjectO paramO extraO)) @@ -345,8 +337,6 @@ (install "index" (trinary text//index)) (install "size" (unary (|>> (apply1 (r.global "nchar")) runtimeT.int//from-float))) (install "hash" (unary runtimeT.text//hash)) - (install "replace-once" (trinary text//replace-once)) - (install "replace-all" (trinary text//replace-all)) (install "char" (binary text//char)) (install "clip" (trinary text//clip)) ))) diff --git a/new-luxc/source/luxc/lang/translation/ruby/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/ruby/procedure/common.jvm.lux index 1b90e322a..7ea0df048 100644 --- a/new-luxc/source/luxc/lang/translation/ruby/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/ruby/procedure/common.jvm.lux @@ -347,23 +347,10 @@ Binary (|> subjectO (ruby.+ paramO))) -(def: (text//contains? [subjectO paramO]) - Binary - (ruby.send "include?" (list paramO) subjectO)) - (def: (text//char [subjectO paramO]) Binary (runtimeT.text//char subjectO paramO)) -(do-template [ ] - [(def: ( [subjectO paramO extraO]) - Trinary - (ruby.send (list paramO extraO) subjectO))] - - [text//replace-all "gsub"] - [text//replace-once "sub"] - ) - (def: (text//clip [subjectO paramO extraO]) Trinary (runtimeT.text//clip subjectO paramO extraO)) @@ -382,8 +369,6 @@ (install "index" (trinary text//index)) (install "size" (unary text//size)) (install "hash" (unary text//hash)) - (install "replace-once" (trinary text//replace-once)) - (install "replace-all" (trinary text//replace-all)) (install "char" (binary text//char)) (install "clip" (trinary text//clip)) ))) -- cgit v1.2.3