summaryrefslogtreecommitdiffstats
path: root/parser.l
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-09-07 22:11:39 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-09-07 22:11:39 -0700
commitfd47bc4ae6bb9f6a4dab2cf12e8c5cb7459675e2 (patch)
tree0ccda2dce4ebc58a0e71e3bdab296452467edd9f /parser.l
parent4c7c4e5fc3c53fca40d619e73b891269feffa010 (diff)
downloadtxr-fd47bc4ae6bb9f6a4dab2cf12e8c5cb7459675e2.tar.gz
txr-fd47bc4ae6bb9f6a4dab2cf12e8c5cb7459675e2.tar.bz2
txr-fd47bc4ae6bb9f6a4dab2cf12e8c5cb7459675e2.zip
parser: fix precedence of DOTDOT.
The problem is that a.b .. c.d parses as (qref a b..c d), which is useless and counterintuitive. Let's fix it, but with a backward compatibility switch to give more leeway to any hapless people out there whose code happens to depend on this unfortunate situation. We basically use two token numbers for the .. token: OLD_DOTDOT, and DOTDOT. Both are wired into the grammar. In backward compatibility mode, the lexer pumps out OLD_DOTDOT. Otherwise DOTDOT. * parser.l (grammar): When .. is scanned, return OLD_DOTDOT when in compatibility with 185 or earlier. Otherwise DOTDOT. * parser.y (OLD_DOTDOT): New terminal symbol; introduced at the same high precedence previously occupied by DOTDOT. (DOTDOT): Changes precedence to lower than '.' and UREFDOT. (n_expr): Two productions added involving OLD_DOTDOT. These are copy and paste of the existing productions involving DOTDOT; the only difference is that OLD_DOTDOT replaces DOTDOT. (yybadtoken): Handle OLD_DOTDOT. * txr.1: Compat notes added.
Diffstat (limited to 'parser.l')
-rw-r--r--parser.l2
1 files changed, 1 insertions, 1 deletions
diff --git a/parser.l b/parser.l
index 501f878c..3f595e4f 100644
--- a/parser.l
+++ b/parser.l
@@ -702,7 +702,7 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
<NESTED>{WS}\.\. {
yylval->lineno = yyextra->lineno;
- return DOTDOT;
+ return (opt_compat && opt_compat <= 185) ? OLD_DOTDOT : DOTDOT;
}
<SPECIAL>@ {