]> Shamusworld >> Repos - rmac/blobdiff - expr.c
Partial fix for bug #108 (Fixup cleanups).
[rmac] / expr.c
diff --git a/expr.c b/expr.c
index 82bb5c6a8ccb2928d0a16256b652bb0cb7f1d0dc..1d6ce38a5b9e581ef705960b1083e3e56b44f36e 100644 (file)
--- a/expr.c
+++ b/expr.c
@@ -1,7 +1,7 @@
 //
 // RMAC - Reboot's Macro Assembler for all Atari computers
 // EXPR.C - Expression Analyzer
-// Copyright (C) 199x Landon Dyer, 2011-2017 Reboot and Friends
+// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends
 // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
 // Source utilised with the kind permission of Landon Dyer
 //
@@ -1066,3 +1066,27 @@ An open question here is do we promote ints to floats as signed or unsigned? It
        return OK;
 }
 
+
+//
+// Count the # of tokens in the passed in expression
+// N.B.: 64-bit constants count as two tokens each
+//
+uint16_t ExpressionLength(TOKEN * tk)
+{
+       uint16_t length;
+
+       for(length=0; tk[length]!=ENDEXPR; length++)
+       {
+               // Add one to length for 2X tokens, two for 3X tokens
+               if (tk[length] == SYMBOL)
+                       length++;
+               else if ((tk[length] == CONST) || (tk[length] == FCONST))
+                       length += 2;
+       }
+
+       // Add 1 for ENDEXPR
+       length++;
+
+       return length;
+}
+