Skip to content

Commit d4dbe3b

Browse files
author
Max Schaefer
committed
JavaScript: Back out parsing of qualified XML identifiers.
Their syntax conflicts with the proposed function-bind operator, which is more important to support.
1 parent 6a90459 commit d4dbe3b

File tree

4 files changed

+219
-221
lines changed

4 files changed

+219
-221
lines changed

javascript/extractor/src/com/semmle/jcorn/CustomParser.java

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@
3939
import com.semmle.js.ast.XMLAttributeSelector;
4040
import com.semmle.js.ast.XMLDotDotExpression;
4141
import com.semmle.js.ast.XMLFilterExpression;
42-
import com.semmle.js.ast.XMLQualifiedIdentifier;
4342
import com.semmle.util.data.Either;
4443
import com.semmle.util.data.Pair;
4544

4645
/**
4746
* An extension of the standard jcorn parser with support for Mozilla-specific
48-
* language extension (most of JavaScript 1.8.5) and JScript language extensions.
47+
* language extension (most of JavaScript 1.8.5 and E4X) and JScript language extensions.
4948
*/
5049
public class CustomParser extends FlowParser {
5150
public CustomParser(Options options, String input, int startPos) {
@@ -460,27 +459,7 @@ protected Expression parsePropertyIdentifierOrIdentifier() {
460459
// attribute identifier
461460
return parseAttributeIdentifier(new SourceLocation(start));
462461
} else {
463-
return parsePossiblyQualifiedIdentifier();
464-
}
465-
}
466-
467-
/**
468-
* Parse a wildcard identifier, a qualified identifier, or a plain identifier.
469-
*/
470-
protected Expression parsePossiblyQualifiedIdentifier() {
471-
SourceLocation start = new SourceLocation(startLoc);
472-
Expression res = parsePropertySelector(start);
473-
474-
if (!this.eat(doubleColon))
475-
return res;
476-
477-
if (this.eat(TokenType.bracketL)) {
478-
Expression e = parseExpression(false, null);
479-
this.expect(TokenType.bracketR);
480-
return this.finishNode(new XMLQualifiedIdentifier(start, res, e, true));
481-
} else {
482-
Expression e = parsePropertySelector(new SourceLocation(startLoc));
483-
return this.finishNode(new XMLQualifiedIdentifier(start, res, e, false));
462+
return parsePropertySelector(new SourceLocation(startLoc));
484463
}
485464
}
486465

@@ -508,7 +487,7 @@ protected Expression parseAttributeIdentifier(SourceLocation start) {
508487
this.expect(TokenType.bracketR);
509488
return this.finishNode(new XMLAttributeSelector(start, idx, true));
510489
} else {
511-
return this.finishNode(new XMLAttributeSelector(start, parsePossiblyQualifiedIdentifier(), false));
490+
return this.finishNode(new XMLAttributeSelector(start, parsePropertySelector(new SourceLocation(startLoc)), false));
512491
}
513492
}
514493

0 commit comments

Comments
 (0)