aboutsummaryrefslogtreecommitdiff
path: root/src/cljcc/parser.clj
diff options
context:
space:
mode:
authorShagun Agrawal <agrawalshagun07@gmail.com>2024-12-08 21:57:39 +0530
committerShagun Agrawal <agrawalshagun07@gmail.com>2024-12-08 21:57:39 +0530
commit24397e5682514f2988072d7039ed39c08e3ba7ef (patch)
treed4048d1d689356eca9ebaaa5fdfc7a291d3bb1fc /src/cljcc/parser.clj
parentfa049cc22c6c7b64b51e6e10b33a259fa58945d7 (diff)
Add tacky phase for long type generation
Tacky phase generation for for long types Refactor expression handling for Tacky phase by using postwalk function Refactor symbol namespaces
Diffstat (limited to 'src/cljcc/parser.clj')
-rw-r--r--src/cljcc/parser.clj12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/cljcc/parser.clj b/src/cljcc/parser.clj
index 7e0ca06..6b9024f 100644
--- a/src/cljcc/parser.clj
+++ b/src/cljcc/parser.clj
@@ -3,6 +3,7 @@
[cljcc.lexer :as l]
[cljcc.token :as t]
[malli.core :as m]
+ [malli.dev.pretty :as pretty]
[clojure.math :refer [pow]]
[cljcc.schema :as s]
[cljcc.exception :as exc]
@@ -53,25 +54,30 @@
(defn function-call-exp-node [identifier arguments]
{:type :exp
:exp-type :function-call-exp
+ :children [:arguments]
:identifier identifier
- :arguments arguments})
+ :arguments (vec arguments)})
(defn cast-exp-node [target-type e]
{:type :exp
:exp-type :cast-exp
:target-type target-type
+ :typed-inner e ; copy of e, for use in tacky phase
+ :children [:value]
:value e})
(defn unary-exp-node [op v]
{:type :exp
:exp-type :unary-exp
:unary-operator op
+ :children [:value]
:value v})
(defn binary-exp-node [l r op]
{:type :exp
:exp-type :binary-exp
:binary-operator op
+ :children [:left :right]
:left l
:right r})
@@ -79,12 +85,14 @@
{:type :exp
:exp-type :assignment-exp
:assignment-operator op
+ :children [:left :right]
:left l
:right r})
(defn conditional-exp-node [l m r]
{:type :exp
:exp-type :conditional-exp
+ :children [:left :right :middle]
:left l
:middle m
:right r})
@@ -484,7 +492,7 @@
(comment
- (m/validate
+ (pretty/explain
s/Program
(parse-from-src
"int main(void) {