Update reserved words

This commit is contained in:
Scott Richmond 2022-01-08 17:36:48 -05:00
parent 1ca1e4df25
commit d8273946f5

View File

@ -4,22 +4,31 @@
(def reserved-words (def reserved-words
"List of Ludus reserved words." "List of Ludus reserved words."
#{"fn" ;; see ludus-spec repo for more info
"if" #{
"then"
"else"
"nil"
"match"
"true"
"false"
"loop"
"recur"
"as" "as"
"ref" "cond"
"mut"}) "else"
;; other possibilities "false"
;; "pattern" -- first class patterns? "fn"
"if"
"match"
"mut"
"nil"
"panic!"
"then"
"true"
"var"
"with" ;;maybe
;; below here, probable
"defer"
"loop"
"ns"
"recur"
"repeat"
"when"
})
(defn- new-scanner (defn- new-scanner
"Creates a new scanner." "Creates a new scanner."
@ -137,9 +146,11 @@
;; two-character tokens ;; two-character tokens
;; -> ;; ->
;; have to fix this: negative numbers
\- (if (= next \>) \- (if (= next \>)
(add-token (advance scanner) ::token/rarrow) (add-token (advance scanner) ::token/rarrow)
(add-error scanner (str "Expected ->. Got " char next))) (add-error scanner (str "Expected ->. Got " char next)))
;; <- ;; <-
\< (if (= next \-) \< (if (= next \-)
(add-token (advance scanner) ::token/larrow) (add-token (advance scanner) ::token/larrow)
@ -151,6 +162,9 @@
(add-error scanner (str "Expected |>. Got " char next))) (add-error scanner (str "Expected |>. Got " char next)))
;; possible additional operator: => (bind) ;; possible additional operator: => (bind)
\= (if (= next \>)
(add-token (advance scanner) ::token/bind)
(add-error scanner (str "Expected =>. Got " char next)))
;; hashmap #{ ;; hashmap #{
\# (if (= next \{) \# (if (= next \{)