do not loose currentState if tokenizer uses combination of next and push

This commit is contained in:
nightwing 2013-11-30 18:40:02 +04:00
commit d87ba89c49
2 changed files with 19 additions and 3 deletions

View file

@ -188,11 +188,13 @@ var RubyHighlightRules = function() {
rules: {
heredoc: [{
onMatch: function(value, currentState, stack) {
if (value == stack[1]) {
if (value === stack[1]) {
stack.shift();
stack.shift();
this.next = stack[0] || "start";
return "support.class";
}
this.next = "";
return "string";
},
regex: ".*$",
@ -203,17 +205,27 @@ var RubyHighlightRules = function() {
regex: "^ +"
}, {
onMatch: function(value, currentState, stack) {
if (value == stack[1]) {
if (value === stack[1]) {
stack.shift();
stack.shift();
this.next = stack[0] || "start";
return "support.class";
}
this.next = "";
return "string";
},
regex: ".*$",
next: "start"
}]
}
}, {
regex : "$",
token : "empty",
next : function(currentState, stack) {
if (stack[0] === "heredoc" || stack[0] === "indentedHeredoc")
return stack[0];
return currentState;
}
}, {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"

View file

@ -320,7 +320,11 @@ var Tokenizer = function(rules) {
if (token.type)
tokens.push(token);
if (stack.length > 1) {
if (stack[0] !== currentState)
stack.unshift(currentState);
}
return {
tokens : tokens,
state : stack.length ? stack : currentState