diff --git a/src/Clojure.g4 b/src/Clojure.g4 index 3ecf83b..ceb09f8 100644 --- a/src/Clojure.g4 +++ b/src/Clojure.g4 @@ -193,13 +193,14 @@ OCTAL_CHAR: ESCAPE 'o' ([0-7] | ([0-7] [0-7]) | ([0-3] [0-7] [0-7])); fragment ESCAPE: '\\'; +// Parcera currently (01.11.20) doesnt support multiple / inside +// keywords nor symbols as documented in https://clojure.org/reference/reader#_symbols +// See https://github.com/carocad/parcera/pull/94 for a more indept discussion. // ::/ is NOT a valid macro keyword, unlike :/ -// multiple / are allowed for backward compatibility -MACRO_KEYWORD: '::' (SIMPLE_KEYWORD '/'+)* SIMPLE_KEYWORD; +MACRO_KEYWORD: '::' (SIMPLE_KEYWORD '/')? SIMPLE_KEYWORD; -// multiple / are allowed for backward compatibility -KEYWORD: ':' (SIMPLE_KEYWORD '/'+)* (SIMPLE_KEYWORD | '/'); +KEYWORD: ':' (SIMPLE_KEYWORD '/')? (SIMPLE_KEYWORD | '/'); fragment SIMPLE_KEYWORD: // a single character like + - KEYWORD_HEAD @@ -210,8 +211,7 @@ fragment KEYWORD_BODY: KEYWORD_HEAD | ':'; fragment KEYWORD_HEAD: ALLOWED_NAME_CHARACTER | DIGIT | [#'] | SIGN; -// multiple / are allowed for backward compatibility -SYMBOL: (SIMPLE_SYMBOL '/'+)* (SIMPLE_SYMBOL | '/'); +SYMBOL: (SIMPLE_SYMBOL '/')? (SIMPLE_SYMBOL | '/'); fragment SIMPLE_SYMBOL: // a single character like + - / etc (ALLOWED_NAME_CHARACTER | SIGN) diff --git a/test/parcera/test_cases.cljc b/test/parcera/test_cases.cljc index 547d82a..31e56bc 100644 --- a/test/parcera/test_cases.cljc +++ b/test/parcera/test_cases.cljc @@ -208,11 +208,14 @@ (is (parcera/failure? (parcera/ast input)))) (let [input "A/A:0"] (is (= (parcera/ast input) [:code [:symbol input]]))) - (let [input "hello//a/"] - (is (parcera/failure? (parcera/ast input)))) - (let [input "hello///"] - (valid? input) - (roundtrip input))) + ;; todo: the followings are NOT valid literal symbols but they are + ;; "supported" by the current LispReader implementation + ;; hopefully in the future it won't; see CLJ-1530 + #_(let [input "hello//a/"] + (is (parcera/failure? (parcera/ast input)))) + #_(let [input "hello///"] + (valid? input) + (roundtrip input))) (deftest tag-literals @@ -241,17 +244,20 @@ (let [input ":#hello"] (valid? input) (roundtrip input)) - ;; this is NOT a valid literal keyword but it is "supported" by the current - ;; reader + ;; todo: the followings are NOT valid literal keyword but they are + ;; "supported" by the current LispReader implementation + ;; hopefully in the future it won't; see CLJ-1530 (let [inputs [":http://www.department0.university0.edu/GraduateCourse52" "::platform/http://www.department0.university0.edu/GraduateCourse52" ":hello/world/foo" ":hello/world/f:oo" - "::platform/foo/bar"]] - (doseq [input inputs] - (valid? input) - (roundtrip input))) - (let [inputs [":hello/world/" "::hello/world/" ":7/"]] + "::platform/foo/bar" + #_(doseq [input inputs] + (valid? input) + (roundtrip input)) + ":hello/world/" + "::hello/world/" + ":7/"]] (doseq [input inputs] (is (parcera/failure? (parcera/ast input))))))