mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-25 13:11:00 +00:00
[qfcc] Implement location printing for the parsers
It's pretty bare-bones, but it's at least consistent across all the parsers, and it's currently used only by the parser debug support.
This commit is contained in:
parent
daaaeb9aed
commit
bca4d0e794
6 changed files with 32 additions and 8 deletions
|
@ -49,6 +49,21 @@ typedef struct rua_loc_s {
|
|||
int file;
|
||||
} rua_loc_t;
|
||||
|
||||
#define RUA_LOC_DEFAULT(Current, Rhs, N) \
|
||||
do if (N) { \
|
||||
(Current).line = YYRHSLOC (Rhs, 1).line; \
|
||||
(Current).column = YYRHSLOC (Rhs, 1).column; \
|
||||
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
|
||||
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
|
||||
(Current).file = YYRHSLOC (Rhs, N).file; \
|
||||
} else { \
|
||||
(Current).line = (Current).last_line = \
|
||||
YYRHSLOC (Rhs, 0).last_line; \
|
||||
(Current).column = (Current).last_column = \
|
||||
YYRHSLOC (Rhs, 0).last_column; \
|
||||
(Current).file = YYRHSLOC (Rhs, 0).file; \
|
||||
} while (0)
|
||||
|
||||
typedef struct expr_s expr_t;
|
||||
typedef struct symtab_s symtab_t;
|
||||
typedef struct function_s function_t;
|
||||
|
@ -156,6 +171,8 @@ void rua_macro_line (rua_macro_t *macro, void *scanner);
|
|||
void rua_macro_va_opt (rua_macro_t *macro, void *scanner);
|
||||
void rua_macro_va_args (rua_macro_t *macro, void *scanner);
|
||||
|
||||
void rua_print_location (FILE *out, const rua_loc_t *loc);
|
||||
|
||||
#include "tools/qfcc/source/pre-parse.h"
|
||||
|
||||
typedef struct rua_parser_s {
|
||||
|
|
|
@ -103,8 +103,8 @@ parse_error (void *scanner)
|
|||
|
||||
#define PARSE_ERROR do { parse_error (scanner); YYERROR; } while (0)
|
||||
|
||||
#define first_line line
|
||||
#define first_column column
|
||||
#define YYLLOC_DEFAULT(Current, Rhs, N) RUA_LOC_DEFAULT(Current, Rhs, N)
|
||||
#define YYLOCATION_PRINT rua_print_location
|
||||
|
||||
int yylex (YYSTYPE *yylval, YYLTYPE *yylloc);
|
||||
|
||||
|
|
|
@ -80,8 +80,8 @@ parse_error (void *scanner)
|
|||
#define PARSE_ERROR do { parse_error (scanner); YYERROR; } while (0)
|
||||
#endif
|
||||
|
||||
#define first_line line
|
||||
#define first_column column
|
||||
#define YYLLOC_DEFAULT(Current, Rhs, N) RUA_LOC_DEFAULT(Current, Rhs, N)
|
||||
#define YYLOCATION_PRINT rua_print_location
|
||||
%}
|
||||
|
||||
%code requires {
|
||||
|
|
|
@ -2408,3 +2408,10 @@ rua_macro_va_args (rua_macro_t *macro, void *scanner)
|
|||
macro->tail = arg->tail;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rua_print_location (FILE *out, const rua_loc_t *loc)
|
||||
{
|
||||
fprintf (out, "%s:[%d.%d-%d.%d]", GETSTR (loc->file),
|
||||
loc->line, loc->column, loc->last_line, loc->last_column);
|
||||
}
|
||||
|
|
|
@ -103,8 +103,8 @@ parse_error (void *scanner)
|
|||
|
||||
#define PARSE_ERROR do { parse_error (scanner); YYERROR; } while (0)
|
||||
|
||||
#define first_line line
|
||||
#define first_column column
|
||||
#define YYLLOC_DEFAULT(Current, Rhs, N) RUA_LOC_DEFAULT(Current, Rhs, N)
|
||||
#define YYLOCATION_PRINT rua_print_location
|
||||
|
||||
int yylex (YYSTYPE *yylval, YYLTYPE *yylloc);
|
||||
|
||||
|
|
|
@ -84,8 +84,8 @@ parse_error (void *scanner)
|
|||
|
||||
#define PARSE_ERROR do { parse_error (scanner); YYERROR; } while (0)
|
||||
|
||||
#define first_line line
|
||||
#define first_column column
|
||||
#define YYLLOC_DEFAULT(Current, Rhs, N) RUA_LOC_DEFAULT(Current, Rhs, N)
|
||||
#define YYLOCATION_PRINT rua_print_location
|
||||
|
||||
int yylex (void);
|
||||
|
||||
|
|
Loading…
Reference in a new issue