From 8c5cca122817bc63f4f84cc8351ced3cb67e5eea Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 29 Nov 2017 04:51:04 -0400 Subject: - Changed the identifier separator, from the semi-colon (;) to the period/dot (.). --- luxc/src/lux/analyser/module.clj | 11 ++++++----- luxc/src/lux/base.clj | 8 ++++---- luxc/src/lux/compiler/cache.clj | 2 +- luxc/src/lux/compiler/cache/ann.clj | 5 ++--- luxc/src/lux/compiler/cache/type.clj | 5 ++--- luxc/src/lux/compiler/js/lux.clj | 4 ++-- luxc/src/lux/compiler/jvm/lux.clj | 6 +++--- luxc/src/lux/lexer.clj | 10 ++++++---- 8 files changed, 26 insertions(+), 25 deletions(-) (limited to 'luxc/src') diff --git a/luxc/src/lux/analyser/module.clj b/luxc/src/lux/analyser/module.clj index c8a263030..090165af9 100644 --- a/luxc/src/lux/analyser/module.clj +++ b/luxc/src/lux/analyser/module.clj @@ -122,7 +122,7 @@ nil) _ - ((&/fail-with-loc (str "[Analyser Error] Cannot create a new global definition outside of a global environment: " module ";" name)) + ((&/fail-with-loc (str "[Analyser Error] Cannot create a new global definition outside of a global environment: " (str module &/+name-separator+ name))) state)))) (defn def-type @@ -133,7 +133,7 @@ (if-let [$def (->> $module (&/get$ $defs) (&/|get name))] (|let [[?type ?meta ?value] $def] (return* state ?type)) - ((&/fail-with-loc (str "[Analyser Error] Unknown definition: " (str module ";" name))) + ((&/fail-with-loc (str "[Analyser Error] Unknown definition: " (str module &/+name-separator+ name))) state)) ((&/fail-with-loc (str "[Analyser Error] Unknown module: " module)) state)))) @@ -156,7 +156,8 @@ ?value])) _ - ((&/fail-with-loc (str "[Analyser Error] Not a type: " (&/ident->text (&/T [module name])))) + ((&/fail-with-loc (str "[Analyser Error] Not a type: " (&/ident->text (&/T [module name])) + "\nMETA: " (&/show-ast ?meta))) state))) ((&/fail-with-loc (str "[Analyser Error] Unknown definition: " (&/ident->text (&/T [module name])))) state)) @@ -398,7 +399,7 @@ [_ ?def-meta _] _def-data] (|case (&meta/meta-get &meta/alias-tag ?def-meta) (&/$Some [_ (&/$Symbol [?r-module ?r-name])]) - (&/T [k (str ?r-module ";" ?r-name) _def-data]) + (&/T [k (str ?r-module &/+name-separator+ ?r-name) _def-data]) _ (&/T [k "" _def-data]) @@ -409,7 +410,7 @@ (|case (&meta/meta-get meta) (&/$Some [_ (&/$Bool true)]) (&/try-all% (&/|list (&type/check type) - (&/fail-with-loc (str "[Analyser Error] Cannot tag as lux;" "? if it's not a " ": " (str module ";" name))))) + (&/fail-with-loc (str "[Analyser Error] Cannot tag as lux;" "? if it's not a " ": " (str module &/+name-separator+ name))))) _ (return nil))) diff --git a/luxc/src/lux/base.clj b/luxc/src/lux/base.clj index 910bdfadf..ae9b2bb47 100644 --- a/luxc/src/lux/base.clj +++ b/luxc/src/lux/base.clj @@ -219,7 +219,7 @@ ;; [Exports] (def ^:const value-field "_value") (def ^:const module-class-name "_") -(def ^:const +name-separator+ ";") +(def ^:const +name-separator+ ".") (def ^:const ^String version "0.6.0") @@ -1217,12 +1217,12 @@ [_ ($Tag ?module ?tag)] (if (.equals "" ?module) (str "#" ?tag) - (str "#" ?module ";" ?tag)) + (str "#" ?module +name-separator+ ?tag)) [_ ($Symbol ?module ?name)] (if (.equals "" ?module) ?name - (str ?module ";" ?name)) + (str ?module +name-separator+ ?name)) [_ ($Tuple ?elems)] (str "[" (->> ?elems (|map show-ast) (|interpose " ") (fold str "")) "]") @@ -1245,7 +1245,7 @@ (|let [[?module ?name] ident] (if (= "" ?module) ?name - (str ?module ";" ?name)))) + (str ?module +name-separator+ ?name)))) (defn fold2% [f init xs ys] (|case [xs ys] diff --git a/luxc/src/lux/compiler/cache.clj b/luxc/src/lux/compiler/cache.clj index 4c3b1a436..678fda334 100644 --- a/luxc/src/lux/compiler/cache.clj +++ b/luxc/src/lux/compiler/cache.clj @@ -96,7 +96,7 @@ (let [parts (.split _def-entry &&core/datum-separator)] (case (alength parts) 2 (let [[_name _alias] parts - [_ __module __name] (re-find #"^(.*);(.*)$" _alias) + [_ __module __name] (re-find #"^(.*)\.(.*)$" _alias) def-anns (make-record (&/|list (&/T [(make-tag &a-meta/alias-tag) (make-symbol (&/T [__module __name]))])))] (|do [def-type (&a-module/def-type __module __name) diff --git a/luxc/src/lux/compiler/cache/ann.clj b/luxc/src/lux/compiler/cache/ann.clj index 4be70a611..3111886ba 100644 --- a/luxc/src/lux/compiler/cache/ann.clj +++ b/luxc/src/lux/compiler/cache/ann.clj @@ -8,7 +8,6 @@ (def ^:private stop (->> 7 char str)) (def ^:private cons-signal (->> 5 char str)) (def ^:private nil-signal (->> 6 char str)) -(def ^:private ident-separator ";") (defn ^:private serialize-seq [serialize params] (str (&/fold (fn [so-far param] @@ -19,7 +18,7 @@ (defn ^:private serialize-ident [ident] (|let [[module name] ident] - (str module ident-separator name))) + (str module &/+name-separator+ name))) (defn serialize "(-> Code Text)" @@ -89,7 +88,7 @@ (defn [^String input] (when (.startsWith input ) (let [[^String ident* ^String input*] (.split (.substring input 1) stop 2) - [_module _name] (.split ident* ident-separator 2)] + [_module _name] (.split ident* "\\." 2)] [(&/T [dummy-cursor ( (&/T [_module _name]))]) input*]))) ^:private deserialize-symbol "@" &/$Symbol diff --git a/luxc/src/lux/compiler/cache/type.clj b/luxc/src/lux/compiler/cache/type.clj index 88e1d5a03..76cdbec52 100644 --- a/luxc/src/lux/compiler/cache/type.clj +++ b/luxc/src/lux/compiler/cache/type.clj @@ -9,7 +9,6 @@ (def ^:private stop (->> 7 char str)) (def ^:private cons-signal (->> 5 char str)) (def ^:private nil-signal (->> 6 char str)) -(def ^:private ident-separator ";") (defn ^:private serialize-list [serialize-type params] (str (&/fold (fn [so-far param] @@ -61,7 +60,7 @@ (str "%" (serialize-type left) (serialize-type right)) (&/$Named [module name] type*) - (str "@" module ident-separator name stop (serialize-type type*)) + (str "@" module &/+name-separator+ name stop (serialize-type type*)) _ (assert false (prn 'serialize-type (&type/show-type type))) @@ -118,7 +117,7 @@ (defn ^:private deserialize-named [^String input] (when (.startsWith input "@") (let [[^String module+name ^String input*] (.split (.substring input 1) stop 2) - [module name] (.split module+name ident-separator 2)] + [module name] (.split module+name "\\." 2)] (when-let [[type* ^String input*] (deserialize-type input*)] [(&/$Named (&/T [module name]) type*) input*])))) diff --git a/luxc/src/lux/compiler/js/lux.clj b/luxc/src/lux/compiler/js/lux.clj index 6319f1b2b..ae3a6425c 100644 --- a/luxc/src/lux/compiler/js/lux.clj +++ b/luxc/src/lux/compiler/js/lux.clj @@ -324,7 +324,7 @@ _ (&/without-repl-closure (&a-module/define module-name ?name def-type def-meta def-value))] (return nil)) - (&/fail-with-loc (str "[Compilation Error] Aliases cannot contain meta-data: " module-name ";" ?name))) + (&/fail-with-loc (str "[Compilation Error] Aliases cannot contain meta-data: " (str module-name &/+name-separator+ ?name)))) (&/$Some _) (&/fail-with-loc "[Compilation Error] Invalid syntax for lux;alias meta-data. Must be an Ident.") @@ -371,7 +371,7 @@ [_ (&/$None)] (return nil)) - :let [_ (println 'DEF (str module-name ";" ?name))]] + :let [_ (println 'DEF (str module-name &/+name-separator+ ?name))]] (return nil)) )) ) diff --git a/luxc/src/lux/compiler/jvm/lux.clj b/luxc/src/lux/compiler/jvm/lux.clj index b76a889b0..024abeb73 100644 --- a/luxc/src/lux/compiler/jvm/lux.clj +++ b/luxc/src/lux/compiler/jvm/lux.clj @@ -266,7 +266,7 @@ _ (&/without-repl-closure (&a-module/define module-name ?name def-type def-meta def-value))] (return nil)) - (&/fail-with-loc (str "[Compilation Error] Aliases cannot contain meta-data: " module-name ";" ?name)))) + (&/fail-with-loc (str "[Compilation Error] Aliases cannot contain meta-data: " (str module-name &/+name-separator+ ?name))))) (&/$Some _) (&/fail-with-loc "[Compilation Error] Invalid syntax for lux;alias meta-data. Must be a symbol.") @@ -343,7 +343,7 @@ [_ (&/$None)] (return nil)) - :let [_ (println 'DEF (str module-name ";" ?name))]] + :let [_ (println 'DEF (str module-name &/+name-separator+ ?name))]] (return nil))) _ @@ -412,7 +412,7 @@ [_ (&/$None)] (return nil)) - :let [_ (println 'DEF (str module-name ";" ?name))]] + :let [_ (println 'DEF (str module-name &/+name-separator+ ?name))]] (return nil))) )))) diff --git a/luxc/src/lux/lexer.clj b/luxc/src/lux/lexer.clj index 65a99de6a..7bd329766 100644 --- a/luxc/src/lux/lexer.clj +++ b/luxc/src/lux/lexer.clj @@ -98,7 +98,7 @@ (return (&/T [meta ($Text token)])))) (def +ident-re+ - #"^([^0-9\[\]\{\}\(\)\s\"#;][^\[\]\{\}\(\)\s\"#;]*)") + #"^([^0-9\[\]\{\}\(\)\s\"#.][^\[\]\{\}\(\)\s\"#.]*)") ;; [Lexers] (def ^:private lex-white-space @@ -144,10 +144,12 @@ lex-frac $Frac #"^-?(0\.[0-9_]+|[1-9][0-9_]*\.[0-9_]+)(e-?[1-9][0-9_]*)?" ) +(def +same-module-mark+ (str &/+name-separator+ &/+name-separator+)) + (def ^:private lex-ident (&/try-all-% "[Reader Error]" (&/|list (|do [[meta _ token] (&reader/read-regex +ident-re+) - [_ _ got-it?] (&reader/read-text? ";")] + [_ _ got-it?] (&reader/read-text? &/+name-separator+)] (|case got-it? (&/$Some _) (|do [[_ _ local-token] (&reader/read-regex +ident-re+) @@ -159,11 +161,11 @@ (&/$None) (return (&/T [meta (&/T ["" token])])))) - (|do [[meta _ _] (&reader/read-text ";;") + (|do [[meta _ _] (&reader/read-text +same-module-mark+) [_ _ token] (&reader/read-regex +ident-re+) module-name &/get-module-name] (return (&/T [meta (&/T [module-name token])]))) - (|do [[meta _ _] (&reader/read-text ";") + (|do [[meta _ _] (&reader/read-text &/+name-separator+) [_ _ token] (&reader/read-regex +ident-re+)] (return (&/T [meta (&/T ["lux" token])]))) ))) -- cgit v1.2.3