WIP: Expression parsing
authorLukas Krickl <lukas@krickl.dev>
Sat, 18 Nov 2023 13:37:17 +0000 (14:37 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sat, 18 Nov 2023 13:37:17 +0000 (14:37 +0100)
doc/ulas.man
include/ulas.h

index 9efe7426c4480b4867291522c8075d95d2d118da..83a566b10196332bb89c326db024969b05081cda 100644 (file)
@@ -51,6 +51,22 @@ name ; will be replaced with 'value'
 .SH ASSEMBLY SYNTAX
 
 
+
+.SH EXPRESSION SYNTAX
+
+Expressions are written in Reverse Polish Notation style and evaluated based on their expected data type.
+For example when an expression expects an int type the expression will assume all values that are pushed to it 
+are integers.
+
+.SH ASSEMBLY DIRECTIVES 
+
+During assembly sometimes it is required to set certain parameters of the assembler such as the base address (represented by the $@ symbol in expressions).
+
+Valid directives:
+
+  \.org <expression>  
+    Sets the base address
+
 .SH EXAMPLES
  
 .SH SEE ALSO
index f026f2e4a3ff89466005ed074076507da806cee1..1798b3f1631606bcf4d8c947b6de681c2e1cf620 100644 (file)
@@ -218,7 +218,7 @@ struct ulas_sym {
  * -1 denotes a NULL value
  */
 
-enum ulas_exprs { ULAS_EXPUNARY, ULAS_EXPBINARY, ULAS_EXPLITERAL };
+enum ulas_exprs { ULAS_EXPUN, ULAS_EXPBIN, ULAS_EXPLIT, ULAS_EXPGRP };
 
 struct ulas_expun {
   long expr;
@@ -235,10 +235,19 @@ struct ulas_explit {
   long tok;
 };
 
+struct ulas_expgrp {
+  // points to the first expression 
+  // in this group 
+  long expr;
+  // how many expressions belong to the group
+  long len;
+};
+
 union ulas_expval {
   struct ulas_expun un;
   struct ulas_expbin bin;
   struct ulas_explit lit;
+  struct ulas_expgrp grp;
 };
 
 struct ulas_expr {