X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=expr.c;h=1d6ce38a5b9e581ef705960b1083e3e56b44f36e;hp=b86111bd579769168ecad264fb1d087f57b02ba8;hb=9153334781cd2e23750f4dc002e847606c07a1f0;hpb=29b32d134bc12831a8ddd098bf9aeeda26dcfe7c diff --git a/expr.c b/expr.c index b86111b..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; +} +