зеркало из https://github.com/mozilla/mozjexl.git
Merge pull request #12 from TechnologyAdvice/ast-balance
Parser: Fixed binOp balancing after nested idents
This commit is contained in:
Коммит
24f7fddb6d
|
@ -1,7 +1,8 @@
|
||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- "0.12"
|
- "0.12"
|
||||||
- "iojs"
|
- "4"
|
||||||
|
- "5"
|
||||||
addons:
|
addons:
|
||||||
code_climate:
|
code_climate:
|
||||||
repo_token:
|
repo_token:
|
||||||
|
@ -10,3 +11,4 @@ script: node_modules/.bin/gulp coverage-test
|
||||||
after_script:
|
after_script:
|
||||||
- npm install -g codeclimate-test-reporter
|
- npm install -g codeclimate-test-reporter
|
||||||
- cat coverage/lcov.info | codeclimate
|
- cat coverage/lcov.info | codeclimate
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,13 @@
|
||||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
Nothing yet!
|
### Fixed
|
||||||
|
- Binary operators after nested identifiers were not balanced properly,
|
||||||
|
resulting in a broken expression/AST
|
||||||
|
- Gulp (or one of its plugins) had a breaking change in a minor release,
|
||||||
|
preventing the frontend build from running. This build method will be
|
||||||
|
removed from the next major version of Jexl. For now, Jexl is now version-
|
||||||
|
locked to the original gulp+plugins that worked.
|
||||||
|
|
||||||
## [v1.1.2]
|
## [v1.1.2]
|
||||||
### Changed
|
### Changed
|
||||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -96,6 +96,7 @@ exports.identifier = function(token) {
|
||||||
if (this._nextIdentEncapsulate) {
|
if (this._nextIdentEncapsulate) {
|
||||||
node.from = this._cursor;
|
node.from = this._cursor;
|
||||||
this._placeBeforeCursor(node);
|
this._placeBeforeCursor(node);
|
||||||
|
this._nextIdentEncapsulate = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (this._nextIdentRelative)
|
if (this._nextIdentRelative)
|
||||||
|
|
10
package.json
10
package.json
|
@ -32,17 +32,17 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/TechnologyAdvice/jexl",
|
"homepage": "https://github.com/TechnologyAdvice/jexl",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"browserify": "^9.0.3",
|
"browserify": "=9.0.3",
|
||||||
"chai": "^2.0.0",
|
"chai": "^2.0.0",
|
||||||
"chai-as-promised": "^4.2.0",
|
"chai-as-promised": "^4.2.0",
|
||||||
"gulp": "^3.8.11",
|
"gulp": "=3.8.11",
|
||||||
"gulp-istanbul": "^0.6.0",
|
"gulp-istanbul": "^0.6.0",
|
||||||
"gulp-istanbul-enforcer": "^1.0.3",
|
"gulp-istanbul-enforcer": "^1.0.3",
|
||||||
"gulp-mocha": "^2.0.0",
|
"gulp-mocha": "^2.0.0",
|
||||||
"gulp-rename": "^1.2.0",
|
"gulp-rename": "=1.2.0",
|
||||||
"gulp-uglify": "^1.1.0",
|
"gulp-uglify": "=1.1.0",
|
||||||
"istanbul": "^0.3.8",
|
"istanbul": "^0.3.8",
|
||||||
"mocha": "^2.1.0",
|
"mocha": "^2.1.0",
|
||||||
"vinyl-transform": "^1.0.0"
|
"vinyl-transform": "=1.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -406,4 +406,22 @@ describe('Parser', function() {
|
||||||
alternate: {type: 'Literal', value: 'baz'}
|
alternate: {type: 'Literal', value: 'baz'}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it('should correctly balance a binary op between complex identifiers', function() {
|
||||||
|
inst.addTokens(lexer.tokenize('a.b == c.d'));
|
||||||
|
inst.complete().should.deep.equal({
|
||||||
|
type: 'BinaryExpression',
|
||||||
|
operator: '==',
|
||||||
|
left: {
|
||||||
|
type: 'Identifier',
|
||||||
|
value: 'b',
|
||||||
|
from: {type: 'Identifier', value: 'a'}
|
||||||
|
},
|
||||||
|
right: {
|
||||||
|
type: 'Identifier',
|
||||||
|
value: 'd',
|
||||||
|
from: {type: 'Identifier', value: 'c'}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче