homunculus
Advanced tools
Comparing version 0.6.6 to 0.6.7
{ | ||
"name": "homunculus", | ||
"version": "0.6.6", | ||
"version": "0.6.7", | ||
"description": "A lexer&parser by Javascript", | ||
@@ -5,0 +5,0 @@ "maintainers": [ |
@@ -72,4 +72,9 @@ var Class = require('../util/Class'); | ||
if(match.callback) { | ||
match.callback(token); | ||
match.callback.call(match, token, this.tokenList); | ||
} | ||
//回调特殊处理忽略掉此次匹配 | ||
if(match.cancel) { | ||
token.cancel(); | ||
continue; | ||
} | ||
@@ -76,0 +81,0 @@ if(this.last) { |
@@ -22,2 +22,17 @@ var Rule = require('./Rule'); | ||
self.addMatch(new LineSearch(Token.COMMENT, '//', [character.ENTER + character.LINE, character.ENTER, character.LINE])); | ||
self.addMatch(new LineSearch(Token.COMMENT, '<!--', [character.ENTER + character.LINE, character.ENTER, character.LINE])); | ||
var htmlEndComment = new LineSearch(Token.COMMENT, '-->', [character.ENTER + character.LINE, character.ENTER, character.LINE]); | ||
htmlEndComment.callback = function(token, tokenList) { | ||
for(var i = tokenList.length - 1; i >= 0; i--) { | ||
var t = tokenList[i]; | ||
if([Token.LINE, Token.ENTER].indexOf(t.type()) > -1) { | ||
return; | ||
} | ||
else if([Token.COMMENT, Token.BLANK, Token.TAB].indexOf(t.type()) == -1) { | ||
this.cancel = true; | ||
return; | ||
} | ||
} | ||
}; | ||
self.addMatch(htmlEndComment); | ||
self.addMatch(new LineSearch(Token.COMMENT, '/*', '*/', true)); | ||
@@ -24,0 +39,0 @@ self.addMatch(new LineParse(Token.STRING, '"', '"', false, Lexer.IS_REG)); |
@@ -72,4 +72,9 @@ define(function(require, exports, module) {var Class = require('../util/Class'); | ||
if(match.callback) { | ||
match.callback(token); | ||
match.callback.call(match, token, this.tokenList); | ||
} | ||
//回调特殊处理忽略掉此次匹配 | ||
if(match.cancel) { | ||
token.cancel(); | ||
continue; | ||
} | ||
@@ -76,0 +81,0 @@ if(this.last) { |
@@ -22,2 +22,17 @@ define(function(require, exports, module) {var Rule = require('./Rule'); | ||
self.addMatch(new LineSearch(Token.COMMENT, '//', [character.ENTER + character.LINE, character.ENTER, character.LINE])); | ||
self.addMatch(new LineSearch(Token.COMMENT, '<!--', [character.ENTER + character.LINE, character.ENTER, character.LINE])); | ||
var htmlEndComment = new LineSearch(Token.COMMENT, '-->', [character.ENTER + character.LINE, character.ENTER, character.LINE]); | ||
htmlEndComment.callback = function(token, tokenList) { | ||
for(var i = tokenList.length - 1; i >= 0; i--) { | ||
var t = tokenList[i]; | ||
if([Token.LINE, Token.ENTER].indexOf(t.type()) > -1) { | ||
return; | ||
} | ||
else if([Token.COMMENT, Token.BLANK, Token.TAB].indexOf(t.type()) == -1) { | ||
this.cancel = true; | ||
return; | ||
} | ||
} | ||
}; | ||
self.addMatch(htmlEndComment); | ||
self.addMatch(new LineSearch(Token.COMMENT, '/*', '*/', true)); | ||
@@ -24,0 +39,0 @@ self.addMatch(new LineParse(Token.STRING, '"', '"', false, Lexer.IS_REG)); |
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
563109
16429