Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.compilers > #2143
| Path | csiph.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end |
|---|---|
| From | Philipp Klaus Krause <pkk@spth.de> |
| Newsgroups | comp.compilers |
| Subject | Why do some versions of bison require {} here? |
| Date | Tue, 1 Jan 2019 10:55:11 +0100 |
| Organization | solani.org |
| Lines | 54 |
| Sender | news@iecc.com |
| Approved | comp.compilers@iecc.com |
| Message-ID | <19-01-001@comp.compilers> (permalink) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Info | gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="31599"; mail-complaints-to="abuse@iecc.com" |
| Keywords | yacc, question, comment |
| Posted-Date | 01 Jan 2019 12:16:08 EST |
| X-submission-address | compilers@iecc.com |
| X-moderator-address | compilers-request@iecc.com |
| X-FAQ-and-archives | http://compilers.iecc.com |
| Content-Language | en-US |
| Xref | csiph.com comp.compilers:2143 |
Show key headers only | View raw
In SDCC.y, there are rules:
program
: external_definition
| program external_definition
;
external_definition
: function_definition
{
// blockNo = 0;
}
| declaration
{
ignoreTypedefType = 0;
if ($1 && $1->type && IS_FUNC($1->type))
{
/* The only legal storage classes for
* a function prototype (declaration)
* are extern and static. extern is the
* default. Thus, if this function isn't
* explicitly marked static, mark it
* extern.
*/
if ($1->etype && IS_SPEC($1->etype) && !SPEC_STAT($1->etype))
{
SPEC_EXTR($1->etype) = 1;
}
}
addSymChain (&$1);
allocVariables ($1);
cleanUpLevel (SymbolTab, 1);
}
| addressmod
;
which has always worked for me without problems on all yacc / bison I
tried. But sporadically, users reported that this failed for them, and
they had to change the last two lines to:
| addressmod
{
}
;
for their yacc / bison to accept the rule.
What is happening here? Why is the {} required? Why only on the last
rule, while the first one is okay?
Philipp
[Adding the empty action forces bison to reduce the rule rather than just
shifting and saving state for later. I couldn't guess why that would matter
in this case. Are there precedence rules? With your change does the grammar compile
cleanly or does it have conflicts? -John]
Back to comp.compilers | Previous | Next — Next in thread | Find similar | Unroll thread
Why do some versions of bison require {} here? Philipp Klaus Krause <pkk@spth.de> - 2019-01-01 10:55 +0100
Re: Why do some versions of bison require {} here? Kaz Kylheku <157-073-9834@kylheku.com> - 2019-01-02 19:29 +0000
Re: Why do some versions of bison require {} here? Philipp Klaus Krause <pkk@spth.de> - 2019-01-03 09:15 +0100
Re: Why do some versions of bison require {} here? Kaz Kylheku <157-073-9834@kylheku.com> - 2019-01-04 03:02 +0000
csiph-web