homunculus
Advanced tools
Comparing version 0.8.2 to 0.8.3
{ | ||
"name": "homunculus", | ||
"version": "0.8.2", | ||
"version": "0.8.3", | ||
"description": "A lexer&parser by Javascript", | ||
@@ -5,0 +5,0 @@ "maintainers": [ |
@@ -111,2 +111,4 @@ # A lexer&parser by Javascript | ||
* isVirtual():Boolean 返回此token是否是虚拟不存在的 | ||
* line():int 此token位于多少行 | ||
* col():int 此token位于多少列 | ||
@@ -113,0 +115,0 @@ #### 静态属性 |
@@ -38,2 +38,3 @@ var Lexer = require('./Lexer'); | ||
var count = 0; | ||
this.colNum = length ? 1 : 0; | ||
outer: | ||
@@ -523,2 +524,4 @@ while(this.index < length) { | ||
this.index += matchLen - 1; | ||
token.line(this.totalLine); | ||
token.col(this.colNum); | ||
var n = character.count(token.val(), character.LINE); | ||
@@ -560,3 +563,7 @@ count += n; | ||
this.tokenList.push(token); | ||
token.line(this.totalLine); | ||
token.col(this.colNum); | ||
this.index = j; | ||
this.colNum += this.index - s.length; | ||
this.colMax = Math.max(this.colMax, this.colNum); | ||
} | ||
@@ -572,2 +579,4 @@ return this; | ||
this.tokenList.push(token); | ||
token.line(this.totalLine); | ||
token.col(this.colNum); | ||
this.index = this.code.length; | ||
@@ -604,2 +613,4 @@ var n = character.count(token.val(), character.LINE); | ||
this.tokenList.push(token); | ||
token.line(this.totalLine); | ||
token.col(this.colNum); | ||
this.index += s.length - 1; | ||
@@ -606,0 +617,0 @@ this.parenthese = false; |
@@ -40,2 +40,3 @@ var Class = require('../util/Class'); | ||
var count = 0; | ||
this.colNum = length ? 1 : 0; | ||
outer: | ||
@@ -54,3 +55,7 @@ while(this.index < length) { | ||
this.tokenList.push(token); | ||
token.line(this.totalLine); | ||
token.col(this.colNum); | ||
this.index2 = ++this.index; | ||
this.colNum += 2; | ||
this.colMax = Math.max(this.colMax, this.colNum); | ||
continue; | ||
@@ -67,3 +72,7 @@ } | ||
this.tokenList.push(token); | ||
token.line(this.totalLine); | ||
token.col(this.colNum); | ||
this.index2 = this.index; | ||
this.colNum++; | ||
this.colMax = Math.max(this.colMax, this.colNum); | ||
continue; | ||
@@ -98,2 +107,4 @@ } | ||
this.tokenList.push(token); | ||
token.line(this.totalLine); | ||
token.col(this.colNum); | ||
this.index2 = this.index += matchLen - 1; | ||
@@ -152,2 +163,4 @@ var n = character.count(token.val(), character.LINE); | ||
this.tokenList.push(token); | ||
token.line(this.totalLine); | ||
token.col(this.colNum); | ||
this.index2 = this.index = end; | ||
@@ -166,2 +179,4 @@ } | ||
this.tokenList.push(token); | ||
token.line(this.totalLine); | ||
token.col(this.colNum); | ||
this.index2 = this.index = idx + 2; | ||
@@ -185,2 +200,4 @@ } | ||
this.tokenList.push(token); | ||
token.line(this.totalLine); | ||
token.col(this.colNum); | ||
this.index2 = this.index = idx + 1; | ||
@@ -214,2 +231,16 @@ } | ||
this.tokenList.push(token); | ||
token.line(this.totalLine); | ||
token.col(this.colNum); | ||
var n = character.count(token.val(), character.LINE); | ||
this.totalLine += n; | ||
if(n) { | ||
var j = s.indexOf(character.LINE); | ||
var k = s.lastIndexOf(character.LINE); | ||
this.colMax = Math.max(this.colMax, this.colNum + j); | ||
this.colNum = s.length - k; | ||
} | ||
else { | ||
this.colNum += s.length; | ||
} | ||
this.colMax = Math.max(this.colMax, this.colNum); | ||
}, | ||
@@ -216,0 +247,0 @@ readch: function() { |
@@ -44,2 +44,3 @@ var Class = require('../util/Class'); | ||
var count = 0; | ||
this.colNum = length ? 1 : 0; | ||
outer: | ||
@@ -93,2 +94,4 @@ while(this.index < length) { | ||
this.index += matchLen - 1; | ||
token.line(this.totalLine); | ||
token.col(this.colNum); | ||
var n = character.count(token.val(), character.LINE); | ||
@@ -208,2 +211,4 @@ count += n; | ||
this.tokenList.push(token); | ||
token.line(this.totalLine); | ||
token.col(this.colNum); | ||
this.colNum += this.index - lastIndex; | ||
@@ -210,0 +215,0 @@ this.colMax = Math.max(this.colMax, this.colNum); |
@@ -10,2 +10,4 @@ var Class = require('../util/Class'); | ||
this.ne = null; | ||
this.li = -1; | ||
this.co = -1; | ||
if(character.isNumber(val)) { | ||
@@ -76,2 +78,14 @@ sIndex = val; | ||
return this.t == Token.VIRTUAL; | ||
}, | ||
line: function(i) { | ||
if(i !== undefined) { | ||
this.li = i; | ||
} | ||
return this.li; | ||
}, | ||
col: function(i) { | ||
if(i !== undefined) { | ||
this.co = i; | ||
} | ||
return this.co; | ||
} | ||
@@ -78,0 +92,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
1245904
17848
163