mirror of https://github.com/omar-polo/gmid.git
move lineno/colno into the token struct
This commit is contained in:
parent
74f0778b9a
commit
ef129b08ef
47
parse.y
47
parse.y
|
@ -27,6 +27,16 @@
|
||||||
|
|
||||||
FILE *yyfp;
|
FILE *yyfp;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
union {
|
||||||
|
char *str;
|
||||||
|
int num;
|
||||||
|
};
|
||||||
|
int lineno;
|
||||||
|
int colno;
|
||||||
|
} yystype;
|
||||||
|
#define YYSTYPE yystype
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* #define YYDEBUG 1
|
* #define YYDEBUG 1
|
||||||
* int yydebug = 1;
|
* int yydebug = 1;
|
||||||
|
@ -36,7 +46,6 @@ struct vhost *host;
|
||||||
struct location *loc;
|
struct location *loc;
|
||||||
|
|
||||||
static int goterror;
|
static int goterror;
|
||||||
static int lineno, colno;
|
|
||||||
|
|
||||||
static struct vhost *new_vhost(void);
|
static struct vhost *new_vhost(void);
|
||||||
static struct location *new_location(void);
|
static struct location *new_location(void);
|
||||||
|
@ -61,11 +70,6 @@ void add_param(char *, char *, int);
|
||||||
/* for bison: */
|
/* for bison: */
|
||||||
/* %define parse.error verbose */
|
/* %define parse.error verbose */
|
||||||
|
|
||||||
%union {
|
|
||||||
char *str;
|
|
||||||
int num;
|
|
||||||
}
|
|
||||||
|
|
||||||
%token TIPV6 TPORT TPROTOCOLS TMIME TDEFAULT TTYPE TCHROOT TUSER TSERVER
|
%token TIPV6 TPORT TPROTOCOLS TMIME TDEFAULT TTYPE TCHROOT TUSER TSERVER
|
||||||
%token TPREFORK TLOCATION TCERT TKEY TROOT TCGI TENV TLANG TLOG TINDEX TAUTO
|
%token TPREFORK TLOCATION TCERT TKEY TROOT TCGI TENV TLANG TLOG TINDEX TAUTO
|
||||||
%token TSTRIP TBLOCK TRETURN TENTRYPOINT TREQUIRE TCLIENT TCA TALIAS TTCP
|
%token TSTRIP TBLOCK TRETURN TENTRYPOINT TREQUIRE TCLIENT TCA TALIAS TTCP
|
||||||
|
@ -112,9 +116,10 @@ vhost : TSERVER TSTRING {
|
||||||
host->domain = $2;
|
host->domain = $2;
|
||||||
|
|
||||||
if (strstr($2, "xn--") != NULL) {
|
if (strstr($2, "xn--") != NULL) {
|
||||||
warnx("%s:%d \"%s\" looks like punycode: "
|
warnx("%s:%d:%d \"%s\" looks like punycode: "
|
||||||
"you should use the decoded hostname.",
|
"you should use the decoded hostname.",
|
||||||
config_path, lineno, $2);
|
config_path, yylval.lineno+1, yylval.colno,
|
||||||
|
$2);
|
||||||
}
|
}
|
||||||
} '{' servopts locations '}' {
|
} '{' servopts locations '}' {
|
||||||
|
|
||||||
|
@ -283,7 +288,7 @@ yyerror(const char *msg, ...)
|
||||||
goterror = 1;
|
goterror = 1;
|
||||||
|
|
||||||
va_start(ap, msg);
|
va_start(ap, msg);
|
||||||
fprintf(stderr, "%s:%d: ", config_path, lineno);
|
fprintf(stderr, "%s:%d: ", config_path, yylval.lineno);
|
||||||
vfprintf(stderr, msg, ap);
|
vfprintf(stderr, msg, ap);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
@ -343,10 +348,10 @@ yylex(void)
|
||||||
repeat:
|
repeat:
|
||||||
/* skip whitespace first */
|
/* skip whitespace first */
|
||||||
for (c = getc(yyfp); isspace(c); c = getc(yyfp)) {
|
for (c = getc(yyfp); isspace(c); c = getc(yyfp)) {
|
||||||
colno++;
|
yylval.colno++;
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
lineno++;
|
yylval.lineno++;
|
||||||
colno = 0;
|
yylval.colno = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,19 +365,19 @@ repeat:
|
||||||
while ((c = getc(yyfp)) != '\n')
|
while ((c = getc(yyfp)) != '\n')
|
||||||
if (c == EOF)
|
if (c == EOF)
|
||||||
goto eof;
|
goto eof;
|
||||||
colno = 0;
|
yylval.colno = 0;
|
||||||
lineno++;
|
yylval.lineno++;
|
||||||
goto repeat;
|
goto repeat;
|
||||||
case EOF:
|
case EOF:
|
||||||
goto eof;
|
goto eof;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* parsing next word */
|
/* parsing next word */
|
||||||
for (;; c = getc(yyfp), colno++) {
|
for (;; c = getc(yyfp), yylval.colno++) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '\0':
|
case '\0':
|
||||||
yyerror("unallowed character NULL in column %d",
|
yyerror("unallowed character NULL in column %d",
|
||||||
colno+1);
|
yylval.colno+1);
|
||||||
escape = 0;
|
escape = 0;
|
||||||
continue;
|
continue;
|
||||||
case '\\':
|
case '\\':
|
||||||
|
@ -383,18 +388,18 @@ repeat:
|
||||||
case '\n':
|
case '\n':
|
||||||
if (quotes)
|
if (quotes)
|
||||||
yyerror("unterminated quotes in column %d",
|
yyerror("unterminated quotes in column %d",
|
||||||
colno+1);
|
yylval.colno+1);
|
||||||
if (escape) {
|
if (escape) {
|
||||||
nonkw = 1;
|
nonkw = 1;
|
||||||
escape = 0;
|
escape = 0;
|
||||||
colno = 0;
|
yylval.colno = 0;
|
||||||
lineno++;
|
yylval.lineno++;
|
||||||
}
|
}
|
||||||
goto eow;
|
goto eow;
|
||||||
case EOF:
|
case EOF:
|
||||||
if (escape)
|
if (escape)
|
||||||
yyerror("unterminated escape in column %d",
|
yyerror("unterminated escape in column %d",
|
||||||
colno);
|
yylval.colno);
|
||||||
if (quotes)
|
if (quotes)
|
||||||
yyerror("unterminated quotes in column %d",
|
yyerror("unterminated quotes in column %d",
|
||||||
qpos+1);
|
qpos+1);
|
||||||
|
@ -412,7 +417,7 @@ repeat:
|
||||||
quotes = !quotes;
|
quotes = !quotes;
|
||||||
if (quotes) {
|
if (quotes) {
|
||||||
nonkw = 1;
|
nonkw = 1;
|
||||||
qpos = colno;
|
qpos = yylval.colno;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue