From f9252a2973e49283a93c25ae78b4fcaad64fc69a Mon Sep 17 00:00:00 2001 From: Camilo Roca Date: Wed, 9 Oct 2019 17:02:25 +0200 Subject: [PATCH 1/3] =?UTF-8?q?unicodes:=20if=20it=20is=20not=20forbidden?= =?UTF-8?q?=20it=20is=20allowed=20=F0=9F=98=85=20added=20unit=20tests=20fo?= =?UTF-8?q?r=20specific=20symbols?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/parcera/core.clj | 4 ++-- test/parcera/test/core.clj | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/parcera/core.clj b/src/parcera/core.clj index 55dd7e4..4a0ec28 100644 --- a/src/parcera/core.clj +++ b/src/parcera/core.clj @@ -114,9 +114,9 @@ ;; EDN reader says otherwise https://github.com/edn-format/edn#symbols ;; nil, true, false are actually symbols with special meaning ... not grammar rules ;; on their own - VALID-CHARACTERS>: #'[\\w.*+\\-!?$%&=<>\\':#]+' + VALID-CHARACTERS>: #'[^\\s\\(\\)\\[\\]{}\"@~]+' *) - : #'([\\p{L}\\w.*+\\-!?$%&=<>\\':#]+\\/)?(\\/|([\\p{L}\\w.*+\\-!?$%&=<>\\':#]+))(?!\\/)' + : #'([^\\s\\(\\)\\[\\]{}\"@~]+\\/)?(\\/|([^\\s\\(\\)\\[\\]{}\"@~]+))(?!\\/)' (* HIDDEN PARSERS ------------------------------------------------------ *) diff --git a/test/parcera/test/core.clj b/test/parcera/test/core.clj index 0bacd69..2e66da9 100644 --- a/test/parcera/test/core.clj +++ b/test/parcera/test/core.clj @@ -49,6 +49,17 @@ "high accuracy\n" (with-out-str (pprint/pprint result))))))) +(deftest unit-tests + (testing "names" + (as-> "foo" input (is (= input (parcera/code (parcera/clojure input))))) + (as-> "foo-bar" input (is (= input (parcera/code (parcera/clojure input))))) + (as-> "foo->bar" input (is (= input (parcera/code (parcera/clojure input))))) + (as-> "->" input (is (= input (parcera/code (parcera/clojure input))))) + (as-> "->as" input (is (= input (parcera/code (parcera/clojure input))))) + (as-> "föl" input (is (= input (parcera/code (parcera/clojure input))))) + (as-> "Öl" input (is (= input (parcera/code (parcera/clojure input))))) + (as-> "ϕ" input (is (= input (parcera/code (parcera/clojure input))))) + (as-> "❤️" input (is (= input (parcera/code (parcera/clojure input))))))) (deftest macros (testing "metadata" From 084735730f44c97226ae897c91066de2936086c3 Mon Sep 17 00:00:00 2001 From: Camilo Roca Date: Wed, 9 Oct 2019 17:02:44 +0200 Subject: [PATCH 2/3] version bumped --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 6f8ad59..f656b4f 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject carocad/parcera "0.1.2" +(defproject carocad/parcera "0.1.3" :description "Grammar-based Clojure(script) parser" :url "https://github.com/carocad/parcera" :license {:name "LGPLv3" From 606e94c5300658fc5dbd2fb79a47ef4fb75ad534 Mon Sep 17 00:00:00 2001 From: Camilo Roca Date: Wed, 9 Oct 2019 17:28:44 +0200 Subject: [PATCH 3/3] fix: disallow escape character \ and , for symbols --- src/parcera/core.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parcera/core.clj b/src/parcera/core.clj index 4a0ec28..506157f 100644 --- a/src/parcera/core.clj +++ b/src/parcera/core.clj @@ -116,7 +116,7 @@ ;; on their own VALID-CHARACTERS>: #'[^\\s\\(\\)\\[\\]{}\"@~]+' *) - : #'([^\\s\\(\\)\\[\\]{}\"@~]+\\/)?(\\/|([^\\s\\(\\)\\[\\]{}\"@~]+))(?!\\/)' + : #'([^\\s\\(\\)\\[\\]{}\"@~,\\\\]+\\/)?(\\/|([^\\s\\(\\)\\[\\]{}\"@~,\\\\]+))(?!\\/)' (* HIDDEN PARSERS ------------------------------------------------------ *)