Added sessions to gitignore
authorLukas Krickl <lukas@krickl.dev>
Sun, 19 Nov 2023 05:32:44 +0000 (06:32 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sun, 19 Nov 2023 05:32:44 +0000 (06:32 +0100)
.gitignore
include/ulas.h
src/test.c
src/ulas.c

index cbd3711eea8430cfe802782d6829b33ea1d8ef07..383f6c348499cea60a32c80d665e228b61324948 100644 (file)
@@ -61,4 +61,4 @@ compile_commands.json
 .cache/
 .clang_complete
 .clangd
-
+.session
index ac48b3fa4f841f18eb7075432fe8c74a1c8234a7..950711c24798bb9e60567cb2be08583f55eed397 100644 (file)
@@ -7,6 +7,7 @@
 
 #define ULAS_PATHMAX 4096
 #define ULAS_LINEMAX 4096
+#define ULAS_MACROPARAMMAX 9
 
 #define MAX(x, y) (((x) > (y)) ? (x) : (y))
 #define MIN(x, y) (((x) < (y)) ? (x) : (y))
@@ -91,12 +92,7 @@ struct ulas_str {
 
 // any token before 256 is just the literal char value
 // primitive data types
-enum ulas_type {
-
-  ULAS_SYMBOL = 256,
-  ULAS_INT,
-  ULAS_STR
-};
+enum ulas_type { ULAS_SYMBOL = 256, ULAS_INT, ULAS_STR };
 
 // data type value
 union ulas_val {
@@ -177,8 +173,6 @@ struct ulas_ppdef {
   int undef;
 };
 
-#define ULAS_MACROPARAMMAX 9
-
 struct ulas_preproc {
   struct ulas_ppdef *defs;
   unsigned long defslen;
@@ -279,6 +273,10 @@ int ulas_main(struct ulas_config cfg);
 
 char *ulas_strndup(const char *src, unsigned long n);
 
+// resolve a symbol until an actual literal token (str, int) is found
+// returns NULL if the symbol cannot be resolved
+struct ulas_tok *ulas_symbolresolve(const char *name);
+
 // tokenisze according to pre-defined rules
 // returns the amount of bytes of line that were
 // consumed or -1 on error
index 65589b9fdea359df939a2d90e06305b110f372f4..61b83ceac7bc29af2908574f0426a48fbc4b1119 100644 (file)
@@ -147,8 +147,8 @@ void test_preproc(void) {
     int rc = 0;                                                                \
     struct ulas_tok tok = ulas_totok((token), strlen(token), &rc);             \
     assert((expected_rc) == rc);                                               \
-    assert(tok.type == ULAS_INT);                                          \
-    assert(tok.val.intv == (expected_val));                                \
+    assert(tok.type == ULAS_INT);                                              \
+    assert(tok.val.intv == (expected_val));                                    \
   }
 
 #define ASSERT_STR_TOTOK(expected_val, expected_rc, token)                     \
@@ -156,9 +156,9 @@ void test_preproc(void) {
     int rc = 0;                                                                \
     struct ulas_tok tok = ulas_totok((token), strlen(token), &rc);             \
     assert((expected_rc) == rc);                                               \
-    assert(tok.type == ULAS_STR);                                          \
-    assert(strcmp((expected_val), tok.val.strv) == 0);                     \
-    free(tok.val.strv);                                                    \
+    assert(tok.type == ULAS_STR);                                              \
+    assert(strcmp((expected_val), tok.val.strv) == 0);                         \
+    free(tok.val.strv);                                                        \
   }
 
 #define ASSERT_SYMBOL_TOTOK(expected_val, expected_rc, token)                  \
@@ -166,9 +166,9 @@ void test_preproc(void) {
     int rc = 0;                                                                \
     struct ulas_tok tok = ulas_totok((token), strlen(token), &rc);             \
     assert((expected_rc) == rc);                                               \
-    assert(tok.type == ULAS_SYMBOL);                                        \
-    assert(strcmp((expected_val), tok.val.strv) == 0);                     \
-    free(tok.val.strv);                                                    \
+    assert(tok.type == ULAS_SYMBOL);                                           \
+    assert(strcmp((expected_val), tok.val.strv) == 0);                         \
+    free(tok.val.strv);                                                        \
   }
 
 #define ASSERT_UNEXPECTED_TOTOK(expected_rc, token)                            \
index 486fc0631697c0a98d091dabcd812317e39bb229..e61dbc0850049c7b45642dc2470e050fe2c18988 100644 (file)
@@ -124,6 +124,11 @@ int ulas_isname(const char *tok, unsigned long n) {
   return 1;
 }
 
+struct ulas_tok *ulas_symbolresolve(const char *name) {
+  // TODO: implement
+  return NULL;
+}
+
 #define WELD_TOKISTERM write
 #define WELD_TOKCOND (i < n && write < n && line[i])
 
@@ -904,8 +909,7 @@ void ulas_tokbufpush(struct ulas_tokbuf *tb, struct ulas_tok tok) {
 void ulas_tokbufclear(struct ulas_tokbuf *tb) {
   for (long i = 0; i < tb->len; i++) {
     struct ulas_tok *t = &tb->buf[i];
-    if (t->type == ULAS_SYMBOL ||
-        t->type == ULAS_STR) {
+    if (t->type == ULAS_SYMBOL || t->type == ULAS_STR) {
       free(t->val.strv);
     }
   }