Skip to content

Commit

Permalink
fix: export as的id可以是关键字
Browse files Browse the repository at this point in the history
  • Loading branch information
army8735 committed Aug 3, 2020
1 parent e653bb0 commit 3903f1d
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 7 deletions.
13 changes: 12 additions & 1 deletion homunculus.js

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

2 changes: 1 addition & 1 deletion homunculus.js.map

Large diffs are not rendered by default.

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.6.2",
"version": "1.6.3",
"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.

13 changes: 12 additions & 1 deletion src/parser/es6/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,20 @@ var Parser = IParser.extend(function(lexer) {
var node = new Node(Node.EXPORTSPEC);
node.add(this.idref());
if(this.look && this.look.content() == 'as') {
//as后一般是id,也可以是关键字,LL2来特殊处理
var type = Token.ID;
for(var i = this.index; i < this.length; i++) {
var next = this.tokens[i];
if(!S[next.type()]) {
if(next.type() == Token.KEYWORD) {
type = Token.KEYWORD;
}
break;
}
}
node.add(
this.match('as'),
this.match(Token.ID)
this.match(type)
);
}
return node;
Expand Down
2 changes: 1 addition & 1 deletion web/lexer/rule/EcmascriptRule.js

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

13 changes: 12 additions & 1 deletion web/parser/es6/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,20 @@ var Parser = IParser.extend(function(lexer) {
var node = new Node(Node.EXPORTSPEC);
node.add(this.idref());
if(this.look && this.look.content() == 'as') {
//as后一般是id,也可以是关键字,LL2来特殊处理
var type = Token.ID;
for(var i = this.index; i < this.length; i++) {
var next = this.tokens[i];
if(!S[next.type()]) {
if(next.type() == Token.KEYWORD) {
type = Token.KEYWORD;
}
break;
}
}
node.add(
this.match('as'),
this.match(Token.ID)
this.match(type)
);
}
return node;
Expand Down

0 comments on commit 3903f1d

Please sign in to comment.