1. RE: How to tell the difference bewteen comparing and assigning

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.


Why don't you use David Cuny's OX to write your
preprocessor, That will make things a lot easier.

Bernie

new topic     » topic index » view message » categorize

2. RE: How to tell the difference bewteen comparing and assigning

jbrown105 at speedymail.org wrote:
> 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.

Why don't you download Dave Cuny's Py interpreter 
and see how he did it? 
IIRC it uses = as both an assignment operator and 
a comparison operator. For atoms AND sequences.

Regards,
Irv

new topic     » goto parent     » topic index » view message » categorize

3. RE: How to tell the difference bewteen comparing and assigning

irv at take.maxleft.com wrote:
> 
> jbrown105 at speedymail.org wrote:
> > 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.
> 
> Why don't you download Dave Cuny's Py interpreter 
> and see how he did it? 
> IIRC it uses = as both an assignment operator and 
> a comparison operator. For atoms AND sequences.
> 
> Regards,
> Irv

AFAIK, Py is a complete language, which parses and processes every token 
of code.

I'm pretty sure James is trying to avoid doing that.

My preprocessor also parses and processes every token of code. I don't 
see any other way of being able to accurately determine if = is an 
assignment or operator.

Ox might be a good solution.


Chris

new topic     » goto parent     » topic index » view message » categorize

4. RE: How to tell the difference bewteen comparing and assigning

irv at take.maxleft.com wrote:
> 
> jbrown105 at speedymail.org wrote:
> > 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.
> 
> Why don't you download Dave Cuny's Py interpreter 
> and see how he did it? 
> IIRC it uses = as both an assignment operator and 
> a comparison operator. For atoms AND sequences.
> 
> Regards,
> Irv

AFAIK, Py is a complete language, which parses and processes every token 
of code.

I'm pretty sure James is trying to avoid doing that.

My preprocessor also parses and processes every token of code. I don't 
see any other way of being able to accurately determine if = is an 
assignment or operator.

Ox might be a good solution.


Chris

new topic     » goto parent     » topic index » view message » categorize

5. RE: How to tell the difference bewteen comparing and assigning

Chris Bensler wrote:
> 
> irv at take.maxleft.com wrote:
> > 
> > jbrown105 at speedymail.org wrote:
> > > 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.
> > 
> > Why don't you download Dave Cuny's Py interpreter 
> > and see how he did it? 
> > IIRC it uses = as both an assignment operator and 
> > a comparison operator. For atoms AND sequences.
> > 
> > Regards,
> > Irv
> 
> AFAIK, Py is a complete language, which parses and processes every token 
> 
> of code.
> 
> I'm pretty sure James is trying to avoid doing that.
> 
> My preprocessor also parses and processes every token of code. I don't 
> see any other way of being able to accurately determine if = is an 
> assignment or operator.

You can't. The token '=' must be semantically checked in context. If the 
token is immediately preceded by an identifer-reference AND that 
references a variable AND that identifier is at the beginning of a 
statement, then the '=' is an assignment, othewrwise is is a equality 
comparision.

It is unfortunate that RDS choose '=' to mean two different things 
depending on where it is placed in the source code, but Euphoria is not 
alone in that regard. 

As an aside, I've often thought that '?=' is a good token for equality 
comparision and ':=' for assignment - but I'm probably out numbered blink

--------
Derek.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu