homunculus
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -0,0 +0,0 @@ var gulp = require('gulp'); |
@@ -0,0 +0,0 @@ var Lexer = require('./src/lexer/Lexer'); |
{ | ||
"name": "homunculus", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "A lexer&parser by Javascript", | ||
@@ -5,0 +5,0 @@ "maintainers": [ |
@@ -0,0 +0,0 @@ var Lexer = require('./Lexer'); |
@@ -0,0 +0,0 @@ var Class = require('../util/Class'); |
@@ -0,0 +0,0 @@ var Match = require('./Match'); |
@@ -0,0 +0,0 @@ var Match = require('./Match'); |
@@ -0,0 +0,0 @@ var Match = require('./Match'); |
@@ -0,0 +0,0 @@ var Match = require('./Match'); |
@@ -0,0 +0,0 @@ var Class = require('../../util/Class'); |
@@ -0,0 +0,0 @@ var Match = require('./Match'); |
@@ -0,0 +0,0 @@ var Rule = require('./Rule'); |
@@ -0,0 +0,0 @@ var Rule = require('./Rule'); |
@@ -0,0 +0,0 @@ var Rule = require('./Rule'); |
@@ -0,0 +0,0 @@ var Rule = require('./Rule'); |
@@ -0,0 +0,0 @@ var Class = require('../../util/Class'); |
@@ -0,0 +0,0 @@ var Class = require('../util/Class'); |
@@ -0,0 +0,0 @@ var character = require('../../util/character'); |
@@ -0,0 +0,0 @@ var Class = require('../../util/Class'); |
@@ -0,0 +0,0 @@ var Class = require('../../util/Class'); |
@@ -117,4 +117,2 @@ var Class = require('../../util/Class'); | ||
UNARYEXPR: 'unaryexpr', | ||
CONSTOR: 'constor', | ||
CONSCALL: 'conscall', | ||
MMBEXPR: 'mmbexpr', | ||
@@ -129,5 +127,7 @@ PRMREXPR: 'prmrexpr', | ||
ARGLIST: 'arglist', | ||
ASSIGNOPRT: 'assignoprt', | ||
IMPTSTMT: 'imptstmt' | ||
IMPTSTMT: 'imptstmt', | ||
POSTFIXEXPR: 'postfixexpr', | ||
NEWEXPR: 'newexpr', | ||
CALLEXPR: 'callexpr' | ||
}); | ||
module.exports = Node; |
@@ -933,59 +933,114 @@ var Class = require('../../util/Class'); | ||
break; | ||
case 'new': | ||
node.add( | ||
this.match(), | ||
this.constor() | ||
); | ||
break; | ||
default: | ||
var mmbexpr = this.mmbexpr(); | ||
if(this.look && ['++', '--'].indexOf(this.look.content()) != -1) { | ||
node.add(mmbexpr, this.match()); | ||
return node; | ||
} | ||
else { | ||
return mmbexpr; | ||
} | ||
return this.postfixexpr(); | ||
} | ||
return node; | ||
}, | ||
constor: function() { | ||
var node = new Node(Node.CONSTOR); | ||
postfixexpr: function() { | ||
var node = new Node(Node.POSTFIXEXPR); | ||
var leftexpr = this.leftexpr(); | ||
if(this.look && ['++', '--'].indexOf(this.look.content()) > -1 && !this.hasMoveLine) { | ||
node.add(leftexpr); | ||
while(this.look && ['++', '--'].indexOf(this.look.content()) > -1) { | ||
node.add(this.match(undefined, true)); | ||
} | ||
} | ||
else { | ||
return leftexpr; | ||
} | ||
return node; | ||
}, | ||
leftexpr: function() { | ||
if(!this.look) { | ||
this.error(); | ||
} | ||
if(this.look.content() == 'this') { | ||
node.add( | ||
this.match(), | ||
this.match('.') | ||
); | ||
if(this.look.content() == 'new') { | ||
return this.newexpr(); | ||
} | ||
else { | ||
return this.conscall(); | ||
return this.callexpr(); | ||
} | ||
node.add(this.conscall()); | ||
return node; | ||
}, | ||
conscall: function() { | ||
var node = new Node(Node.CONSCALL); | ||
node.add(this.match(Token.ID, this.look.content() + ' is not a constructor')); | ||
if(this.look) { | ||
if(this.look.content() == '(') { | ||
node.add(this.args()); | ||
} | ||
else if(this.look.content() == '.') { | ||
node.add( | ||
this.match(), | ||
this.conscall() | ||
); | ||
while(this.look && this.look.content() == '.') { | ||
node.add( | ||
newexpr: function(depth) { | ||
depth = depth || 0; | ||
var node = new Node(Node.NEWEXPR); | ||
node.add(this.match('new')); | ||
if(!this.look) { | ||
this.error(); | ||
} | ||
if(this.look.content() == 'new') { | ||
node.add(this.newexpr(depth + 1)); | ||
} | ||
else { | ||
node.add(this.mmbexpr()); | ||
} | ||
if(this.look && this.look.content() == '(') { | ||
node.add(this.args()); | ||
} | ||
if(this.look && ['.', '['].indexOf(this.look.content()) > -1) { | ||
var mmb = new Node(Node.MMBEXPR); | ||
mmb.add(node); | ||
while(this.look) { | ||
if(this.look.content() == '.') { | ||
mmb.add( | ||
this.match(), | ||
this.conscall() | ||
this.match(Token.ID) | ||
); | ||
} | ||
else if(this.look.content() == '[') { | ||
mmb.add( | ||
this.match(), | ||
this.expr(), | ||
this.match(']') | ||
); | ||
} | ||
else { | ||
break; | ||
} | ||
} | ||
if(depth == 0 && this.look && this.look.content() == '(') { | ||
var callexpr = this.callexpr(mmb); | ||
return callexpr; | ||
} | ||
return mmb; | ||
} | ||
return node; | ||
}, | ||
callexpr: function(mmb) { | ||
var node = new Node(Node.CALLEXPR); | ||
mmb = mmb || this.mmbexpr(); | ||
if(this.look && this.look.content() == '(') { | ||
node.add( | ||
mmb, | ||
this.args() | ||
); | ||
if(this.look && ['.', '[', '('].indexOf(this.look.content()) > -1) { | ||
while(this.look) { | ||
if(this.look.content() == '.') { | ||
node.add( | ||
this.match(), | ||
this.match(Token.ID) | ||
); | ||
} | ||
else if(this.look.content() == '[') { | ||
node.add( | ||
this.match(), | ||
this.expr(), | ||
this.match(']') | ||
); | ||
} | ||
else if(this.look.content() == '(') { | ||
node.add(this.args()); | ||
} | ||
else { | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
else { | ||
return mmb; | ||
} | ||
return node; | ||
}, | ||
mmbexpr: function() { | ||
@@ -996,7 +1051,17 @@ var node = new Node(Node.MMBEXPR); | ||
} | ||
var prmrexpr = this.prmrexpr(); | ||
function goOn() { | ||
while(this.look && ['.', '[', '('].indexOf(this.look.content()) != -1) { | ||
var mmb; | ||
if(this.look.content() == 'function') { | ||
mmb = this.fnexpr(); | ||
} | ||
else { | ||
mmb = this.prmrexpr(); | ||
} | ||
if(this.look && ['.', '['].indexOf(this.look.content()) > -1) { | ||
node.add(mmb); | ||
while(this.look) { | ||
if(this.look.content() == '.') { | ||
node.add(this.match(), this.mmbexpr()); | ||
node.add( | ||
this.match(), | ||
this.match(Token.ID) | ||
); | ||
} | ||
@@ -1011,34 +1076,8 @@ else if(this.look.content() == '[') { | ||
else { | ||
node.add(this.args()); | ||
break; | ||
} | ||
} | ||
} | ||
if(this.look) { | ||
if(this.look.content() == '.') { | ||
node.add( | ||
prmrexpr, | ||
this.match(), | ||
this.mmbexpr() | ||
); | ||
goOn.call(this); | ||
} | ||
else if(this.look.content() == '[') { | ||
node.add( | ||
prmrexpr, | ||
this.match(), | ||
this.expr(), | ||
this.match(']') | ||
); | ||
goOn.call(this); | ||
} | ||
else if(this.look.content() == '(') { | ||
node.add(prmrexpr, this.args()); | ||
goOn.call(this); | ||
} | ||
else { | ||
return prmrexpr; | ||
} | ||
} | ||
else { | ||
return prmrexpr; | ||
return mmb; | ||
} | ||
@@ -1062,4 +1101,2 @@ return node; | ||
switch(this.look.content()) { | ||
case 'function': | ||
return this.fnexpr(); | ||
case 'this': | ||
@@ -1223,26 +1260,2 @@ case 'null': | ||
}, | ||
assignoprt: function() { | ||
var node = new Node(Node.ASSIGNOPRT); | ||
switch(this.look.content()) { | ||
case '*=': | ||
case '/=': | ||
case '%=': | ||
case '+=': | ||
case '-=': | ||
case '<<=': | ||
case '>>=': | ||
case '>>>=': | ||
case '&=': | ||
case '^=': | ||
case '|=': | ||
node.add( | ||
this.match(), | ||
this.assignexpr() | ||
); | ||
break; | ||
default: | ||
this.error(); | ||
} | ||
return node; | ||
}, | ||
match: function(type, line, msg) { | ||
@@ -1249,0 +1262,0 @@ if(typeof type == 'boolean') { |
@@ -0,0 +0,0 @@ exports.LINE = '\n'; |
@@ -0,0 +0,0 @@ function inheritPrototype(subType, superType) { |
@@ -0,0 +0,0 @@ function quickSort(arr, begin, end, compare) { |
@@ -0,0 +0,0 @@ var homunculus = require('../homunculus'); |
@@ -101,3 +101,3 @@ var homunculus = require('../homunculus'); | ||
var lexer = homunculus.getLexer('js'); | ||
var code = fs.readFileSync(path.join(__dirname, './jquery-1.11.0.js'), { encoding: 'utf-8' }); | ||
var code = fs.readFileSync(path.join(__dirname, './lib/jquery-1.11.0.js'), { encoding: 'utf-8' }); | ||
var tokens = lexer.parse(code); | ||
@@ -110,3 +110,33 @@ var str = ''; | ||
}); | ||
it('backbone 1.1.0', function() { | ||
var lexer = homunculus.getLexer('js'); | ||
var code = fs.readFileSync(path.join(__dirname, './lib/backbone.js'), { encoding: 'utf-8' }); | ||
var tokens = lexer.parse(code); | ||
var str = ''; | ||
tokens.forEach(function(token) { | ||
str += token.content(); | ||
}); | ||
expect(str).to.eql(code); | ||
}); | ||
it('handlebars', function() { | ||
var lexer = homunculus.getLexer('js'); | ||
var code = fs.readFileSync(path.join(__dirname, './lib/handlebars.js'), { encoding: 'utf-8' }); | ||
var tokens = lexer.parse(code); | ||
var str = ''; | ||
tokens.forEach(function(token) { | ||
str += token.content(); | ||
}); | ||
expect(str).to.eql(code); | ||
}); | ||
it('Uri', function() { | ||
var lexer = homunculus.getLexer('js'); | ||
var code = fs.readFileSync(path.join(__dirname, './lib/Uri.js'), { encoding: 'utf-8' }); | ||
var tokens = lexer.parse(code); | ||
var str = ''; | ||
tokens.forEach(function(token) { | ||
str += token.content(); | ||
}); | ||
expect(str).to.eql(code); | ||
}); | ||
}); | ||
}); |
@@ -97,3 +97,3 @@ var homunculus = require('../homunculus'); | ||
var parser = homunculus.getParser('js'); | ||
var code = fs.readFileSync(path.join(__dirname, './jquery-1.11.0.js'), { encoding: 'utf-8' }); | ||
var code = fs.readFileSync(path.join(__dirname, './lib/jquery-1.11.0.js'), { encoding: 'utf-8' }); | ||
var node = parser.parse(code); | ||
@@ -104,3 +104,43 @@ var ignore = parser.ignore(); | ||
}); | ||
it('backbone 1.1.0', function() { | ||
var parser = homunculus.getParser('js'); | ||
var code = fs.readFileSync(path.join(__dirname, './lib/backbone.js'), { encoding: 'utf-8' }); | ||
var node = parser.parse(code); | ||
var ignore = parser.ignore(); | ||
var str = jion(node, ignore); | ||
expect(str).to.eql(code); | ||
}); | ||
it('handlebars', function() { | ||
var parser = homunculus.getParser('js'); | ||
var code = fs.readFileSync(path.join(__dirname, './lib/handlebars.js'), { encoding: 'utf-8' }); | ||
var node = parser.parse(code); | ||
var ignore = parser.ignore(); | ||
var str = jion(node, ignore); | ||
expect(str).to.eql(code); | ||
}); | ||
it('bootstrap 3.0.0', function() { | ||
var parser = homunculus.getParser('js'); | ||
var code = fs.readFileSync(path.join(__dirname, './lib/bootstrap.js'), { encoding: 'utf-8' }); | ||
var node = parser.parse(code); | ||
var ignore = parser.ignore(); | ||
var str = jion(node, ignore); | ||
expect(str).to.eql(code); | ||
}); | ||
it('expect 0.1.2', function() { | ||
var parser = homunculus.getParser('js'); | ||
var code = fs.readFileSync(path.join(__dirname, './lib/expect.js'), { encoding: 'utf-8' }); | ||
var node = parser.parse(code); | ||
var ignore = parser.ignore(); | ||
var str = jion(node, ignore); | ||
expect(str).to.eql(code); | ||
}); | ||
it('html5shiv 3.6.1', function() { | ||
var parser = homunculus.getParser('js'); | ||
var code = fs.readFileSync(path.join(__dirname, './lib/html5shiv.js'), { encoding: 'utf-8' }); | ||
var node = parser.parse(code); | ||
var ignore = parser.ignore(); | ||
var str = jion(node, ignore); | ||
expect(str).to.eql(code); | ||
}); | ||
}); | ||
}); |
@@ -0,0 +0,0 @@ var fs = require('fs'); |
@@ -0,0 +0,0 @@ define(function(require, exports, module) { |
@@ -0,0 +0,0 @@ define(function(require, exports, module) { |
@@ -0,0 +0,0 @@ define(function(require, exports, module) { |
@@ -0,0 +0,0 @@ define(function(require, exports, module) { |
@@ -0,0 +0,0 @@ define(function(require, exports, module) { |
define(function(require, exports, module) { | ||
var Class = require('../../util/Class'); | ||
var Node = Class(function(type, children) { | ||
this.type = type; | ||
if(type == Node.TOKEN) { | ||
this.children = children; | ||
this.type = type; | ||
if(type == Node.TOKEN) { | ||
this.children = children; | ||
} | ||
else if(Array.isArray(children)) { | ||
this.children = children; | ||
} | ||
else { | ||
this.children = children ? [children] : []; | ||
} | ||
this.p = null; | ||
this.pr = null; | ||
this.ne = null; | ||
return this; | ||
}).methods({ | ||
name: function() { | ||
return this.type; | ||
}, | ||
leaves: function() { | ||
return this.children; | ||
}, | ||
add: function() { | ||
var self = this; | ||
var args = Array.prototype.slice.call(arguments, 0); | ||
args.forEach(function(node) { | ||
node.parent(self); | ||
var last = self.children[self.children.length - 1]; | ||
if(last) { | ||
last.next(node); | ||
node.prev(last); | ||
} | ||
self.children.push(node); | ||
}); | ||
return self; | ||
}, | ||
token: function() { | ||
return this.children; | ||
}, | ||
parent: function(p) { | ||
if(p) { | ||
this.p = p; | ||
} | ||
else if(Array.isArray(children)) { | ||
this.children = children; | ||
return this.p; | ||
}, | ||
prev: function(pr) { | ||
if(pr) { | ||
this.pr = pr; | ||
} | ||
else { | ||
this.children = children ? [children] : []; | ||
return this.pr; | ||
}, | ||
next: function(ne) { | ||
if(ne) { | ||
this.ne = ne; | ||
} | ||
return this; | ||
}).methods({ | ||
name: function() { | ||
return this.type; | ||
}, | ||
leaves: function() { | ||
return this.children; | ||
}, | ||
add: function() { | ||
var self = this, | ||
args = Array.prototype.slice.call(arguments, 0); | ||
args.forEach(function(node) { | ||
if(Array.isArray(node)) { | ||
self.children = self.children.concat(node); | ||
} | ||
else { | ||
self.children.push(node); | ||
} | ||
}); | ||
return self; | ||
}, | ||
token: function() { | ||
return this.children; | ||
} | ||
}).statics({ | ||
PROGRAM: 'program', | ||
ELEMS: 'elems', | ||
ELEM: 'elem', | ||
CSTSTMT: 'cststmt', | ||
LETSTMT: 'letstmt', | ||
VARSTMT: 'varstmt', | ||
VARDECL: 'vardecl', | ||
FNBODY: 'fnbody', | ||
BLOCK: 'block', | ||
ITERSTMT: 'iterstmt', | ||
TOKEN: 'token', | ||
FNPARAMS: 'fnparams', | ||
BINDELEMENT: 'bindelement', | ||
RESTPARAM: 'restparam', | ||
EXPR: 'expr', | ||
CLASSDECL: 'classdecl', | ||
CLASSTAIL: 'classtail', | ||
HERITAGE: 'heritage', | ||
CLASSBODY: 'classbody', | ||
METHOD: 'method', | ||
SUPERSTMT: 'superstmt', | ||
GETFN: 'getfn', | ||
SETFN: 'setfn', | ||
PROGRAM: 'program', | ||
STMT: 'stmt', | ||
ASSIGN: 'assign', | ||
EMPTSTMT: 'emptstmt', | ||
IFSTMT: 'ifstmt', | ||
CNTNSTMT: 'cntnstmt', | ||
BRKSTMT: 'brkstmt', | ||
RETSTMT: 'retstmt', | ||
WITHSTMT: 'withstmt', | ||
SWCHSTMT: 'swchstmt', | ||
CASEBLOCK: 'caseblock', | ||
CASECLAUSE: 'caseclause', | ||
DFTCLAUSE: 'dftclause', | ||
LABSTMT: 'labstmt', | ||
THRSTMT: 'thrstmt', | ||
TRYSTMT: 'trystmt', | ||
DEBSTMT: 'debstmt', | ||
CACH: 'cach', | ||
FINL: 'finl', | ||
FNDECL: 'fndecl', | ||
FNEXPR: 'fnexpr', | ||
ASSIGNEXPR: 'assignexpr', | ||
CNDTEXPR: 'cndtexpr', | ||
LOGOREXPR: 'logorexpr', | ||
LOGANDEXPR: 'logandexpr', | ||
BITOREXPR: 'bitorexpr', | ||
BITANDEXPR: 'bitandexpr', | ||
BITXOREXPR: 'bitxorexpr', | ||
EQEXPR: 'eqexpr', | ||
RELTEXPR: 'reltexpr', | ||
SHIFTEXPR: 'shiftexpr', | ||
ADDEXPR: 'addexpr', | ||
MTPLEXPR: 'mtplexpr', | ||
UNARYEXPR: 'unaryexpr', | ||
CONSTOR: 'constor', | ||
CONSCALL: 'conscall', | ||
MMBEXPR: 'mmbexpr', | ||
PRMREXPR: 'prmrexpr', | ||
ARRLTR: 'arrltr', | ||
OBJLTR: 'objltr', | ||
PROPTASSIGN: 'proptassign', | ||
PROPTNAME: 'proptname', | ||
PROPTSETS: 'propsets', | ||
ARGS: 'args', | ||
ARGLIST: 'arglist', | ||
ASSIGNOPRT: 'assignoprt', | ||
IMPTSTMT: 'imptstmt' | ||
}); | ||
return this.ne; | ||
} | ||
}).statics({ | ||
PROGRAM: 'program', | ||
ELEMS: 'elems', | ||
ELEM: 'elem', | ||
CSTSTMT: 'cststmt', | ||
LETSTMT: 'letstmt', | ||
VARSTMT: 'varstmt', | ||
VARDECL: 'vardecl', | ||
FNBODY: 'fnbody', | ||
BLOCK: 'block', | ||
ITERSTMT: 'iterstmt', | ||
TOKEN: 'token', | ||
FNPARAMS: 'fnparams', | ||
BINDELEMENT: 'bindelement', | ||
RESTPARAM: 'restparam', | ||
EXPR: 'expr', | ||
CLASSDECL: 'classdecl', | ||
CLASSTAIL: 'classtail', | ||
HERITAGE: 'heritage', | ||
CLASSBODY: 'classbody', | ||
METHOD: 'method', | ||
SUPERSTMT: 'superstmt', | ||
GETFN: 'getfn', | ||
SETFN: 'setfn', | ||
PROGRAM: 'program', | ||
STMT: 'stmt', | ||
ASSIGN: 'assign', | ||
EMPTSTMT: 'emptstmt', | ||
IFSTMT: 'ifstmt', | ||
CNTNSTMT: 'cntnstmt', | ||
BRKSTMT: 'brkstmt', | ||
RETSTMT: 'retstmt', | ||
WITHSTMT: 'withstmt', | ||
SWCHSTMT: 'swchstmt', | ||
CASEBLOCK: 'caseblock', | ||
CASECLAUSE: 'caseclause', | ||
DFTCLAUSE: 'dftclause', | ||
LABSTMT: 'labstmt', | ||
THRSTMT: 'thrstmt', | ||
TRYSTMT: 'trystmt', | ||
DEBSTMT: 'debstmt', | ||
CACH: 'cach', | ||
FINL: 'finl', | ||
FNDECL: 'fndecl', | ||
FNEXPR: 'fnexpr', | ||
ASSIGNEXPR: 'assignexpr', | ||
CNDTEXPR: 'cndtexpr', | ||
LOGOREXPR: 'logorexpr', | ||
LOGANDEXPR: 'logandexpr', | ||
BITOREXPR: 'bitorexpr', | ||
BITANDEXPR: 'bitandexpr', | ||
BITXOREXPR: 'bitxorexpr', | ||
EQEXPR: 'eqexpr', | ||
RELTEXPR: 'reltexpr', | ||
SHIFTEXPR: 'shiftexpr', | ||
ADDEXPR: 'addexpr', | ||
MTPLEXPR: 'mtplexpr', | ||
UNARYEXPR: 'unaryexpr', | ||
MMBEXPR: 'mmbexpr', | ||
PRMREXPR: 'prmrexpr', | ||
ARRLTR: 'arrltr', | ||
OBJLTR: 'objltr', | ||
PROPTASSIGN: 'proptassign', | ||
PROPTNAME: 'proptname', | ||
PROPTSETS: 'propsets', | ||
ARGS: 'args', | ||
ARGLIST: 'arglist', | ||
IMPTSTMT: 'imptstmt', | ||
POSTFIXEXPR: 'postfixexpr', | ||
NEWEXPR: 'newexpr', | ||
CALLEXPR: 'callexpr' | ||
}); | ||
module.exports = Node; | ||
}); |
@@ -934,59 +934,114 @@ define(function(require, exports, module) { | ||
break; | ||
case 'new': | ||
node.add( | ||
this.match(), | ||
this.constor() | ||
); | ||
break; | ||
default: | ||
var mmbexpr = this.mmbexpr(); | ||
if(this.look && ['++', '--'].indexOf(this.look.content()) != -1) { | ||
node.add(mmbexpr, this.match()); | ||
return node; | ||
} | ||
else { | ||
return mmbexpr; | ||
} | ||
return this.postfixexpr(); | ||
} | ||
return node; | ||
}, | ||
constor: function() { | ||
var node = new Node(Node.CONSTOR); | ||
postfixexpr: function() { | ||
var node = new Node(Node.POSTFIXEXPR); | ||
var leftexpr = this.leftexpr(); | ||
if(this.look && ['++', '--'].indexOf(this.look.content()) > -1 && !this.hasMoveLine) { | ||
node.add(leftexpr); | ||
while(this.look && ['++', '--'].indexOf(this.look.content()) > -1) { | ||
node.add(this.match(undefined, true)); | ||
} | ||
} | ||
else { | ||
return leftexpr; | ||
} | ||
return node; | ||
}, | ||
leftexpr: function() { | ||
if(!this.look) { | ||
this.error(); | ||
} | ||
if(this.look.content() == 'this') { | ||
node.add( | ||
this.match(), | ||
this.match('.') | ||
); | ||
if(this.look.content() == 'new') { | ||
return this.newexpr(); | ||
} | ||
else { | ||
return this.conscall(); | ||
return this.callexpr(); | ||
} | ||
node.add(this.conscall()); | ||
return node; | ||
}, | ||
conscall: function() { | ||
var node = new Node(Node.CONSCALL); | ||
node.add(this.match(Token.ID, this.look.content() + ' is not a constructor')); | ||
if(this.look) { | ||
if(this.look.content() == '(') { | ||
node.add(this.args()); | ||
} | ||
else if(this.look.content() == '.') { | ||
node.add( | ||
this.match(), | ||
this.conscall() | ||
); | ||
while(this.look && this.look.content() == '.') { | ||
node.add( | ||
newexpr: function(depth) { | ||
depth = depth || 0; | ||
var node = new Node(Node.NEWEXPR); | ||
node.add(this.match('new')); | ||
if(!this.look) { | ||
this.error(); | ||
} | ||
if(this.look.content() == 'new') { | ||
node.add(this.newexpr(depth + 1)); | ||
} | ||
else { | ||
node.add(this.mmbexpr()); | ||
} | ||
if(this.look && this.look.content() == '(') { | ||
node.add(this.args()); | ||
} | ||
if(this.look && ['.', '['].indexOf(this.look.content()) > -1) { | ||
var mmb = new Node(Node.MMBEXPR); | ||
mmb.add(node); | ||
while(this.look) { | ||
if(this.look.content() == '.') { | ||
mmb.add( | ||
this.match(), | ||
this.conscall() | ||
this.match(Token.ID) | ||
); | ||
} | ||
else if(this.look.content() == '[') { | ||
mmb.add( | ||
this.match(), | ||
this.expr(), | ||
this.match(']') | ||
); | ||
} | ||
else { | ||
break; | ||
} | ||
} | ||
if(depth == 0 && this.look && this.look.content() == '(') { | ||
var callexpr = this.callexpr(mmb); | ||
return callexpr; | ||
} | ||
return mmb; | ||
} | ||
return node; | ||
}, | ||
callexpr: function(mmb) { | ||
var node = new Node(Node.CALLEXPR); | ||
mmb = mmb || this.mmbexpr(); | ||
if(this.look && this.look.content() == '(') { | ||
node.add( | ||
mmb, | ||
this.args() | ||
); | ||
if(this.look && ['.', '[', '('].indexOf(this.look.content()) > -1) { | ||
while(this.look) { | ||
if(this.look.content() == '.') { | ||
node.add( | ||
this.match(), | ||
this.match(Token.ID) | ||
); | ||
} | ||
else if(this.look.content() == '[') { | ||
node.add( | ||
this.match(), | ||
this.expr(), | ||
this.match(']') | ||
); | ||
} | ||
else if(this.look.content() == '(') { | ||
node.add(this.args()); | ||
} | ||
else { | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
else { | ||
return mmb; | ||
} | ||
return node; | ||
}, | ||
mmbexpr: function() { | ||
@@ -997,7 +1052,17 @@ var node = new Node(Node.MMBEXPR); | ||
} | ||
var prmrexpr = this.prmrexpr(); | ||
function goOn() { | ||
while(this.look && ['.', '[', '('].indexOf(this.look.content()) != -1) { | ||
var mmb; | ||
if(this.look.content() == 'function') { | ||
mmb = this.fnexpr(); | ||
} | ||
else { | ||
mmb = this.prmrexpr(); | ||
} | ||
if(this.look && ['.', '['].indexOf(this.look.content()) > -1) { | ||
node.add(mmb); | ||
while(this.look) { | ||
if(this.look.content() == '.') { | ||
node.add(this.match(), this.mmbexpr()); | ||
node.add( | ||
this.match(), | ||
this.match(Token.ID) | ||
); | ||
} | ||
@@ -1012,34 +1077,8 @@ else if(this.look.content() == '[') { | ||
else { | ||
node.add(this.args()); | ||
break; | ||
} | ||
} | ||
} | ||
if(this.look) { | ||
if(this.look.content() == '.') { | ||
node.add( | ||
prmrexpr, | ||
this.match(), | ||
this.mmbexpr() | ||
); | ||
goOn.call(this); | ||
} | ||
else if(this.look.content() == '[') { | ||
node.add( | ||
prmrexpr, | ||
this.match(), | ||
this.expr(), | ||
this.match(']') | ||
); | ||
goOn.call(this); | ||
} | ||
else if(this.look.content() == '(') { | ||
node.add(prmrexpr, this.args()); | ||
goOn.call(this); | ||
} | ||
else { | ||
return prmrexpr; | ||
} | ||
} | ||
else { | ||
return prmrexpr; | ||
return mmb; | ||
} | ||
@@ -1063,4 +1102,2 @@ return node; | ||
switch(this.look.content()) { | ||
case 'function': | ||
return this.fnexpr(); | ||
case 'this': | ||
@@ -1224,26 +1261,2 @@ case 'null': | ||
}, | ||
assignoprt: function() { | ||
var node = new Node(Node.ASSIGNOPRT); | ||
switch(this.look.content()) { | ||
case '*=': | ||
case '/=': | ||
case '%=': | ||
case '+=': | ||
case '-=': | ||
case '<<=': | ||
case '>>=': | ||
case '>>>=': | ||
case '&=': | ||
case '^=': | ||
case '|=': | ||
node.add( | ||
this.match(), | ||
this.assignexpr() | ||
); | ||
break; | ||
default: | ||
this.error(); | ||
} | ||
return node; | ||
}, | ||
match: function(type, line, msg) { | ||
@@ -1250,0 +1263,0 @@ if(typeof type == 'boolean') { |
@@ -0,0 +0,0 @@ define(function(require, exports, module) { |
@@ -0,0 +0,0 @@ define(function(require, exports, module) { |
@@ -0,0 +0,0 @@ define(function(require, exports, module) { |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Mixed license
License(Experimental) Package contains multiple licenses.
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
941323
72
25354
1
10
5