[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
glr & locations
From: |
Claudia Hermann |
Subject: |
glr & locations |
Date: |
Fri, 28 Oct 2005 21:26:40 +0200 |
User-agent: |
Mozilla Thunderbird 1.0.2 (Windows/20050317) |
hi all,
i have a parser with glr activated and use the location tracking
function. every things works fine as long as i don't use ambiguous rules
where i have to choose between with '%dprec'. additionally i have an
optional nonterminal at the beginning of the rule. in this special case
i get undefined values for the optional nonterminal as well as for the
whole rule. In all other rules an empty nonterminal gets the location
from the previous node.
i compiled the attached example with bison 2.1 and gcc 3.4.2. my system
is freebsd 5.3 on i386. previously i also tried to compile with bison
2.0, but with the same result.
when i execute this program, i get the following column locations for
the 3 nodes:
0/4 - 671435522/671435522 - 6/8
but i would expect following result:
0/4 - 4/4 - 6/8
is this a bison bug or is there only any error in my code?
if this is a bug, does there any patch exist?
regards,
claudia hermann
%{
static void yyerror(const char *msg);
int i = 0;
%}
%token T_CONSTANT
%token T_PORT
%token T_SIGNAL
%glr-parser
%%
PortClause : T_PORT InterfaceDeclaration T_PORT
{ printf("%d/%d - %d/%d - %d/%d\n", @1.first_column,
@1.last_column, @2.first_column, @2.last_column, @3.first_column,
@3.last_column); }
;
InterfaceDeclaration : OptConstantWord %dprec 1
| OptSignalWord %dprec 2
;
OptConstantWord : /* empty */
| T_CONSTANT
;
OptSignalWord : /* empty */
{ printf("empty: %d/%d\n", @$.first_column, @$.last_column); }
| T_SIGNAL
;
%%
static void yyerror(const char *msg) {
fprintf (stderr, "error\n");
}
int yylex() {
if (i == 0) {
yylloc.first_column = 0;
yylloc.last_column = 4;
i++;
return T_PORT;
}
if (i == 1) {
yylloc.first_column = 6;
yylloc.last_column = 8;
i++;
return T_PORT;
}
return 0;
}
int main (int argc, const char *argv[]) {
yyparse();
return 0;
}
- glr & locations,
Claudia Hermann <=