Skip to content

Commit

Permalink
fix: 重复代码和console,压缩配置
Browse files Browse the repository at this point in the history
  • Loading branch information
army8735 committed Feb 21, 2020
1 parent 071c32f commit 8b08de0
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 59 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,5 @@ pip-log.txt
.mr.developer.cfg
.idea/
node_modules/
tests/covrage.html
tests/covrage.html
homunculus.min.js*
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ demo/
node_modules/
gulpfile.js
README.md
lib/
lib/
homunculus.min.js*
17 changes: 1 addition & 16 deletions 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.1",
"version": "1.6.2",
"description": "A lexer&parser by Javascript",
"maintainers": [
{
Expand Down
21 changes: 19 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import commonjs from 'rollup-plugin-commonjs';
import { uglify } from 'rollup-plugin-uglify';

export default {
export default [{
input: 'src/homunculus.js',
output: {
name: 'homunculus',
Expand All @@ -13,4 +14,20 @@ export default {
exclude: 'node_modules/**' // 只编译我们的源代码
}),
],
};
}, {
input: 'src/homunculus.js',
output: {
name: 'homunculus',
file: 'homunculus.min.js',
format: 'umd',
sourcemap: true,
},
plugins: [
commonjs({
exclude: 'node_modules/**' // 只编译我们的源代码
}),
uglify({
sourcemap: true,
}),
],
}];
4 changes: 2 additions & 2 deletions src/lexer/Lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ var Lexer = Class(function(rule) {
col: function() {
return this.colMax;
},
error: function(s, str) {console.log(arguments.callee.caller)
error: function(s, str) {
if(character.isUndefined(str)) {
str = this.code.substr(this.index - 1, 20);
}
Expand All @@ -305,4 +305,4 @@ var Lexer = Class(function(rule) {
}
});
var cmode = Lexer.STRICT;
module.exports = Lexer;
module.exports = Lexer;
14 changes: 0 additions & 14 deletions src/parser/es6/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1285,20 +1285,6 @@ var Parser = IParser.extend(function(lexer) {
}
return node;
},
asyncmethod: function(noIn, noOf) {
var node = new Node(Node.ASYNCMETHOD);
node.add(
this.match('async', true),
this.proptname(),
this.match('('),
this.fmparams(),
this.match(')'),
this.match('{'),
this.fnbody(),
this.match('}')
);
return node;
},
annot: function() {
var node = new Node(Node.ANNOT);
node.add(this.match());
Expand Down
3 changes: 1 addition & 2 deletions src/parser/js/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ var Node = INode.extend(function(type, children) {
ITERSTMT: 'iterstmt',
FNPARAMS: 'fnparams',
EXPR: 'expr',
PROGRAM: 'program',
STMT: 'stmt',
ASSIGN: 'assign',
EMPTSTMT: 'emptstmt',
Expand Down Expand Up @@ -73,4 +72,4 @@ var Node = INode.extend(function(type, children) {
}
});
var keys;
module.exports = Node;
module.exports = Node;
5 changes: 3 additions & 2 deletions web/lexer/Lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ var Lexer = Class(function(rule) {
col: function() {
return this.colMax;
},
error: function(s, str) {console.log(arguments.callee.caller)
error: function(s, str) {
if(character.isUndefined(str)) {
str = this.code.substr(this.index - 1, 20);
}
Expand All @@ -305,4 +305,5 @@ var Lexer = Class(function(rule) {
}
});
var cmode = Lexer.STRICT;
module.exports = Lexer;});
module.exports = Lexer;
});
15 changes: 0 additions & 15 deletions web/parser/es6/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1285,20 +1285,6 @@ var Parser = IParser.extend(function(lexer) {
}
return node;
},
asyncmethod: function(noIn, noOf) {
var node = new Node(Node.ASYNCMETHOD);
node.add(
this.match('async', true),
this.proptname(),
this.match('('),
this.fmparams(),
this.match(')'),
this.match('{'),
this.fnbody(),
this.match('}')
);
return node;
},
annot: function() {
var node = new Node(Node.ANNOT);
node.add(this.match());
Expand Down Expand Up @@ -2249,7 +2235,6 @@ var Parser = IParser.extend(function(lexer) {
if(!this.look) {
this.error();
}
debugger;
if(this.look.content() == '[') {
var cmpt = this.cmptpropt(noIn, noOf);
if(!this.look) {
Expand Down
4 changes: 2 additions & 2 deletions web/parser/js/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ var Node = INode.extend(function(type, children) {
ITERSTMT: 'iterstmt',
FNPARAMS: 'fnparams',
EXPR: 'expr',
PROGRAM: 'program',
STMT: 'stmt',
ASSIGN: 'assign',
EMPTSTMT: 'emptstmt',
Expand Down Expand Up @@ -73,4 +72,5 @@ var Node = INode.extend(function(type, children) {
}
});
var keys;
module.exports = Node;});
module.exports = Node;
});

0 comments on commit 8b08de0

Please sign in to comment.