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


Groups > comp.compilers > #2638

Re: "Bootstrapping yacc in yacc" -> "Bootstrapping yacc in lex"!

Path csiph.com!xmission!usenet.csail.mit.edu!news.iecc.com!.POSTED.news.iecc.com!nerds-end
From Kaz Kylheku <563-365-8930@kylheku.com>
Newsgroups comp.compilers
Subject Re: "Bootstrapping yacc in yacc" -> "Bootstrapping yacc in lex"!
Date Mon, 15 Mar 2021 02:37:16 -0000 (UTC)
Organization A noiseless patient Spider
Lines 47
Sender news@iecc.com
Approved comp.compilers@iecc.com
Message-ID <21-03-005@comp.compilers> (permalink)
References <21-03-004@comp.compilers>
Injection-Info gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="83188"; mail-complaints-to="abuse@iecc.com"
Keywords yacc
Posted-Date 15 Mar 2021 11:52:38 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:2638

Show key headers only | View raw


On 2021-03-15, Rock Brentwood <rockbrentwood@gmail.com> wrote:
> It's a recurrent question that's come up in other forums "can yacc be
> bootstrapped in yacc?" Now, I'm adding a twist.
>
> I'll repeat one of my recent replies here. In the syntax for yacc files, laid
> out by the POSIX standard, there is no mandatory semi-colon at the ends of
> rules, so an extra look-ahead is required to determine whether an identifier
> is followed by a colon. If so, then this indicates the left-hand side of a new
> rule.
>
> A grammar rule has the form
>
> left-hand-side ":" stuff on the right optional ";"'s.
>
> If you see a ":" in the middle of the rules on the right, then you've actually
> sneaked on over into the *next* rule.
>
> Bison hacks the syntax, by making left-hand-side + ":" into a single token.

You could simply allow rules of this form

  ":" right side ...


With a semantic restrction that this must be preceded by a rule that
is not terminated with a semicolon, whose last element is a symbol:

  blah ":" previous rule material ending in symbol /* no semicolon */

  ":" next rule ";"

Then we make the AST transformation of moving "symbol" to be the head
of the following rule:

  -->


  blah ":" previous rule material ending in

  symbol ":" next rule ";"

Situations where it's not a symbol, or the prior rule has ended in
a semicolon (which is thus followed by a colon) are not syntax
errors, but are diagnosed semantically.
--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Back to comp.compilers | Previous | NextPrevious in thread | Find similar


Thread

"Bootstrapping yacc in yacc" -> "Bootstrapping yacc in lex"! Rock Brentwood <rockbrentwood@gmail.com> - 2021-03-14 17:54 -0700
  Re: "Bootstrapping yacc in yacc" -> "Bootstrapping yacc in lex"! Kaz Kylheku <563-365-8930@kylheku.com> - 2021-03-15 02:37 +0000

csiph-web