X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=expr.c;fp=expr.c;h=1d6ce38a5b9e581ef705960b1083e3e56b44f36e;hp=82bb5c6a8ccb2928d0a16256b652bb0cb7f1d0dc;hb=9153334781cd2e23750f4dc002e847606c07a1f0;hpb=81c752326a21408c84f98a18aed065491a88b779 diff --git a/expr.c b/expr.c index 82bb5c6..1d6ce38 100644 --- 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; +} +