Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

homunculus

Package Overview
Dependencies
Maintainers
2
Versions
164
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

homunculus - npm Package Compare versions

Comparing version 0.2.6 to 0.2.7

demo/sea.js

10

gulpfile.js

@@ -17,4 +17,4 @@ var gulp = require('gulp');

gulp.task('clean-dist', function() {
return gulp.src('./dist/*')
gulp.task('clean-web', function() {
return gulp.src('./web/*')
.pipe(clean());

@@ -24,3 +24,3 @@ });

function cb(file, enc, cb) {
var target = file.path.replace(path.sep + 'src' + path.sep, path.sep + 'dist' + path.sep);
var target = file.path.replace(path.sep + 'src' + path.sep, path.sep + 'web' + path.sep);
mkdir(path.dirname(target));

@@ -30,3 +30,3 @@ util.log(path.relative(file.cwd, file.path), '->', path.relative(file.cwd, target));

content = content.toString('utf-8');
content = "(function(factory) {\n if(typeof define === 'function' && (define.amd || define.cmd)) {\n define(factory);\n }\n else {\n factory(require, exports, module);\n }\n})(function(require, exports, module) {\n " + content.replace(/\n/g, '\n ') + '\n});';
content = "define(function(require, exports, module) {\n " + content.replace(/\n/g, '\n ') + '\n});';
fs.writeFileSync(target, content, { encoding: 'utf-8' });

@@ -36,3 +36,3 @@ cb(null, file);

gulp.task('default', ['clean-dist'], function() {
gulp.task('default', ['clean-web'], function() {
gulp.src('./src/**/*.js')

@@ -39,0 +39,0 @@ .pipe(function() {

@@ -1,158 +0,8 @@

(function(factory) {
if(typeof define === 'function' && (define.amd || define.cmd)) {
define(factory);
}
else {
factory(require, exports, module);
}
})(function(require, exports, module) {
var Lexer = require('./dist/lexer/Lexer');
var CssLexer = require('./dist/lexer/CssLexer');
var EcmascriptRule = require('./dist/lexer/rule/EcmascriptRule');
var CssRule = require('./dist/lexer/rule/CssRule');
var JavaRule = require('./dist/lexer/rule/JavaRule');
var CRule = require('./dist/lexer/rule/CRule');
var Token = require('./dist/lexer/Token');
var JsParser = require('./dist/parser/js/Parser');
var Es6Parser = require('./dist/parser/es6/Parser');
var CssParser = require('./dist/parser/css/Parser');
var JsNode = require('./dist/parser/js/Node');
var Es6Node = require('./dist/parser/es6/Node');
var CssNode = require('./dist/parser/css/Node');
var JsContext = require('./dist/parser/js/Context');
exports.getClass = function (type, lan) {
type = (type || '').toLowerCase();
lan = (lan || '').toLowerCase();
switch (type) {
case 'lexer':
switch (lan) {
case 'js':
case 'javascript':
case 'es':
case 'es5':
case 'ecmascript':
case 'es6':
case 'as':
case 'actionscript':
return Lexer;
case 'css':
return CssLexer;
default:
throw new Error('Unsupport Language Lexer: ' + lan);
}
break;
case 'parser':
switch (lan) {
case 'js':
case 'javascript':
case 'es':
case 'es5':
case 'ecmascript':
return JsParser;
case 'es6':
return Es6Parser;
case 'css':
return CssParser;
default:
throw new Error('Unsupport Language Parser: ' + lan);
}
break;
case 'node':
switch (lan) {
case 'js':
case 'javascript':
case 'es':
case 'es5':
case 'ecmascript':
return JsNode;
case 'es6':
return Es6Node;
case 'css':
return CssNode;
default:
throw new Error('Unsupport Language Node: ' + lan);
}
break;
case 'context':
switch (lan) {
case 'js':
case 'javascript':
case 'es':
case 'es5':
case 'ecmascript':
return JsContext;
default:
throw new Error('Unsupport Language Context: ' + lan);
}
break;
case 'token':
return Token;
default:
throw new Error('Unsupport Class Type: ' + type);
}
};
exports.getLexer = function (lan) {
lan = lan.toLowerCase();
switch (lan) {
case 'js':
case 'javascript':
case 'es':
case 'es5':
case 'ecmascript':
case 'es6':
case 'as':
case 'actionscript':
return new Lexer(new EcmascriptRule());
case 'css':
return new CssLexer(new CssRule());
case "java":
return new Lexer(new JavaRule());
case "c":
case "c++":
case "cpp":
case "cplusplus":
return new Lexer(new CRule());
default:
throw new Error('Unsupport Language Lexer: ' + lan);
}
};
exports.getParser = function (lan) {
lan = lan.toLowerCase();
switch (lan) {
case 'js':
case 'javascript':
case 'es':
case 'es5':
case 'ecmascript':
return new JsParser(exports.getLexer(lan));
case 'es6':
return new Es6Parser(exports.getLexer(lan));
case 'css':
return new CssParser(exports.getLexer(lan));
default:
throw new Error('Unsupport Language Parser: ' + lan);
}
};
exports.getContext = function (lan) {
lan = lan.toLowerCase();
switch (lan) {
case 'js':
case 'javascript':
case 'es':
case 'es5':
case 'ecmascript':
return new JsContext();
default:
throw new Error('Unsupport Language Context: ' + lan);
}
};
});
if(typeof define === 'function' && (define.amd || define.cmd)) {
define(function(require, exports, module) {
module.exports = require('./web/Homunculus');
});
}
else {
module.exports = require('./src/Homunculus');
}
{
"name": "homunculus",
"version": "0.2.6",
"version": "0.2.7",
"description": "A lexer&parser by Javascript",

@@ -17,12 +17,11 @@ "maintainers": [

"pattern": [
"dist/lexer/Lexer",
"dist/lexer/Token",
"dist/lexer/match",
"dist/lexer/rule/Rule",
"dist/lexer/rule/EcmascriptRule",
"dist/parser/js",
"dist/parser/es6",
"dist/parser/Parser",
"dist/parser/Node",
"dist/util"
"src/lexer/Lexer",
"src/lexer/Token",
"src/lexer/match",
"src/lexer/rule/Rule",
"src/lexer/rule/EcmascriptRule",
"src/parser/js",
"src/parser/es6",
"src/parser/Parser",
"src/parser/Node"
]

@@ -29,0 +28,0 @@ }

@@ -18,2 +18,3 @@ # A lexer&parser by Javascript

## API
### Homunculus
* getClass(type:String, lan:String):class

@@ -20,0 +21,0 @@ * type:

@@ -15,3 +15,2 @@ var INode = require('../Node');

FNPARAMS: 'fnparams',
BINDELEMENT: 'bindelement',
RESTPARAM: 'restparam',

@@ -18,0 +17,0 @@ EXPR: 'expr',

@@ -105,4 +105,3 @@ var IParser = require('../Parser');

node.add(
this.match(),
this.match(';')
this.match()
);

@@ -113,6 +112,6 @@ }

this.importcaulse(),
this.fromcaulse(),
this.match(';')
this.fromcaulse()
);
}
node.add(this.match(';'));
return node;

@@ -125,3 +124,4 @@ },

this.bindid(),
this.fromcaulse()
this.fromcaulse(),
this.match(';')
);

@@ -257,3 +257,3 @@ return node;

if(['function', 'class', 'let', 'const'].indexOf(this.look.content()) > -1) {
return this.decl();
return this.decl(yYield);
}

@@ -264,3 +264,3 @@ else {

},
decl: function() {
decl: function(yYield) {
if(!this.look) {

@@ -272,3 +272,3 @@ this.error();

case 'const':
return this.lexdecl();
return this.lexdecl(yYield);
case 'function':

@@ -297,13 +297,13 @@ for(var i = this.index; i < this.length; i++) {

case 'var':
return this.varstmt();
return this.varstmt(null, yYield);
case '{':
return this.blockstmt();
return this.blockstmt(yYield);
case ';':
return this.emptstmt();
case 'if':
return this.ifstmt();
return this.ifstmt(yYield);
case 'do':
case 'while':
case 'for':
return this.iterstmt();
return this.iterstmt(yYield);
case 'continue':

@@ -316,9 +316,9 @@ return this.cntnstmt();

case 'with':
return this.withstmt();
return this.withstmt(yYield);
case 'switch':
return this.swchstmt();
return this.swchstmt(yYield);
case 'throw':
return this.thrstmt();
return this.thrstmt(yYield);
case 'try':
return this.trystmt();
return this.trystmt(yYield);
case 'debugger':

@@ -348,3 +348,3 @@ return this.debstmt();

},
lexdecl: function() {
lexdecl: function(yYield) {
var node = new Node(Node.LEXDECL);

@@ -360,7 +360,7 @@ if(this.look.content() == 'let') {

}
node.add(this.lexbind());
node.add(this.lexbind(yYield));
while(this.look && this.look.content() == ',') {
node.add(
this.match(),
this.lexbind()
this.lexbind(yYield)
);

@@ -371,8 +371,8 @@ }

},
lexbind: function() {
lexbind: function(yYield) {
var node = new Node(Node.LEXBIND);
this.declnode(node);
this.declnode(node, yYield);
return node;
},
declnode: function(node) {
declnode: function(node, yYield) {
if(!this.look) {

@@ -386,3 +386,3 @@ this.error('missing variable name');

}
node.add(this.initlz());
node.add(this.initlz(null, null, yYield));
}

@@ -392,11 +392,11 @@ else {

if(this.look && this.look.content() == '=') {
node.add(this.initlz());
node.add(this.initlz(null, null, yYield));
}
}
},
varstmt: function(noSem) {
varstmt: function(noSem, yYield) {
var node = new Node(Node.VARSTMT);
node.add(
this.match('var'),
this.vardecl()
this.vardecl(yYield)
);

@@ -406,3 +406,3 @@ while(this.look && this.look.content() == ',') {

this.match(),
this.vardecl()
this.vardecl(yYield)
);

@@ -415,5 +415,5 @@ }

},
vardecl: function() {
vardecl: function(yYield) {
var node = new Node(Node.VARDECL);
this.declnode(node);
this.declnode(node, yYield);
return node;

@@ -465,3 +465,3 @@ },

}
if(this.look.content() == '...') {
if(this.look && this.look.content() == '...') {
node.add(this.bindrest());

@@ -558,10 +558,10 @@ }

var node = new Node(Node.BLOCKSTMT);
node.add(this.block());
node.add(this.block(null, yYield));
return node;
},
block: function(msg) {
block: function(msg, yYield) {
var node = new Node(Node.BLOCK);
node.add(this.match('{', msg));
while(this.look && this.look.content() != '}') {
node.add(this.stmtlitem());
node.add(this.stmtlitem(yYield));
}

@@ -576,3 +576,3 @@ node.add(this.match('}', 'missing } in compound statement'));

},
ifstmt: function() {
ifstmt: function(yYield) {
var node = new Node(Node.IFSTMT);

@@ -589,3 +589,3 @@ node.add(

this.match('else'),
this.stmt()
this.stmt(yYield)
);

@@ -595,3 +595,3 @@ }

},
iterstmt: function() {
iterstmt: function(yYield) {
var node = new Node(Node.ITERSTMT);

@@ -616,3 +616,3 @@ switch(this.look.content()) {

this.match(')'),
this.stmt()
this.stmt(yYield)
);

@@ -769,3 +769,3 @@ break;

node.add(this.match(')'));
node.add(this.stmt());
node.add(this.stmt(yYield));
}

@@ -812,3 +812,3 @@ return node;

},
withstmt: function() {
withstmt: function(yYield) {
var node = new Node(Node.WITHSTMT);

@@ -820,7 +820,7 @@ node.add(

this.match(')', 'missing ) after with-statement object'),
this.stmt()
this.stmt(yYield)
);
return node;
},
swchstmt: function() {
swchstmt: function(yYield) {
var node = new Node(Node.SWCHSTMT);

@@ -832,7 +832,7 @@ node.add(

this.match(')'),
this.caseblock()
this.caseblock(yYield)
);
return node;
},
caseblock: function() {
caseblock: function(yYield) {
var node = new Node(Node.CASEBLOCK);

@@ -842,6 +842,6 @@ node.add(this.match('{'));

if(this.look.content() == 'case') {
node.add(this.caseclause());
node.add(this.caseclause(yYield));
}
else if(this.look.content() == 'default') {
node.add(this.dftclause());
node.add(this.dftclause(yYield));
}

@@ -855,3 +855,3 @@ else {

},
caseclause: function() {
caseclause: function(yYield) {
var node = new Node(Node.CASECLAUSE);

@@ -867,7 +867,7 @@ node.add(

&& this.look.content() != '}') {
node.add(this.stmt());
node.add(this.stmt(yYield));
}
return node;
},
dftclause: function() {
dftclause: function(yYield) {
var node = new Node(Node.DFTCLAUSE);

@@ -879,3 +879,3 @@ node.add(

while(this.look && this.look.content() != '}') {
node.add(this.stmt());
node.add(this.stmt(yYield));
}

@@ -902,16 +902,16 @@ return node;

},
trystmt: function() {
trystmt: function(yYield) {
var node = new Node(Node.TRYSTMT);
node.add(
this.match('try'),
this.block('missing { before try block')
this.block('missing { before try block', yYield)
);
if(this.look && this.look.content() == 'catch') {
node.add(this.cach());
node.add(this.cach(yYield));
if(this.look && this.look.content() == 'finally') {
node.add(this.finl());
node.add(this.finl(yYield));
}
}
else {
node.add(this.finl());
node.add(this.finl(yYield));
}

@@ -925,3 +925,3 @@ return node;

},
cach: function() {
cach: function(yYield) {
var node = new Node(Node.CACH);

@@ -933,3 +933,3 @@ node.add(

this.match(')', 'missing ) after catch'),
this.block('missing { before catch block')
this.block('missing { before catch block', yYield)
);

@@ -948,7 +948,7 @@ return node;

},
finl: function() {
finl: function(yYield) {
var node = new Node(Node.FINL);
node.add(
this.match('finally'),
this.block('missing { before finally block')
this.block('missing { before finally block', yYield)
);

@@ -1235,7 +1235,7 @@ return node;

},
initlz: function(noIn, noOf) {
initlz: function(noIn, noOf, yYield) {
var node = new Node(Node.INITLZ);
node.add(
this.match('='),
this.assignexpr(noIn, noOf)
this.assignexpr(noIn, noOf, yYield)
);

@@ -1251,3 +1251,3 @@ return node;

if(!yYield) {
this.error();
this.error('yield not in generator function');
}

@@ -2002,3 +2002,3 @@ return this.yieldexpr(noIn, noOf, yYield);

}
if(this.look.content() == '...') {
if(this.look && this.look.content() == '...') {
node.add(this.spread(noIn, noOf));

@@ -2005,0 +2005,0 @@ }

@@ -5,12 +5,12 @@ var homunculus = require('../');

var Lexer = require('../dist/lexer/Lexer');
var CssLexer = require('../dist/lexer/CssLexer');
var JsParser = require('../dist/parser/js/Parser');
var Es6Parser = require('../dist/parser/es6/Parser');
var CssParser = require('../dist/parser/css/Parser');
var JsNode = require('../dist/parser/js/Node');
var Es6Node = require('../dist/parser/es6/Node');
var CssNode = require('../dist/parser/css/Node');
var Token = require('../dist/lexer/Token');
var JsContext = require('../dist/parser/js/Context');
var Lexer = require('../src/lexer/Lexer');
var CssLexer = require('../src/lexer/CssLexer');
var JsParser = require('../src/parser/js/Parser');
var Es6Parser = require('../src/parser/es6/Parser');
var CssParser = require('../src/parser/css/Parser');
var JsNode = require('../src/parser/js/Node');
var Es6Node = require('../src/parser/es6/Node');
var CssNode = require('../src/parser/css/Node');
var Token = require('../src/lexer/Token');
var JsContext = require('../src/parser/js/Context');

@@ -17,0 +17,0 @@ describe('api of homunculus', function() {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc