Skip to content

Commit

Permalink
改进注解语法 #62
Browse files Browse the repository at this point in the history
支持unicode,但不支持memberexpr
  • Loading branch information
army8735 committed Sep 13, 2018
1 parent fc83a50 commit 26952cc
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homunculus",
"version": "1.3.3",
"version": "1.3.4",
"description": "A lexer&parser by Javascript",
"maintainers": [
{
Expand Down
2 changes: 1 addition & 1 deletion src/lexer/rule/EcmascriptRule.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/parser/es6/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ var Parser = IParser.extend(function(lexer) {
if(['function', 'class', 'let', 'const', 'async'].indexOf(this.look.content()) > -1) {
return this.decl(yYield);
}
else if(this.look.type() == Token.ANNOT) {
return this.annot();
}
else {
return this.stmt(yYield, isConstructor);
}
Expand Down
5 changes: 5 additions & 0 deletions tests/es6parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1836,6 +1836,11 @@ describe('es6parser', function() {
var node = parser.parse('await a()');
expect(tree(node)).to.eql([JsNode.SCRIPT,[JsNode.SCRIPTBODY,[JsNode.EXPRSTMT,[JsNode.UNARYEXPR,["await",JsNode.CALLEXPR,[JsNode.PRMREXPR,["a"],JsNode.ARGS,["(",JsNode.ARGLIST,[],")"]]]]]]]);
});
it('decorator', function() {
var parser = homunculus.getParser('es6');
var node = parser.parse('@test var a=1;');
expect(tree(node)).to.eql([JsNode.SCRIPT,[JsNode.SCRIPTBODY,[JsNode.ANNOT,["@test"],JsNode.VARSTMT,["var",JsNode.VARDECL,[JsNode.BINDID,["a"],JsNode.INITLZ,["=",JsNode.PRMREXPR,["1"]]],";"]]]]);
});
});
describe('js lib exec test', function() {
it('jquery 1.11.0', function() {
Expand Down
Loading

0 comments on commit 26952cc

Please sign in to comment.