Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.compilers > #651
| From | James Harris <james.harris.1@gmail.com> |
|---|---|
| Newsgroups | comp.compilers |
| Subject | Re: Yacc/Bison - what semantic actions to take on a parse error |
| Date | 2012-05-24 22:49 -0700 |
| Organization | Compilers Central |
| Message-ID | <12-05-022@comp.compilers> (permalink) |
| References | <12-05-014@comp.compilers> <12-05-021@comp.compilers> |
On May 24, 8:05 pm, James Harris <james.harri...@gmail.com> wrote:
...
> The issue is that the error production cannot create a meaningful node
> so what actions to replace ACTION are appropriate? Here are some
> options.
>
> * Create an X node with dummy values. That would satisfy the type
> checking.
> * Set $<err_msg>$ = "invalid X node"
> * Braces but no action, i.e. {}
> * No action clause so default to $$ = $1;
> * Some combination of YYERROR; and yyerror();
...
> http://www.gnu.org/software/bison/manual/html_node/Action-Features.html
>
> So, which option is 'best'? Or should we just ignore a type mismatch
> error?
> [You already know you ran into a syntax error, so I'd think that type
> checking is more likely to produce an error cascade than something
> useful. -John]
It sounds like you might be referring to type checking in the
compiler's later semantic analysis phase. I was asking about the
checking for a type match that the Yacc/Bison build process carries
out.
For example, if we leave the default action $$ = $1 in an error
production the parser creation process might report something like
$1 of 'X' has no declared type
or, if we set $$ to a dummy
error: cannot convert dummy_class* to X_class* in assignment
James
[Ah, that, right. If it were going to try to use the parse tree, I'd
create a dummy node, otherwise { $$ = NULL; } -John]
Back to comp.compilers | Previous | Next — Previous in thread | Next in thread | Find similar
Yacc/Bison - what semantic actions to take on a parse error James Harris <james.harris.1@gmail.com> - 2012-05-23 04:19 -0700
Re: Yacc/Bison - what semantic actions to take on a parse error James Harris <james.harris.1@gmail.com> - 2012-05-24 12:05 -0700
Re: Yacc/Bison - what semantic actions to take on a parse error James Harris <james.harris.1@gmail.com> - 2012-05-24 22:49 -0700
Re: Yacc/Bison - what semantic actions to take on a parse error Chris F Clark <cfc@shell01.TheWorld.com> - 2012-05-30 14:41 -0400
csiph-web