summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-05-18 06:21:23 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-05-18 06:21:23 -0700
commitc51a26976c735531cf2f63d503f125da87f90133 (patch)
treec8efd7acf0728ab5e4f824b1b434fecb043d3083
parent07376fac04b7c353d72563ca939ac990c162e901 (diff)
downloadtxr-c51a26976c735531cf2f63d503f125da87f90133.tar.gz
txr-c51a26976c735531cf2f63d503f125da87f90133.tar.bz2
txr-c51a26976c735531cf2f63d503f125da87f90133.zip
parser: bugfix: set line number on <lineno> tokens.
This issue was revealed as a garbage line number in an unbound variable warning diagnostic, where the variable occurs in a quasi word list literal. A small test case is (list #`@var`) where var unbound. The fix is, in the lexer, to set the yylval->lineno for all tokens which are declared as <lineno> in the grammar file, for which doing so has beens neglected. We do this even for those tokens whose line number values are never accessd in any rule; it could arise in the future. * parser.l (grammar): Set the yylval->lineno for the tokens HASH_BACKSLASH, HASH_B_QUOTE, HASH_SLASH, WORDS, WSPLICE, QWORDS and QWSPLICE.
-rw-r--r--parser.l7
1 files changed, 7 insertions, 0 deletions
diff --git a/parser.l b/parser.l
index fef31835..501f878c 100644
--- a/parser.l
+++ b/parser.l
@@ -619,16 +619,19 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
<SPECIAL,QSPECIAL,NESTED,BRACED>#\\ {
yy_push_state(CHRLIT, yyscanner);
+ yylval->lineno = yyextra->lineno;
return HASH_BACKSLASH;
}
<SPECIAL,QSPECIAL,NESTED,BRACED>#b' {
yy_push_state(BUFLIT, yyscanner);
+ yylval->lineno = yyextra->lineno;
return HASH_B_QUOTE;
}
<SPECIAL,QSPECIAL,NESTED,BRACED>#[/] {
yy_push_state(REGEX, yyscanner);
+ yylval->lineno = yyextra->lineno;
return HASH_SLASH;
}
@@ -639,21 +642,25 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
<SPECIAL,QSPECIAL,NESTED,BRACED>#\" {
yy_push_state(WLIT, yyscanner);
+ yylval->lineno = yyextra->lineno;
return WORDS;
}
<SPECIAL,QSPECIAL,NESTED,BRACED>#\*\" {
yy_push_state(WLIT, yyscanner);
+ yylval->lineno = yyextra->lineno;
return WSPLICE;
}
<SPECIAL,QSPECIAL,NESTED,BRACED>#\` {
yy_push_state(QWLIT, yyscanner);
+ yylval->lineno = yyextra->lineno;
return QWORDS;
}
<SPECIAL,QSPECIAL,NESTED,BRACED>#\*\` {
yy_push_state(QWLIT, yyscanner);
+ yylval->lineno = yyextra->lineno;
return QWSPLICE;
}