[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to raise an error
From: |
Mike Aubury |
Subject: |
Re: How to raise an error |
Date: |
Fri, 9 Oct 2009 19:25:53 +0100 |
Why not something like :
identifier:
LOCALIDENTIFIER {
$$ = CreateIdentifierNode(yytext);
if ($$== NULL) {
YYERROR;
}
}
Then just get your CreateIdentifierNode to return NULL if its invalid..
(You can play with setting an error buffer string to set the actual
error message etc..)
In my code - I tend to do something like :
LOCALIDENTIFIER {
char errbuff[256];
$$ = CreateIdentifierNode(yytext,errbuff);
if ($$== NULL) {
yyerror(errbuff);
YYERROR;
}
}
Where CreateIdentifierNode sets 'errbuff' when "CreateIdentifierNode"
returns NULL..
2009/10/9 BradDaBug <address@hidden>:
>
> My parser basically works by calling various functions that build a big parse
> tree. Something like this:
>
> identifier:
> LOCALIDENTIFIER { $$ = CreateIdentifierNode(yytext); }
>
> The problem is that I need to be able to detect errors within those
> functions (for example, is the identifier name too long) and propagate them
> back to Bison. But I don't know how. I don't have access to the YYERROR
> macro in those functions, and I can't manually "goto yyerrorlab;" since I'm
> in a different function.
>
> How can I do it?
> --
> View this message in context:
> http://www.nabble.com/How-to-raise-an-error-tp25824253p25824253.html
> Sent from the Gnu - Bison - Help mailing list archive at Nabble.com.
>
>
>
> _______________________________________________
> address@hidden http://lists.gnu.org/mailman/listinfo/help-bison
>