Skip to content

Commit

Permalink
ansic.y: eliminate line and column global vars
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCount committed Mar 1, 2022
1 parent fe1a87d commit f02db90
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions test/compare_parsers/ansic.y
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

%{
#define YYSTYPE string_t

void yyerror (char *s);
%}

%pure-parser
Expand Down Expand Up @@ -470,11 +472,28 @@ identifier

#include <stdio.h>

extern int column;
extern int line;

yyerror(s)
char *s;
void
yyerror (char *s)
{
fprintf (stderr, "syntax error line - %d, column - %d\n", line, column + 1);
int line, column;

if (curr == NULL)
{
curr = list;
}
else
{
curr = curr->next;
}
if (curr == NULL)
{
line = -1;
column = -1;
}
else
{
line = curr->line;
column = curr->column;
}
fprintf (stderr, "syntax error line - %d, column - %d\n", line, column + 1);
}

0 comments on commit f02db90

Please sign in to comment.