Fix JS parser to properly handle "." <keyword> sequence

This commit is contained in:
Alexey Andreev
2017-04-24 12:17:52 +03:00
parent 9e89213d66
commit ca7062d776
4 changed files with 23 additions and 2 deletions
@@ -995,8 +995,9 @@ public class Parser extends Observable {
int tt;
while ((tt = ts.getToken()) > ts.EOF) {
if (tt == ts.DOT) {
ts.treatKeywordAsIdentifier = true;
mustMatchToken(ts, ts.NAME, "msg.no.name.after.dot");
String s = ts.getString();
ts.treatKeywordAsIdentifier = false;
pn = nf.createBinary(ts.DOT, pn, nf.createName(ts.getString()));
/*
* pn = nf.createBinary(ts.DOT, pn, memberExpr(ts)) is the version in
@@ -695,7 +695,7 @@ public class TokenStream {
in.unread();
String str = getStringFromBuffer();
if (!containsEscape) {
if (!containsEscape && !treatKeywordAsIdentifier) {
// OPT we shouldn't have to make a string (object!) to
// check if it's a keyword.
@@ -1477,6 +1477,7 @@ public class TokenStream {
CodePosition lastPosition;
private int op;
public boolean treatKeywordAsIdentifier;
// Set this to an inital non-null value so that the Parser has
// something to retrieve even if an error has occured and no