commit
f118db4560
10 changed files with 127 additions and 118 deletions
|
|
@ -7,9 +7,12 @@ $(function() {
|
||||||
editor.container.style.opacity = "";
|
editor.container.style.opacity = "";
|
||||||
embedded_editor = ace.edit("embedded_ace_code");
|
embedded_editor = ace.edit("embedded_ace_code");
|
||||||
embedded_editor.container.style.opacity = "";
|
embedded_editor.container.style.opacity = "";
|
||||||
editor.getSession().setMode("ace/mode/javascript");
|
editor.session.setMode("ace/mode/javascript");
|
||||||
editor.getSession().setMode("ace/mode/javascript");
|
editor.session.setMode("ace/mode/javascript");
|
||||||
embedded_editor.getSession().setMode("ace/mode/html");
|
embedded_editor.session.setMode("ace/mode/html");
|
||||||
|
|
||||||
|
embedded_editor.setAutoScrollEditorIntoView(true);
|
||||||
|
editor.setAutoScrollEditorIntoView(true);
|
||||||
|
|
||||||
$("ul.menu-list li").click(function(e) {
|
$("ul.menu-list li").click(function(e) {
|
||||||
if (e.target.tagName === "LI") {
|
if (e.target.tagName === "LI") {
|
||||||
|
|
|
||||||
|
|
@ -944,6 +944,11 @@ oop.inherits(FoldMode, BaseFoldMode);
|
||||||
style="position: relative; left: 3px; width: 96px;top: -12px;">
|
style="position: relative; left: 3px; width: 96px;top: -12px;">
|
||||||
<a href="http://slimtext.org/">Slim Text</a>
|
<a href="http://slimtext.org/">Slim Text</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<img src="https://www.decor-tab-creator.com/_files/decor_logo_white_new.png"
|
||||||
|
style="position: relative; left: -5px; width: 111px;top: 15px;">
|
||||||
|
<a href="https://www.decor-tab-creator.com">Decor</a>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="https://github.com/Gozala/sky-edit">Sky Edit</a>
|
<a href="https://github.com/Gozala/sky-edit">Sky Edit</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -2445,7 +2445,7 @@ config.defineOptions(EditSession.prototype, "session", {
|
||||||
},
|
},
|
||||||
newLineMode: {
|
newLineMode: {
|
||||||
set: function(val) {this.doc.setNewLineMode(val)},
|
set: function(val) {this.doc.setNewLineMode(val)},
|
||||||
get: function() {return this.doc.getNewLineMode(newLineMode)},
|
get: function() {return this.doc.getNewLineMode()},
|
||||||
handlesSet: true
|
handlesSet: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -2136,7 +2136,7 @@ var Editor = function(renderer, session) {
|
||||||
* @param {Boolean} enable default true
|
* @param {Boolean} enable default true
|
||||||
**/
|
**/
|
||||||
this.setAutoScrollEditorIntoView = function(enable) {
|
this.setAutoScrollEditorIntoView = function(enable) {
|
||||||
if (enable === true)
|
if (enable === false)
|
||||||
return;
|
return;
|
||||||
var rect;
|
var rect;
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
@ -2178,7 +2178,7 @@ var Editor = function(renderer, session) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.setAutoScrollEditorIntoView = function(enable) {
|
this.setAutoScrollEditorIntoView = function(enable) {
|
||||||
if (enable === false)
|
if (enable === true)
|
||||||
return;
|
return;
|
||||||
delete this.setAutoScrollEditorIntoView;
|
delete this.setAutoScrollEditorIntoView;
|
||||||
this.removeEventListener("changeSelection", onChangeSelection);
|
this.removeEventListener("changeSelection", onChangeSelection);
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,9 @@
|
||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
.ace_search_form.ace_nomatch {
|
||||||
|
outline: 1px solid red;
|
||||||
|
}
|
||||||
|
|
||||||
.ace_search_field {
|
.ace_search_field {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
|
|
@ -111,4 +114,44 @@
|
||||||
}
|
}
|
||||||
.ace_replacebtn.next {
|
.ace_replacebtn.next {
|
||||||
width: 27px
|
width: 27px
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace_button {
|
||||||
|
margin-left: 2px;
|
||||||
|
cursor: pointer;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-o-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
overflow: hidden;
|
||||||
|
opacity: 0.7;
|
||||||
|
border: 1px solid rgba(100,100,100,0.23);
|
||||||
|
padding: 1px;
|
||||||
|
-moz-box-sizing: border-box;
|
||||||
|
box-sizing: border-box;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace_button:hover {
|
||||||
|
background-color: #eee;
|
||||||
|
opacity:1;
|
||||||
|
}
|
||||||
|
.ace_button:active {
|
||||||
|
background-color: #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace_button.checked {
|
||||||
|
border-color: #3399ff;
|
||||||
|
opacity:1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace_search_options{
|
||||||
|
margin-bottom: 3px;
|
||||||
|
text-align: right;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-o-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
@ -52,6 +52,11 @@ var html = '<div class="ace_search right">\
|
||||||
<button type="button" action="replace" class="ace_replacebtn">Replace</button>\
|
<button type="button" action="replace" class="ace_replacebtn">Replace</button>\
|
||||||
<button type="button" action="replaceAll" class="ace_replacebtn">All</button>\
|
<button type="button" action="replaceAll" class="ace_replacebtn">All</button>\
|
||||||
</div>\
|
</div>\
|
||||||
|
<div class="ace_search_options">\
|
||||||
|
<span action="toggleRegexpMode" class="ace_button" title="RegExp Search">.*</span>\
|
||||||
|
<span action="toggleCaseSensitive" class="ace_button" title="CaseSensitive Search">Aa</span>\
|
||||||
|
<span action="toggleWholeWords" class="ace_button" title="Whole Word Search">\\b</span>\
|
||||||
|
</div>\
|
||||||
</div>'.replace(/>\s+/g, ">");
|
</div>'.replace(/>\s+/g, ">");
|
||||||
|
|
||||||
var SearchBox = function(editor, range, showReplaceForm) {
|
var SearchBox = function(editor, range, showReplaceForm) {
|
||||||
|
|
@ -75,6 +80,10 @@ var SearchBox = function(editor, range, showReplaceForm) {
|
||||||
|
|
||||||
this.searchBox = sb.querySelector(".ace_search_form");
|
this.searchBox = sb.querySelector(".ace_search_form");
|
||||||
this.replaceBox = sb.querySelector(".ace_replace_form");
|
this.replaceBox = sb.querySelector(".ace_replace_form");
|
||||||
|
this.searchOptions = sb.querySelector(".ace_search_options");
|
||||||
|
this.regExpOption = sb.querySelector("[action=toggleRegexpMode]");
|
||||||
|
this.caseSensitiveOption = sb.querySelector("[action=toggleCaseSensitive]");
|
||||||
|
this.wholeWordOption = sb.querySelector("[action=toggleWholeWords]");
|
||||||
this.searchInput = this.searchBox.querySelector(".ace_search_field");
|
this.searchInput = this.searchBox.querySelector(".ace_search_field");
|
||||||
this.replaceInput = this.replaceBox.querySelector(".ace_search_field");
|
this.replaceInput = this.replaceBox.querySelector(".ace_search_field");
|
||||||
|
|
||||||
|
|
@ -90,6 +99,8 @@ var SearchBox = function(editor, range, showReplaceForm) {
|
||||||
var action = t.getAttribute("action");
|
var action = t.getAttribute("action");
|
||||||
if (action && _this[action])
|
if (action && _this[action])
|
||||||
_this[action]();
|
_this[action]();
|
||||||
|
else if (_this.$searchBarKb.commands[action])
|
||||||
|
_this.$searchBarKb.commands[action].exec(_this);
|
||||||
event.stopPropagation(e);
|
event.stopPropagation(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -157,14 +168,47 @@ var SearchBox = function(editor, range, showReplaceForm) {
|
||||||
(sb.activeInput == sb.replaceInput ? sb.searchInput : sb.replaceInput).focus();
|
(sb.activeInput == sb.replaceInput ? sb.searchInput : sb.replaceInput).focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.$searchBarKb.addCommands([{
|
||||||
|
name: "toggleRegexpMode",
|
||||||
|
bindKey: {win: "Alt-R|Alt-/", mac: "Ctrl-Alt-R|Ctrl-Alt-/"},
|
||||||
|
exec: function(sb) {
|
||||||
|
sb.regExpOption.checked = !sb.regExpOption.checked;
|
||||||
|
sb.$syncOptions();
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: "toggleCaseSensitive",
|
||||||
|
bindKey: {win: "Alt-C|Alt-I", mac: "Ctrl-Alt-R|Ctrl-Alt-I"},
|
||||||
|
exec: function(sb) {
|
||||||
|
sb.caseSensitiveOption.checked = !sb.caseSensitiveOption.checked;
|
||||||
|
sb.$syncOptions();
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: "toggleWholeWords",
|
||||||
|
bindKey: {win: "Alt-B|Alt-W", mac: "Ctrl-Alt-B|Ctrl-Alt-W"},
|
||||||
|
exec: function(sb) {
|
||||||
|
sb.wholeWordOption.checked = !sb.wholeWordOption.checked;
|
||||||
|
sb.$syncOptions();
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
this.$syncOptions = function() {
|
||||||
|
dom.setCssClass(this.regExpOption, "checked", this.regExpOption.checked);
|
||||||
|
dom.setCssClass(this.wholeWordOption, "checked", this.wholeWordOption.checked);
|
||||||
|
dom.setCssClass(this.caseSensitiveOption, "checked", this.caseSensitiveOption.checked);
|
||||||
|
this.find(false, false);
|
||||||
|
};
|
||||||
|
|
||||||
this.find = function(skipCurrent, backwards) {
|
this.find = function(skipCurrent, backwards) {
|
||||||
this.editor.find(this.searchInput.value, {
|
var range = this.editor.find(this.searchInput.value, {
|
||||||
skipCurrent: skipCurrent,
|
skipCurrent: skipCurrent,
|
||||||
backwards: backwards,
|
backwards: backwards,
|
||||||
wrap: true
|
wrap: true,
|
||||||
|
regExp: this.regExpOption.checked,
|
||||||
|
caseSensitive: this.caseSensitiveOption.checked,
|
||||||
|
wholeWord: this.wholeWordOption.checked
|
||||||
});
|
});
|
||||||
|
dom.setCssClass(this.searchBox, "ace_nomatch", !range && this.searchInput.value);
|
||||||
this.editor.session.highlight(this.editor.$search.$options.re);
|
this.editor.session.highlight(this.editor.$search.$options.re);
|
||||||
};
|
};
|
||||||
this.findNext = function() {
|
this.findNext = function() {
|
||||||
|
|
@ -175,7 +219,6 @@ var SearchBox = function(editor, range, showReplaceForm) {
|
||||||
};
|
};
|
||||||
this.replace = function() {
|
this.replace = function() {
|
||||||
this.editor.replace(this.replaceInput.value);
|
this.editor.replace(this.replaceInput.value);
|
||||||
this.findNext();
|
|
||||||
};
|
};
|
||||||
this.replaceAll = function() {
|
this.replaceAll = function() {
|
||||||
this.editor.replaceAll(this.replaceInput.value);
|
this.editor.replaceAll(this.replaceInput.value);
|
||||||
|
|
|
||||||
|
|
@ -38,11 +38,15 @@ var LogiQLHighlightRules = require("./logiql_highlight_rules").LogiQLHighlightRu
|
||||||
var FoldMode = require("./folding/coffee").FoldMode;
|
var FoldMode = require("./folding/coffee").FoldMode;
|
||||||
var TokenIterator = require("../token_iterator").TokenIterator;
|
var TokenIterator = require("../token_iterator").TokenIterator;
|
||||||
var Range = require("../range").Range;
|
var Range = require("../range").Range;
|
||||||
|
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
||||||
|
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
||||||
|
|
||||||
var Mode = function() {
|
var Mode = function() {
|
||||||
var highlighter = new LogiQLHighlightRules();
|
var highlighter = new LogiQLHighlightRules();
|
||||||
this.foldingRules = new FoldMode();
|
this.foldingRules = new FoldMode();
|
||||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||||
|
this.$outdent = new MatchingBraceOutdent();
|
||||||
|
this.$behaviour = new CstyleBehaviour();
|
||||||
};
|
};
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
|
|
@ -62,12 +66,15 @@ oop.inherits(Mode, TextMode);
|
||||||
return indent;
|
return indent;
|
||||||
|
|
||||||
var match = line.match();
|
var match = line.match();
|
||||||
if (/(-->|<--|<-|->)\s*$/.test(line))
|
if (/(-->|<--|<-|->|{)\s*$/.test(line))
|
||||||
indent += tab;
|
indent += tab;
|
||||||
return indent;
|
return indent;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.checkOutdent = function(state, line, input) {
|
this.checkOutdent = function(state, line, input) {
|
||||||
|
if (this.$outdent.checkOutdent(line, input))
|
||||||
|
return true;
|
||||||
|
|
||||||
if (input !== "\n" && input !== "\r\n")
|
if (input !== "\n" && input !== "\r\n")
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -78,6 +85,8 @@ oop.inherits(Mode, TextMode);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.autoOutdent = function(state, doc, row) {
|
this.autoOutdent = function(state, doc, row) {
|
||||||
|
if (this.$outdent.autoOutdent(doc, row))
|
||||||
|
return;
|
||||||
var prevLine = doc.getLine(row);
|
var prevLine = doc.getLine(row);
|
||||||
var match = prevLine.match(/^\s+/);
|
var match = prevLine.match(/^\s+/);
|
||||||
var column = prevLine.lastIndexOf(".") + 1;
|
var column = prevLine.lastIndexOf(".") + 1;
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ var LogiQLHighlightRules = function() {
|
||||||
//All the lang system predicates
|
//All the lang system predicates
|
||||||
},
|
},
|
||||||
{ token: [ 'storage.type', 'text' ],
|
{ token: [ 'storage.type', 'text' ],
|
||||||
regex: '(export|sealed|clauses|block|alias)\\s*\\((?=`)',
|
regex: '(export|sealed|clauses|block|alias)(\\s*\\()(?=`)',
|
||||||
//Module keywords
|
//Module keywords
|
||||||
},
|
},
|
||||||
{ token: 'entity.name',
|
{ token: 'entity.name',
|
||||||
|
|
|
||||||
|
|
@ -75,8 +75,12 @@ var Tokenizer = function(rules) {
|
||||||
var adjustedregex = rule.regex;
|
var adjustedregex = rule.regex;
|
||||||
var matchcount = new RegExp("(?:(" + adjustedregex + ")|(.))").exec("a").length - 2;
|
var matchcount = new RegExp("(?:(" + adjustedregex + ")|(.))").exec("a").length - 2;
|
||||||
if (Array.isArray(rule.token)) {
|
if (Array.isArray(rule.token)) {
|
||||||
if (rule.token.length == 1) {
|
if (rule.token.length == 1 || matchcount == 1) {
|
||||||
rule.token = rule.token[0];
|
rule.token = rule.token[0];
|
||||||
|
} else if (matchcount - 1 != rule.token.length) {
|
||||||
|
throw new Error("number of classes and regexp groups in '" +
|
||||||
|
rule.token + "'\n'" + rule.regex + "' doesn't match\n"
|
||||||
|
+ (matchcount - 1) + "!=" + rule.token.length);
|
||||||
} else {
|
} else {
|
||||||
rule.tokenArray = rule.token;
|
rule.tokenArray = rule.token;
|
||||||
rule.onMatch = this.$arrayTokens;
|
rule.onMatch = this.$arrayTokens;
|
||||||
|
|
@ -143,11 +147,6 @@ var Tokenizer = function(rules) {
|
||||||
var values = this.splitRegex.exec(str);
|
var values = this.splitRegex.exec(str);
|
||||||
var tokens = [];
|
var tokens = [];
|
||||||
var types = this.tokenArray;
|
var types = this.tokenArray;
|
||||||
if (types.length != values.length - 1) {
|
|
||||||
if (window.console)
|
|
||||||
console.error(types , values, str, this.splitRegex, this);
|
|
||||||
return [{type: "error.invalid", value: str}];
|
|
||||||
}
|
|
||||||
for (var i = 0, l = types.length; i < l; i++) {
|
for (var i = 0, l = types.length; i < l; i++) {
|
||||||
if (values[i + 1])
|
if (values[i + 1])
|
||||||
tokens[tokens.length] = {
|
tokens[tokens.length] = {
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
var BaseTokenizer = require("./tokenizer").Tokenizer;
|
||||||
|
|
||||||
// tokenizing lines longer than this makes editor very slow
|
// tokenizing lines longer than this makes editor very slow
|
||||||
var MAX_TOKEN_COUNT = 1000;
|
var MAX_TOKEN_COUNT = 1000;
|
||||||
|
|
@ -39,101 +40,7 @@ var MAX_TOKEN_COUNT = 1000;
|
||||||
**/
|
**/
|
||||||
|
|
||||||
var Tokenizer = function(rules) {
|
var Tokenizer = function(rules) {
|
||||||
this.states = rules;
|
BaseTokenizer.call(this, rules);
|
||||||
|
|
||||||
this.regExps = {};
|
|
||||||
this.matchMappings = {};
|
|
||||||
for (var key in this.states) {
|
|
||||||
var state = this.states[key];
|
|
||||||
var ruleRegExps = [];
|
|
||||||
var matchTotal = 0;
|
|
||||||
var mapping = this.matchMappings[key] = {defaultToken: "default.text"};
|
|
||||||
var flag = "g";
|
|
||||||
|
|
||||||
for (var i = 0; i < state.length; i++) {
|
|
||||||
var rule = state[i];
|
|
||||||
if (rule.defaultToken)
|
|
||||||
mapping.defaultToken = rule.defaultToken;
|
|
||||||
if (rule.caseInsensitive)
|
|
||||||
flag = "gi";
|
|
||||||
if (rule.regex == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (rule.regex instanceof RegExp)
|
|
||||||
rule.regex = rule.regex.toString().slice(1, -1);
|
|
||||||
|
|
||||||
// Count number of matching groups. 2 extra groups from the full match
|
|
||||||
// And the catch-all on the end (used to force a match);
|
|
||||||
var adjustedregex = rule.regex;
|
|
||||||
var matchcount = new RegExp("(?:(" + adjustedregex + ")|(.))").exec("a").length - 2;
|
|
||||||
if (Array.isArray(rule.token)) {
|
|
||||||
if (rule.token.length == 1) {
|
|
||||||
rule.token = rule.token[0];
|
|
||||||
} else {
|
|
||||||
rule.tokenArray = rule.token;
|
|
||||||
rule.token = this.$arrayTokens;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (matchcount > 1) {
|
|
||||||
if (/\\\d/.test(rule.regex)) {
|
|
||||||
// Replace any backreferences and offset appropriately.
|
|
||||||
adjustedregex = rule.regex.replace(/\\([0-9]+)/g, function (match, digit) {
|
|
||||||
return "\\" + (parseInt(digit, 10) + matchTotal + 1);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
matchcount = 1;
|
|
||||||
adjustedregex = this.removeCapturingGroups(rule.regex);
|
|
||||||
}
|
|
||||||
if (!rule.splitRegex)
|
|
||||||
rule.splitRegex = this.createSplitterRegexp(rule.regex, flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
mapping[matchTotal] = i;
|
|
||||||
matchTotal += matchcount;
|
|
||||||
|
|
||||||
ruleRegExps.push(adjustedregex);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.regExps[key] = new RegExp("(" + ruleRegExps.join(")|(") + ")|($)", flag);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
this.$arrayTokens = function(str) {
|
|
||||||
if (!str)
|
|
||||||
return [];
|
|
||||||
var values = str.split(this.splitRegex)
|
|
||||||
var tokens = [];
|
|
||||||
var types = this.tokenArray;
|
|
||||||
if (types.length != values.length - 2) {
|
|
||||||
if (window.console)
|
|
||||||
console.error(types.length , values.length - 2, str, this.splitRegex);
|
|
||||||
return [{type: "error.invalid", value: str}];
|
|
||||||
}
|
|
||||||
for (var i = 0; i < types.length; i++) {
|
|
||||||
if (values[i + 1]) {
|
|
||||||
tokens[tokens.length] = {
|
|
||||||
type: types[i],
|
|
||||||
value: values[i + 1]
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return tokens;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.removeCapturingGroups = function(src) {
|
|
||||||
var r = src.replace(
|
|
||||||
/\[(?:\\.|[^\]])*?\]|\\.|\(\?[:=!]|(\()/g,
|
|
||||||
function(x, y) {return y ? "(?:" : x;}
|
|
||||||
);
|
|
||||||
return r;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.createSplitterRegexp = function(src, flag) {
|
|
||||||
src = src.replace(/\(\?=([^()]|\\.)*?\)$/, "");
|
|
||||||
return new RegExp(src, flag);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an object containing two properties: `tokens`, which contains all the tokens; and `state`, the current state.
|
* Returns an object containing two properties: `tokens`, which contains all the tokens; and `state`, the current state.
|
||||||
|
|
@ -202,10 +109,10 @@ var Tokenizer = function(rules) {
|
||||||
|
|
||||||
rule = state[mapping[i]];
|
rule = state[mapping[i]];
|
||||||
|
|
||||||
// compute token type
|
if (rule.onMatch)
|
||||||
type = typeof rule.token == "function"
|
type = rule.onMatch(value, currentState, stack);
|
||||||
? rule.token(value, currentState, stack)
|
else
|
||||||
: rule.token;
|
type = rule.token;
|
||||||
|
|
||||||
if (rule.next) {
|
if (rule.next) {
|
||||||
if (typeof rule.next == "string")
|
if (typeof rule.next == "string")
|
||||||
|
|
@ -268,7 +175,7 @@ var Tokenizer = function(rules) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
}).call(Tokenizer.prototype);
|
};
|
||||||
|
|
||||||
exports.Tokenizer = Tokenizer;
|
exports.Tokenizer = Tokenizer;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue