Re: Implementing an "in" operator

"Ed Davis" <>
26 Nov 2002 22:11:43 -0500

          From comp.compilers

Related articles
Implementing an "in" operator (Ed Davis) (2002-11-13)
Re: Implementing an "in" operator (Charles Bryant) (2002-11-20)
Re: Implementing an "in" operator (Steve Siegfried) (2002-11-24)
Re: Implementing an "in" operator (Ed Davis) (2002-11-26)
| List of all articles for this month |

From: "Ed Davis" <>
Newsgroups: comp.compilers
Date: 26 Nov 2002 22:11:43 -0500
References: 02-11-079 02-11-127
Keywords: design, comment
Posted-Date: 26 Nov 2002 22:11:43 EST

"Steve Siegfried" <> wrote in message news:02-11-127...

> Parsing this then becomes following the BNF (which I'm sure your
> professor gave you when he assigned the problem) and generating the IR

I graduated from college over 20 years ago. Pascal wasn't taught at
my university at that time. We used something called Algol-Z, which
was our (slightly) customized implementation of Wirth's Algol-W. It
did not have sets, or an "in" operator. And yes, I still have my
limited edition (a collectors item? <grin>), December 1976 copy of the
"Algol W Users Guide".

> Thus the whole trick behind implementing sets in a compiler is not in
> the operators, but in the internal representation of sets and
> set-constants.

My language does not feature "sets".


int a, b, c, d, e

if (a in b,c..d,e)

I don't see how this fits with what you were saying. Of course I could
be wrong, and would be glad to be so, as your idea did appear simpler
than what I have come up with so far.
[Even though your language doesn't feature sets, your "in" operator is a
set membership test. "b,c..d,e" is a set, the "in" checks whether a is
in the set. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.