WIP: preprocessor
authorLukas Krickl <lukas@krickl.dev>
Sun, 5 Nov 2023 13:50:10 +0000 (14:50 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sun, 5 Nov 2023 13:50:10 +0000 (14:50 +0100)
README.md
doc/ulas.man
include/ulas.h
src/ulas.c

index f4b21f379af2e2924c01c7b2b36d5da14ad8d3e4..7d014709a815172cbabf9a260c487cfe58175d0c 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 # ulas
 
-Unlink's light assembler is a C99 assembler for the 6502 without any external dependencies.
+Unlink's light assembler is a C99 assembler without any external dependencies.
 
 ## Table of content
 
index f7dbcdbe3a0f45ae8238e534adf1ffe0f0f22b88..d168766565490ea44755e78461652a68a20ed514 100644 (file)
   -v, --verbose             
     verbose output
  
-.SH SYNTAX
+.SH PREPROCESSOR 
+
+The preprocessor is a text based way of modifying the input before 
+the assembly step.
+
+Withing preprocessor macros 
+- $0 will expand to the literal argument string 
+- $1 to $9 will expand to the comma separated arguments of the macro 
+- $$ will expand to an internal macro call counter which can be used to make labels 
+  that are expanded by a macro unique.
+
+Macros:
+
+#macro 
+label$$:
+  adc $1, $2
+#endm
+
+.SH ASSEMBLY SYNTAX
 
 
 
index cecc23c425d50edae265f4a4bea7a53f897a2319..870fa2b21d08d9c843d7f2055a1f37f91059282c 100644 (file)
@@ -72,6 +72,23 @@ struct ulas_tok {
   union ulas_tokdat dat;
 };
 
+enum ulas_ppdirs {
+  ULAS_PP_DEF,
+  ULAS_PP_MACRO,
+};
+
+struct ulas_ppdir {
+  enum ulas_ppdirs type;
+};
+
+/**
+ * Symbols
+ */
+
+struct ulas_sym {
+  const char *name;
+};
+
 /**
  * Expressions
  */
@@ -113,6 +130,11 @@ void ulas_init(struct ulas_config cfg);
 
 int ulas_main(struct ulas_config cfg);
 
+/**
+ * Tokenize and apply the preprocessor
+ */
+int ulas_preproc(FILE *dst, FILE *src);
+
 char *ulas_strndup(const char *src, size_t n);
 
 #endif
index ee6c2997a120c8c841e95a06daefc9dd0c4e5268..24ed9d38f751d682ed78d319ccaddaa1a51512e2 100644 (file)
@@ -54,3 +54,5 @@ int ulas_main(struct ulas_config cfg) {
 
   return 0;
 }
+
+int ulas_preproc(FILE *dst, FILE *src) {}