diff options
author | Eduardo Julian | 2018-05-13 00:47:43 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-05-13 00:47:43 -0400 |
commit | 38742d7c110f5a28f9ea4aec117cc531ac6c9b5e (patch) | |
tree | 47e75d21064c216e6156f68764b94fc86526633f /stdlib/source/lux/lang | |
parent | 6717fc5e4aaf5986cd4f0d4ea1a12793188cbe9a (diff) |
- Added new #I64 type as foundation for types based on 64-bit integers.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/lang/syntax.lux | 28 | ||||
-rw-r--r-- | stdlib/source/lux/lang/type.lux | 6 | ||||
-rw-r--r-- | stdlib/source/lux/lang/type/check.lux | 10 |
3 files changed, 24 insertions, 20 deletions
diff --git a/stdlib/source/lux/lang/syntax.lux b/stdlib/source/lux/lang/syntax.lux index 6c7236f76..bc1543cac 100644 --- a/stdlib/source/lux/lang/syntax.lux +++ b/stdlib/source/lux/lang/syntax.lux @@ -25,7 +25,7 @@ ## (file-name, line, column) to keep track of their provenance and ## location, which is helpful for documentation and debugging. (.module: - lux + [lux #- nat int deg] (lux (control monad ["p" parser "p/" Monad<Parser>] ["ex" exception #+ exception:]) @@ -74,7 +74,7 @@ comment (l.some (l.none-of new-line)) _ (l.this new-line)] (wrap [(|> where - (update@ #.line n/inc) + (update@ #.line inc) (set@ #.column +0)) comment]))) @@ -111,7 +111,7 @@ [_ (l.this new-line)] (recur (format comment new-line) (|> where - (update@ #.line n/inc) + (update@ #.line inc) (set@ #.column +0)))) ## This is the rule for handling nested sub-comments. ## Ultimately, the whole comment is just treated as text @@ -238,7 +238,7 @@ (do @ [normal (l.none-of "\\\"\n")] (wrap [(|> where - (update@ #.column n/inc)) + (update@ #.column inc)) normal])) ## Must handle escaped ## chars separately. @@ -250,7 +250,7 @@ _ (l.this "\"") #let [char (maybe.assume (text.nth +0 char))]] (wrap [(|> where' - (update@ #.column n/inc)) + (update@ #.column inc)) [where (#.Nat char)]]))) (def: (normal-nat where) @@ -341,7 +341,7 @@ ## as many spaces as necessary to be column-aligned. ## This helps ensure that the formatting on the text in the ## source-code matches the formatting of the Text value. - #let [offset-column (n/inc (get@ #.column where))] + #let [offset-column (inc (get@ #.column where))] [where' text-read] (: (l.Lexer [Cursor Text]) ## I must keep track of how much of the ## text body has been read, how far the @@ -350,7 +350,7 @@ ## processing normal text body. (loop [text-read "" where (|> where - (update@ #.column n/inc)) + (update@ #.column inc)) must-have-offset? false] (p.either (if must-have-offset? ## If I'm at the start of a @@ -375,8 +375,8 @@ (update@ #.column (n/+ offset-size))) false) (p.fail (format "Each line of a multi-line text must have an appropriate offset!\n" - "Expected: " (%i (nat-to-int offset-column)) " columns.\n" - " Actual: " (%i (nat-to-int offset-size)) " columns.\n")))) + "Expected: " (%i (.int offset-column)) " columns.\n" + " Actual: " (%i (.int offset-size)) " columns.\n")))) ($_ p.either ## Normal text characters. (do @ @@ -397,7 +397,7 @@ ## reaches the right-delimiter. (do @ [_ (l.this "\"")] - (wrap [(update@ #.column n/inc where) + (wrap [(update@ #.column inc where) text-read])))) ## If a new-line is ## encountered, it gets @@ -408,7 +408,7 @@ [_ (l.this new-line)] (recur (format text-read new-line) (|> where - (update@ #.line n/inc) + (update@ #.line inc) (set@ #.column +0)) true)))))] (wrap [where' @@ -439,7 +439,7 @@ ## end-delimiter. where' (left-padding^ where) _ (l.this <close>)] - (wrap [(update@ #.column n/inc where') + (wrap [(update@ #.column inc where') (sequence.to-list elems)]))))] (wrap [where' [where (<tag> elems)]])))] @@ -474,7 +474,7 @@ (do @ [where' (left-padding^ where) _ (l.this "}")] - (wrap [(update@ #.column n/inc where') + (wrap [(update@ #.column inc where') (sequence.to-list elems)]))))] (wrap [where' [where (#.Record elems)]]))) @@ -537,7 +537,7 @@ [_ (l.this identifier-separator) def-name ident-part^] (wrap [["lux" def-name] - (n/inc (text.size def-name))])) + (inc (text.size def-name))])) ## Not all identifiers must be specified with a module part. ## If that part is not provided, the identifier will be created ## with the empty "" text as the module. diff --git a/stdlib/source/lux/lang/type.lux b/stdlib/source/lux/lang/type.lux index 48db0b928..d7dc33ca9 100644 --- a/stdlib/source/lux/lang/type.lux +++ b/stdlib/source/lux/lang/type.lux @@ -92,7 +92,7 @@ type type] (case type (<tag> env sub-type) - (recur (n/inc num-args) sub-type) + (recur (inc num-args) sub-type) _ [num-args type])))] @@ -301,7 +301,7 @@ (-> Nat Type Type) (case size +0 body - _ (<tag> (list) (<name> (n/dec size) body))))] + _ (|> body (<name> (dec size)) (<tag> (list)))))] [univ-q #.UnivQ] [ex-q #.ExQ] @@ -329,4 +329,4 @@ (-> Nat Type Type) (case level +0 elem-type - _ (#.Primitive "#Array" (list (array (n/dec level) elem-type))))) + _ (|> elem-type (array (dec level)) (list) (#.Primitive "#Array")))) diff --git a/stdlib/source/lux/lang/type/check.lux b/stdlib/source/lux/lang/type/check.lux index 1853f0931..4537ae38d 100644 --- a/stdlib/source/lux/lang/type/check.lux +++ b/stdlib/source/lux/lang/type/check.lux @@ -114,6 +114,10 @@ (var::get id plist')) )) +(def: (var::new id plist) + (-> Var Type-Vars Type-Vars) + (#.Cons [id #.None] plist)) + (def: (var::put id value plist) (-> Var (Maybe Type) Type-Vars Type-Vars) (case plist @@ -163,7 +167,7 @@ (Check [Nat Type]) (function (_ context) (let [id (get@ #.ex-counter context)] - (#e.Success [(update@ #.ex-counter n/inc context) + (#e.Success [(update@ #.ex-counter inc context) [id (#.Ex id)]])))) (do-template [<name> <outputT> <fail> <succeed>] @@ -228,8 +232,8 @@ (function (_ context) (let [id (get@ #.var-counter context)] (#e.Success [(|> context - (update@ #.var-counter n/inc) - (update@ #.var-bindings (var::put id #.None))) + (update@ #.var-counter inc) + (update@ #.var-bindings (var::new id))) [id (#.Var id)]])))) (def: get-bindings |