diff --git a/src/rustint/core.clj b/src/rustint/core.clj index 4f1a273..f456c29 100644 --- a/src/rustint/core.clj +++ b/src/rustint/core.clj @@ -2097,10 +2097,33 @@ ; [; (fn main ( ) { println! ( "{}" , TRES ) }) [use std :: io ; const TRES : i64 = 3] :sin-errores [[0] [[io [lib ()] 0] [TRES [const i64] 3]]] 0 [[CAL 0] HLT] []] ; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defn maxnil [a1 a2] + (cond + (and (nil? a1) (nil? a2)) nil + (nil? a1) a2 + (nil? a2) a1 + :else (max a1 a2) + ) +) + +(defn last_const_idx [seq] + (reduce maxnil (map-indexed (fn [idx itm] (if itm idx nil)) (map #(= 'const %1) seq))) +) + (defn cargar-const-en-tabla [amb] (cond - (not= (get amb 4) :sin-errores) amb - :else nil + (not= (get amb 3) :sin-errores) amb + :else (let [ + syp (get amb 2), + ctx (get amb 4), + idx_const (last_const_idx syp), + const_name (get syp (+ 1 idx_const)), + const_type (get syp (+ 3 idx_const)), + const_value (get syp (+ 5 idx_const)), + ] + (assoc-in amb [4 1 1] [const_name ['const const_type] const_value]) + ) ) )