bison yyerror() passing yylloc to errFunc() but line number is coming out as 1
git-svn-id: svn://anubis/fart/trunk@128 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
aaaac6d887
commit
76260a7696
@ -71,4 +71,6 @@ width return WIDTH;
|
|||||||
\n /* ignore newlines */
|
\n /* ignore newlines */
|
||||||
[ \t\v] /* ignore whitespace */
|
[ \t\v] /* ignore whitespace */
|
||||||
|
|
||||||
|
. return -1;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
@ -10,14 +10,13 @@
|
|||||||
#include "parser.tab.hh" /* bison-generated header with YY[SL]TYPE */
|
#include "parser.tab.hh" /* bison-generated header with YY[SL]TYPE */
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
#define yyerror(msg) errFunc(msg, &yylloc)
|
||||||
|
|
||||||
int yylex(YYSTYPE *, YYLTYPE *);
|
int yylex(YYSTYPE *, YYLTYPE *);
|
||||||
|
|
||||||
extern FILE * yyin;
|
extern FILE * yyin;
|
||||||
|
|
||||||
void yyerror(const char * str)
|
void errFunc(const char * str, YYLTYPE * yyllocp);
|
||||||
{
|
|
||||||
fprintf(stderr, "error: %s\n", str);
|
|
||||||
}
|
|
||||||
|
|
||||||
int yywrap()
|
int yywrap()
|
||||||
{
|
{
|
||||||
@ -398,6 +397,18 @@ refptr<Node> parse(const char * fileName)
|
|||||||
cerr << "Failed to open file '" << fileName << "'" << endl;
|
cerr << "Failed to open file '" << fileName << "'" << endl;
|
||||||
return refptr<Node>(NULL);
|
return refptr<Node>(NULL);
|
||||||
}
|
}
|
||||||
yyparse();
|
if (yyparse())
|
||||||
|
{
|
||||||
|
cerr << "Aborting." << endl;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
return parsed_scene_node;
|
return parsed_scene_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void errFunc(const char * str, YYLTYPE * yyllocp)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "error: %s: line %d, column %d\n",
|
||||||
|
str,
|
||||||
|
yyllocp->first_line,
|
||||||
|
yyllocp->first_column);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user