fixed location issues for error messages and scoping. Used location macros and the percent location as defined in guides to track location. Code may warrant cleanup as we don't need to manually keep track of locations ourselves any more through our line and column number variables
This commit is contained in:
@ -14,7 +14,8 @@
|
||||
extern int column_number;
|
||||
extern FILE * yyin;
|
||||
%}
|
||||
|
||||
//%define api.location.type {location_t}
|
||||
%locations
|
||||
%union {
|
||||
int integ;
|
||||
char * words;
|
||||
@ -123,8 +124,8 @@ idlist:
|
||||
;
|
||||
|
||||
sblock:
|
||||
L_BRACE {column_number += yyleng; cur = CreateScope(cur,line_number,column_number);} statement_list {cur = getParent(cur);} R_BRACE
|
||||
| L_BRACE {column_number += yyleng; cur = CreateScope(cur,line_number,column_number);} dblock statement_list {cur = getParent(cur);} R_BRACE
|
||||
L_BRACE {cur = CreateScope(cur,@1.first_line,@1.first_column);} statement_list {cur = getParent(cur);} R_BRACE
|
||||
| L_BRACE {cur = CreateScope(cur,@1.first_line,@1.first_column);} dblock statement_list {cur = getParent(cur);} R_BRACE
|
||||
;
|
||||
|
||||
dblock:
|
||||
@ -225,7 +226,7 @@ types:
|
||||
%%
|
||||
|
||||
void yyerror(const char *err) {
|
||||
fprintf(stderr, "ERROR: %s at token %s at line number %d,column number %d\n", err,yytext,line_number,column_number);
|
||||
fprintf(stderr, "ERROR: %s at token %s at line number %d,column number %d\n", err,yytext,yylloc.first_line,yylloc.first_column);
|
||||
}
|
||||
/*
|
||||
int main(int argc, char * argv[]) {
|
||||
|
Reference in New Issue
Block a user