homunculus
Advanced tools
Comparing version 0.2.6-1 to 0.2.6-2
@@ -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() { |
166
index.js
@@ -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-1", | ||
"version": "0.2.6-2", | ||
"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: |
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Obfuscated code
Supply chain riskObfuscated files are intentionally packed to hide their behavior. This could be a sign of malware.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Obfuscated code
Supply chain riskObfuscated files are intentionally packed to hide their behavior. This could be a sign of malware.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
90
124
8
0
1284333
32443