homunculus
Advanced tools
Comparing version
@@ -0,0 +0,0 @@ (function() { |
@@ -0,0 +0,0 @@ var gulp = require('gulp'); |
@@ -0,0 +0,0 @@ var Lexer = require('./src/lexer/Lexer'); |
{ | ||
"name": "homunculus", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "A lexer&parser by Javascript", | ||
@@ -5,0 +5,0 @@ "maintainers": [ |
@@ -0,0 +0,0 @@ var Lexer = require('./Lexer'); |
@@ -45,3 +45,3 @@ var Class = require('../util/Class'); | ||
if(match.match(this.peek, this.code, this.index)) { | ||
var token = new Token(match.tokenType(), match.content(), match.val(), this.sIndex++, this.index - 1); | ||
var token = new Token(match.tokenType(), match.content(), match.val(), this.index - 1); | ||
var error = match.error(); | ||
@@ -156,3 +156,3 @@ var matchLen = match.content().length; | ||
} | ||
var token = new Token(Token.REG, this.code.slice(lastIndex, --this.index), this.sIndex++, lastIndex); | ||
var token = new Token(Token.REG, this.code.slice(lastIndex, --this.index), lastIndex); | ||
temp.push(token); | ||
@@ -211,3 +211,2 @@ this.tokenList.push(token); | ||
this.colMax = 0; //最大列数 | ||
this.sIndex = 0; //token的索引 | ||
} | ||
@@ -214,0 +213,0 @@ }).statics({ |
@@ -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'); |
var Class = require('../util/Class'); | ||
var character = require('../util/character'); | ||
var tid = 0; | ||
var types; | ||
var Token = Class(function(type, content, val, index, sIndex) { | ||
var Token = Class(function(type, content, val, sIndex) { | ||
this.t = type; //token类型 | ||
this.c = content; //token的字面内容,string包括头尾的引号 | ||
if(character.isNumber(val)) { | ||
sIndex = index; | ||
index = val; | ||
sIndex = val; | ||
val = content; | ||
@@ -14,6 +14,6 @@ } | ||
val = content; | ||
index = sIndex = -1; | ||
sIndex = -1; | ||
} | ||
this.v = val; //token的值,一般情况下等于content,特殊如string情况下值是不加头尾的引号 | ||
this.i = index; //token的索引 | ||
this.id = tid++; //token的索引 | ||
this.si = sIndex; //token在源码字符串中的索引 | ||
@@ -45,7 +45,7 @@ }).methods({ | ||
}, | ||
index: function(i) { | ||
if(!character.isUndefined(i)) { | ||
this.i = i; | ||
tid: function(id) { | ||
if(!character.isUndefined(id)) { | ||
this.id = id; | ||
} | ||
return this.i; | ||
return this.id; | ||
}, | ||
@@ -52,0 +52,0 @@ sIndex: function(si) { |
@@ -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'); |
@@ -0,0 +0,0 @@ var Class = require('../../util/Class'); |
@@ -0,0 +0,0 @@ var Class = require('../../util/Class'); |
@@ -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'); |
@@ -108,12 +108,12 @@ var homunculus = require('../homunculus'); | ||
it('tokens index 1', function() { | ||
expect(tokens[0].index()).to.eql(0); | ||
expect(tokens[0].tid()).to.eql(0); | ||
}); | ||
it('tokens index 2', function() { | ||
expect(tokens[1].index()).to.eql(1); | ||
expect(tokens[1].tid()).to.eql(1); | ||
}); | ||
it('tokens index 3', function() { | ||
expect(tokens[6].index()).to.eql(6); | ||
expect(tokens[6].tid()).to.eql(6); | ||
}); | ||
it('tokens index 4', function() { | ||
expect(tokens[13].index()).to.eql(13); | ||
expect(tokens[13].tid()).to.eql(13); | ||
}); | ||
@@ -120,0 +120,0 @@ it('tokens sIndex 1', function() { |
@@ -0,0 +0,0 @@ //javascript |
@@ -0,0 +0,0 @@ ["//javascript", |
@@ -0,0 +0,0 @@ // Simple JavaScript Templating |
@@ -0,0 +0,0 @@ ["// Simple JavaScript Templating", |
@@ -0,0 +0,0 @@ function f(test) { |
@@ -0,0 +0,0 @@ ["function", |
@@ -0,0 +0,0 @@ // Backbone.js 1.1.0 |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ |
@@ -0,0 +0,0 @@ /*! HTML5 Shiv v3.6.1 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed */ |
@@ -0,0 +0,0 @@ /*! |
@@ -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) { |
@@ -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) { |
@@ -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
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
901002
3.06%23547
0