// A framework for simple tokenizers. Takes care of newlines and
// white-space, and of getting the text from the source stream into
// the token object. A state is a function of two arguments -- a
// string stream and a setState function. The second can be used to
// change the tokenizer's state, and can be ignored for stateless
// tokenizers. This function should advance the stream over a token
// and return a string or object containing information about the next
// token, or null to pass and have the (new) state be called to finish
// the token. When a string is given, it is wrapped in a {style, type}
// object. In the resulting object, the characters consumed are stored
// under the content property. Any whitespace following them is also
// automatically consumed, and added to the value property. (Thus,
// content is the actual meaningful part of the token, while value
// contains all the text it spans.)
function tokenizer(source, state) {
// Newlines are always a separate token.
function isWhiteSpace(ch) {
// The messy regexp is because IE's regexp matcher is of the
// opinion that non-breaking spaces are no whitespace.
return ch != "\n" && /^[\s\u00a0]*$/.test(ch);
}
var tokenizer = {
state: state,
take: function(type) {
if (typeof(type) == "string")
type = {style: type, type: type};
type.content = (type.content || "") + source.get();
if (!/\n$/.test(type.content))
source.nextWhile(isWhiteSpace);
type.value = type.content + source.get();
return type;
},
next: function () {
if (!source.more()) throw StopIteration;
var type;
if (source.equals("\n")) {
source.next();
return this.take("whitespace");
}
if (source.applies(isWhiteSpace))
type = "whitespace";
else
while (!type)
type = this.state(source, function(s) {tokenizer.state = s;});
return this.take(type);
}
};
return tokenizer;
}
| nama | waktu | ukuran | owner | perm | aksi |
|---|---|---|---|---|---|
| .. | |||||
| basefiles-uncompressed.js | 2014-04-14 20:01 | 109.99 KB | 76129f60960:kunden | -xw-x----- | |
| basefiles.js | 2014-04-14 20:01 | 43.45 KB | 76129f60960:kunden | -xw-x----- | |
| codemirror-uncompressed.js | 2014-04-14 20:01 | 22.08 KB | 76129f60960:kunden | -xw-x----- | |
| codemirror.js | 2014-04-14 20:01 | 11.74 KB | 76129f60960:kunden | -xw-x----- | |
| editor.js | 2014-04-14 20:01 | 62.23 KB | 76129f60960:kunden | -xw-x----- | |
| highlight.js | 2014-04-14 20:01 | 2.04 KB | 76129f60960:kunden | -xw-x----- | |
| index.html | 2014-04-14 20:01 | 31 B | 76129f60960:kunden | -xw-x----- | |
| mirrorframe.js | 2014-04-14 20:01 | 2.22 KB | 76129f60960:kunden | -xw-x----- | |
| parsecss.js | 2014-04-14 20:01 | 4.42 KB | 76129f60960:kunden | -xw-x----- | |
| parsedummy.js | 2014-04-14 20:01 | 845 B | 76129f60960:kunden | -xw-x----- | |
| parsehtmlmixed.js | 2014-04-14 20:01 | 2.66 KB | 76129f60960:kunden | -xw-x----- | |
| parsejavascript.js | 2014-04-14 20:01 | 13.63 KB | 76129f60960:kunden | -xw-x----- | |
| parsephp.js | 2014-04-14 20:01 | 16.54 KB | 76129f60960:kunden | -xw-x----- | |
| parsephphtmlmixed.js | 2014-04-14 20:01 | 3.89 KB | 76129f60960:kunden | -xw-x----- | |
| parsesparql.js | 2014-04-14 20:01 | 5.03 KB | 76129f60960:kunden | -xw-x----- | |
| parsexml.js | 2014-04-14 20:01 | 8.54 KB | 76129f60960:kunden | -xw-x----- | |
| select.js | 2014-04-14 20:01 | 23.32 KB | 76129f60960:kunden | -xw-x----- | |
| stringstream.js | 2014-04-14 20:01 | 4.82 KB | 76129f60960:kunden | -xw-x----- | |
| tokenize.js | 2014-04-14 20:01 | 1.95 KB | 76129f60960:kunden | -xw-x----- | |
| tokenizejavascript.js | 2014-04-14 20:01 | 6.65 KB | 76129f60960:kunden | -xw-x----- | |
| tokenizephp.js | 2014-04-14 20:01 | 76.23 KB | 76129f60960:kunden | -xw-x----- | |
| undo.js | 2014-04-14 20:01 | 14.17 KB | 76129f60960:kunden | -xw-x----- | |
| util.js | 2014-04-14 20:01 | 3.5 KB | 76129f60960:kunden | -xw-x----- | |