Re: How to tell the difference bewteen comparing and assigning

new topic     » goto parent     » topic index » view thread      » older message » newer message

On  0, stabmaster_ at HOTMAIL.COM wrote:
> 
> One way to spot comparisons (although it probably doesn't cover _all_ 
> possible comparisons) are when '=' is used after 'if' or 'while'
> 
> if 1=0 then...
> 
> while 0=1 do...
> 
> etc.
> 

Aside from not covering all situations, what do i do about this:

if a > b then a = b else b = a end if

i could try looking only between the "if" and "then" tokens (and ditto
for
while..do) but it would be hard to do that for all possible situations:

?(a=b) --check for (
?a[b=b] --check for [
? a=b --check for ?
a = a = b --check for previous =
etc etc etc

as there are too many exceptions and to make a parser which takes care
of this
cleanly would be quite difficult. i was thinking about making my
preprocessor
use == for comparision and := for assignment and ignore the = sign
completely.
(Perhaps even make the = sign an illegal token, although that would be
going
to the extreme.) I'd prefer not to do that however, so if you or anyone
else
has an idea on how this could be done, it would be greatly appreciated.

TIA,
jbrown



-- 
http://fastmail.fm
Quick as a click

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu