Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
Delegate marking should be at the right location.
Browse files Browse the repository at this point in the history
Whitespaces and comments skipping should be carried out before
calling the syntax tree delegate location marking functions.

https://code.google.com/p/esprima/issues/detail?id=355
  • Loading branch information
ariya committed May 21, 2013
1 parent 2159a86 commit 074f4a7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion esprima.js
Expand Up @@ -1190,7 +1190,6 @@ parseStatement: true, parseSourceElement: true */
name: 'SyntaxTree',

markStart: function () {
skipComment();
if (extra.loc) {
state.markerStack.push(index - lineStart);
state.markerStack.push(lineNumber);
Expand Down Expand Up @@ -1781,6 +1780,7 @@ parseStatement: true, parseSourceElement: true */
var previousStrict, body;

previousStrict = strict;
skipComment();
delegate.markStart();
body = parseFunctionSourceElements();
if (first && strict && isRestrictedWord(param[0].name)) {
Expand All @@ -1793,6 +1793,7 @@ parseStatement: true, parseSourceElement: true */
function parseObjectPropertyKey() {
var token;

skipComment();
delegate.markStart();
token = lex();

Expand All @@ -1813,6 +1814,7 @@ parseStatement: true, parseSourceElement: true */
var token, key, id, value, param;

token = lookahead;
skipComment();
delegate.markStart();

if (token.type === Token.Identifier) {
Expand Down Expand Up @@ -2397,6 +2399,7 @@ parseStatement: true, parseSourceElement: true */
function parseBlock() {
var block;

skipComment();
delegate.markStart();
expect('{');

Expand All @@ -2412,6 +2415,7 @@ parseStatement: true, parseSourceElement: true */
function parseVariableIdentifier() {
var token;

skipComment();
delegate.markStart();
token = lex();

Expand All @@ -2425,6 +2429,7 @@ parseStatement: true, parseSourceElement: true */
function parseVariableDeclaration(kind) {
var init = null, id;

skipComment();
delegate.markStart();
id = parseVariableIdentifier();

Expand Down Expand Up @@ -2477,6 +2482,7 @@ parseStatement: true, parseSourceElement: true */
function parseConstLetDeclaration(kind) {
var declarations;

skipComment();
delegate.markStart();

expectKeyword(kind);
Expand Down Expand Up @@ -2812,6 +2818,7 @@ parseStatement: true, parseSourceElement: true */
consequent = [],
statement;

skipComment();
delegate.markStart();
if (matchKeyword('default')) {
lex();
Expand Down Expand Up @@ -2901,6 +2908,7 @@ parseStatement: true, parseSourceElement: true */
function parseCatchClause() {
var param, body;

skipComment();
delegate.markStart();
expectKeyword('catch');

Expand Down Expand Up @@ -2965,6 +2973,7 @@ parseStatement: true, parseSourceElement: true */
throwUnexpected(lookahead);
}

skipComment();
delegate.markStart();

if (type === Token.Punctuator) {
Expand Down Expand Up @@ -3043,6 +3052,7 @@ parseStatement: true, parseSourceElement: true */
var sourceElement, sourceElements = [], token, directive, firstRestricted,
oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody;

skipComment();
delegate.markStart();
expect('{');

Expand Down Expand Up @@ -3155,6 +3165,7 @@ parseStatement: true, parseSourceElement: true */
function parseFunctionDeclaration() {
var id, params = [], body, token, stricted, tmp, firstRestricted, message, previousStrict;

skipComment();
delegate.markStart();

expectKeyword('function');
Expand Down Expand Up @@ -3300,6 +3311,8 @@ parseStatement: true, parseSourceElement: true */

function parseProgram() {
var body;

skipComment();
delegate.markStart();
strict = false;
peek();
Expand Down

0 comments on commit 074f4a7

Please sign in to comment.