homunculus
Advanced tools
Comparing version 0.10.1 to 0.10.2
{ | ||
"name": "homunculus", | ||
"version": "0.10.1", | ||
"version": "0.10.2", | ||
"description": "A lexer&parser by Javascript", | ||
@@ -5,0 +5,0 @@ "maintainers": [ |
@@ -22,3 +22,3 @@ var character = require('../util/character'); | ||
new RegMatch(JSXToken.NUMBER, /^\d+(?:\.\d*)?/), | ||
new RegMatch(JSXToken.PROPERTY, /^[a-z]+(?:-\w+)*/i) | ||
new RegMatch(JSXToken.PROPERTY, /^[a-z]\w*(?:-\w+)*/i) | ||
]; | ||
@@ -54,3 +54,4 @@ | ||
this.jStack = []; //当{开始时++,}减少时--,以此得知js部分结束回归jsx | ||
this.aStack = []; //当[开始时++,]减少时--,以此得知js部分结束回归jsx | ||
this.aStack = []; //html和js互相递归时,记录当前层是否在attr状态中 | ||
this.cStack = []; //html和js互相递归时,记录当前jsx标签是否是自闭和 | ||
this.selfClose = false; //当前jsx标签是否是自闭和 | ||
@@ -112,2 +113,4 @@ }, | ||
this.jStack.push(1); | ||
this.cStack.push(this.selfClose); | ||
this.aStack.push(this.state); | ||
var token = new JSXToken(JSXToken.SIGN, this.peek, this.peek); | ||
@@ -117,10 +120,2 @@ this.dealToken(token, 1, 0, temp); | ||
} | ||
//[递归进入js状态 | ||
else if(this.peek == '[') { | ||
this.html = false; | ||
this.braceState = false; | ||
this.aStack.push(1); | ||
var token = new JSXToken(JSXToken.SIGN, this.peek, this.peek); | ||
this.dealToken(token, 1, 0, temp); | ||
} | ||
else { | ||
@@ -178,3 +173,3 @@ for(var i = 0, len = JSXMatch.length; i < len; i++) { | ||
//\w elem | ||
this.dealTag(temp); | ||
this.dealTag(temp, true); | ||
} | ||
@@ -274,3 +269,3 @@ //<\w | ||
} | ||
//处理{和[ | ||
//处理{ | ||
this.stateBrace(match.content(), token.type()); | ||
@@ -293,3 +288,3 @@ this.xBrace(match.content()); | ||
}, | ||
dealTag: function(temp) { | ||
dealTag: function(temp, end) { | ||
ELEM.match(this.peek, this.code, this.index); | ||
@@ -299,8 +294,10 @@ var token = new JSXToken(ELEM.tokenType(), ELEM.content(), ELEM.val(), this.index - 1); | ||
this.dealToken(token, matchLen, 0, temp); | ||
//自闭和没有.和: | ||
if(SELF_CLOSE.hasOwnProperty(token.content().toLowerCase())) { | ||
this.selfClose = true; | ||
return; | ||
if(!end) { | ||
//自闭和没有.和: | ||
if(SELF_CLOSE.hasOwnProperty(token.content().toLowerCase())) { | ||
this.selfClose = true; | ||
return; | ||
} | ||
this.selfClose = false; | ||
} | ||
this.selfClose = false; | ||
var c = this.code.charAt(this.index); | ||
@@ -357,2 +354,4 @@ if(c == '.') { | ||
this.html = true; | ||
this.selfClose = this.cStack.pop(); | ||
this.state = this.aStack.pop(); | ||
this.jStack.pop(); | ||
@@ -362,16 +361,2 @@ } | ||
} | ||
else if(content == '[') { | ||
if(this.aStack.length) { | ||
this.aStack[this.aStack.length - 1]++; | ||
} | ||
} | ||
else if(content == ']') { | ||
if(this.aStack.length) { | ||
this.aStack[this.aStack.length - 1]--; | ||
if(this.aStack[this.aStack.length - 1] == 0) { | ||
this.html = true; | ||
this.aStack.pop(); | ||
} | ||
} | ||
} | ||
} | ||
@@ -378,0 +363,0 @@ }).statics({ |
@@ -22,3 +22,3 @@ define(function(require, exports, module) {var character = require('../util/character'); | ||
new RegMatch(JSXToken.NUMBER, /^\d+(?:\.\d*)?/), | ||
new RegMatch(JSXToken.PROPERTY, /^[a-z]+(?:-\w+)*/i) | ||
new RegMatch(JSXToken.PROPERTY, /^[a-z]\w*(?:-\w+)*/i) | ||
]; | ||
@@ -54,3 +54,4 @@ | ||
this.jStack = []; //当{开始时++,}减少时--,以此得知js部分结束回归jsx | ||
this.aStack = []; //当[开始时++,]减少时--,以此得知js部分结束回归jsx | ||
this.aStack = []; //html和js互相递归时,记录当前层是否在attr状态中 | ||
this.cStack = []; //html和js互相递归时,记录当前jsx标签是否是自闭和 | ||
this.selfClose = false; //当前jsx标签是否是自闭和 | ||
@@ -112,2 +113,4 @@ }, | ||
this.jStack.push(1); | ||
this.cStack.push(this.selfClose); | ||
this.aStack.push(this.state); | ||
var token = new JSXToken(JSXToken.SIGN, this.peek, this.peek); | ||
@@ -117,10 +120,2 @@ this.dealToken(token, 1, 0, temp); | ||
} | ||
//[递归进入js状态 | ||
else if(this.peek == '[') { | ||
this.html = false; | ||
this.braceState = false; | ||
this.aStack.push(1); | ||
var token = new JSXToken(JSXToken.SIGN, this.peek, this.peek); | ||
this.dealToken(token, 1, 0, temp); | ||
} | ||
else { | ||
@@ -178,3 +173,3 @@ for(var i = 0, len = JSXMatch.length; i < len; i++) { | ||
//\w elem | ||
this.dealTag(temp); | ||
this.dealTag(temp, true); | ||
} | ||
@@ -274,3 +269,3 @@ //<\w | ||
} | ||
//处理{和[ | ||
//处理{ | ||
this.stateBrace(match.content(), token.type()); | ||
@@ -293,3 +288,3 @@ this.xBrace(match.content()); | ||
}, | ||
dealTag: function(temp) { | ||
dealTag: function(temp, end) { | ||
ELEM.match(this.peek, this.code, this.index); | ||
@@ -299,8 +294,10 @@ var token = new JSXToken(ELEM.tokenType(), ELEM.content(), ELEM.val(), this.index - 1); | ||
this.dealToken(token, matchLen, 0, temp); | ||
//自闭和没有.和: | ||
if(SELF_CLOSE.hasOwnProperty(token.content().toLowerCase())) { | ||
this.selfClose = true; | ||
return; | ||
if(!end) { | ||
//自闭和没有.和: | ||
if(SELF_CLOSE.hasOwnProperty(token.content().toLowerCase())) { | ||
this.selfClose = true; | ||
return; | ||
} | ||
this.selfClose = false; | ||
} | ||
this.selfClose = false; | ||
var c = this.code.charAt(this.index); | ||
@@ -357,2 +354,4 @@ if(c == '.') { | ||
this.html = true; | ||
this.selfClose = this.cStack.pop(); | ||
this.state = this.aStack.pop(); | ||
this.jStack.pop(); | ||
@@ -362,16 +361,2 @@ } | ||
} | ||
else if(content == '[') { | ||
if(this.aStack.length) { | ||
this.aStack[this.aStack.length - 1]++; | ||
} | ||
} | ||
else if(content == ']') { | ||
if(this.aStack.length) { | ||
this.aStack[this.aStack.length - 1]--; | ||
if(this.aStack[this.aStack.length - 1] == 0) { | ||
this.html = true; | ||
this.aStack.pop(); | ||
} | ||
} | ||
} | ||
} | ||
@@ -378,0 +363,0 @@ }).statics({ |
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
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
697790
19217