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


Groups > comp.compilers > #1712

Re: precedences vs. hierarchy

From federation2005@netzero.com
Newsgroups comp.compilers
Subject Re: precedences vs. hierarchy
Date 2016-06-06 14:01 -0700
Organization Compilers Central
Message-ID <16-06-006@comp.compilers> (permalink)
References <16-06-001@comp.compilers>

Show all headers | View raw


On Monday, June 6, 2016 at 7:35:45 AM UTC-5, Andreas Schramm wrote:
> (i) by precedence and associativity declarations, and
> (ii) by a hierarchy of non-terminals.
> are they equally respected approaches?

The latter is strictly more powerful than the former. In particular,
hierarchies can be circular or out of sequence, like the expression syntax in
C! Levels "Ex13" and "Ex14" here
https://www.scribd.com/doc/235318907/Combined-Syntax-for-C-90-C-99-and-C-11

Fortran used a the same approach as classical philology textbooks on language
in the 1950's and 1966; then went over to a kind of precedence syntax in the
1977 standard. I think the latest standard uses non-terminal tagging.

Prolog's expression syntax is non-terminal tagged (the "term" is the only real
non-terminal in the language).

From the vantage point of a parser -- seen as a PDT -- the thing you actually
want is a way to do relative comparisons with a finite lookahead sequence (of
typically just one token) versus your current context. So in fact, neither
approach described is actually the best, but one which has an "Action Table"
that plots contexts versus lookaheads (subcategorizing each into groups to
avoid duplicate rows and columns). When a context is favored you reduce you
carry out the action predicated on it (usually a reduce), while when a
lookahead is favored you carry out the action predicated on it (normally a
shift).

If you diagram the table like a quilt or tapestry, so that a vertical line
(and broken horizontal line woven "underneath" it) favors the column header,
while a horizontal line (and broken vertical line woven "underneath" it)
favors the row header, then a linearly-ordered hierarchy will show up as a
regular pattern in the tapestry. with horizontal lines dominating on a side
toward one of the corners of the weave, while the vertical lines dominate on
the opposite end.

The hierarchy tacit in the action table need not be linearly ordered at all
but can be twisted and knotted, even transcending what can be described by a
labeling of non-terminals. So this way is strictly more powerful than either
of the two methods described.

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


Thread

precedences vs. hierarchy Andreas Schramm <bassobajo@gmail.com> - 2016-06-06 09:08 +0200
  Re: precedences vs. hierarchy "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2016-06-06 17:08 +0200
    Re: precedences vs. hierarchy Kaz Kylheku <545-066-4921@kylheku.com> - 2016-06-07 15:35 +0000
      Re: precedences vs. hierarchy "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2016-06-07 22:53 +0200
      Re: precedences vs. hierarchy anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-08 09:48 +0000
  Re: precedences vs. hierarchy George Neuner <gneuner2@comcast.net> - 2016-06-06 12:35 -0400
  Re: precedences vs. hierarchy federation2005@netzero.com - 2016-06-06 14:01 -0700
    Example: The Full Syntax Of Prolog (Re: precedences vs. hierarchy) rockbrentwood@gmail.com - 2016-08-24 15:45 -0700

csiph-web