diff options
| author | Shagun Agrawal <agrawalshagun07@gmail.com> | 2024-11-03 14:53:13 +0530 |
|---|---|---|
| committer | Shagun Agrawal <agrawalshagun07@gmail.com> | 2024-11-03 14:53:13 +0530 |
| commit | a9e828cc6aeab1400217d2af9fa20c93b2183baa (patch) | |
| tree | 1983b863952bee098c0934a4b943601b9a12b954 /src/cljcc/lexer.clj | |
| parent | 817731f53df634b1a7e6c5b69c8c0064d2b1c91c (diff) | |
Add parsing for storage class specifiers
Add parsing for extern and static keywords in declarations
Diffstat (limited to 'src/cljcc/lexer.clj')
| -rw-r--r-- | src/cljcc/lexer.clj | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/cljcc/lexer.clj b/src/cljcc/lexer.clj index f074ab2..f1b0a2a 100644 --- a/src/cljcc/lexer.clj +++ b/src/cljcc/lexer.clj @@ -1,8 +1,8 @@ (ns cljcc.lexer (:require [cljcc.util :refer [newline? whitespace? read-number digit? letter-digit? letter?]] - [cljcc.token :as t] - [clojure.pprint :as pp])) + [cljcc.exception :as exc] + [cljcc.token :as t])) (defn- lexer-ctx [] {:tokens [] @@ -63,15 +63,18 @@ (recur (apply str rst) npos (-> ctx (update :col #(+ % cnt)) (update :tokens #(conj % token))))) - :else (throw (ex-info "Lexer error. Invalid token." {:line line :col col}))))) + :else (exc/lex-error {:line line :col col})))) (comment - "int main(void) { - return 2; - }" + (lex "int main(void) {return int a = 2; a <<= 2;}") - (pp/pprint - (lex "int main(void) {return int a = 2; a <<= 2;}")) - ()) + (lex " + extern int a; + + int main(void) { + return 42};") + + + ()) |
