Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #908

Re: precedence have both ways

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!usenet.blueworldhosting.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED!nerds-end
From glen herrmannsfeldt <gah@ugcs.caltech.edu>
Newsgroups comp.compilers
Subject Re: precedence have both ways
Date Fri, 31 May 2013 05:10:52 +0000 (UTC)
Organization Aioe.org NNTP Server
Lines 56
Sender johnl@iecc.com
Approved comp.compilers@iecc.com
Message-ID <13-05-022@comp.compilers> (permalink)
References <13-05-010@comp.compilers> <13-05-018@comp.compilers> <13-05-020@comp.compilers>
NNTP-Posting-Host news.iecc.com
X-Trace leila.iecc.com 1370027769 10061 64.57.183.58 (31 May 2013 19:16:09 GMT)
X-Complaints-To abuse@iecc.com
NNTP-Posting-Date Fri, 31 May 2013 19:16:09 +0000 (UTC)
Keywords parse, errors
Posted-Date 31 May 2013 15:16:09 EDT
X-submission-address compilers@iecc.com
X-moderator-address compilers-request@iecc.com
X-FAQ-and-archives http://compilers.iecc.com
Xref csiph.com comp.compilers:908

Show key headers only | View raw


Joe keane <jgk@panix.com> wrote:

(snip)

> This reminds me of a question.

> One person designs a language 'C1' with precedence:
>
>    [higher]
>    ...
>    |
>    &
>    <, <=, >, <=
>    ==, !=
>    ...
>    [lower]

> Some other person designs a language 'C2' with precedence:

Looks not so far from B, see:

http://cm.bell-labs.com/cm/cs/who/dmr/bref.pdf

>    [higher]
>    ...
>    <, <=, >, <=
>    ==, !=
>    |
>    &
>    ...
>    [lower]

> They're the same besides that.

> To compromise, they make a new language 'C3' such that a program is
> valid C3 if it is valid C1 and valid C2 -and- both ways mean the same.

Seems easy if you disallow the use of the operators with changed
precedence without appropriate ()'s.

> Is there some good way to do this -in the grammar-?

As above, put the restriction in the grammar.

As I understand it, not having actually ever programmed in B,
(but found the reference manual) B only had the bitwise operators,
and shared them (used them also for) the logical operators.
The had (and have) the appropriate precedence.

When C inherited them from B, and then added the && and || operators,
the previous & and | operators kept their precedence. For actual use
as bitwise operators, such as masks, it would be more convenient if
they had higher precedence. As it is, they pretty much always are
parenthesized. (Easy to forget and generate wrong results.)

-- glen

Back to comp.compilers | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Articles/books that discuss separating the context-free part of a language from the context-sensitive part? "Costello, Roger L." <costello@mitre.org> - 2013-05-17 20:57 +0000
  Re: Articles/books that discuss separating the context-free part of a language from the context-sensitive part? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2013-05-18 00:18 +0000
    Re: Articles/books that discuss separating the context-free part of a language from the context-sensitive part? Gene Wirchenko <genew@telus.net> - 2013-05-19 18:02 -0700
      Re: Articles/books that discuss separating the context-free part of a language from the context-sensitive part? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2013-05-20 03:17 +0000
  Re: Articles/books that discuss separating the context-free part of a language from the context-sensitive part? Aleksey Demakov <ademakov@gmail.com> - 2013-05-18 16:52 +0400
  Re: Articles/books that discuss separating the context-free part of a language from the context-sensitive part? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-20 10:53 +0000
    Re: Articles/books that discuss separating the context-free part of a language from the context-sensitive part? Gene Wirchenko <genew@telus.net> - 2013-05-20 23:24 -0700
    precedence have both ways jgk@panix.com (Joe keane) - 2013-05-30 23:21 -0400
      Re: precedence have both ways glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2013-05-31 05:10 +0000
      Re: precedence have both ways anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-31 10:54 +0000

csiph-web