MCPcopy Create free account
hub / github.com/TextGeneratorio/text-generator.io / tokenBase

Function tokenBase

static/libs/javascript.js:66–135  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

64 return style;
65 }
66 function tokenBase(stream, state) {
67 var ch = stream.next();
68 if (ch == '"' || ch == "'") {
69 state.tokenize = tokenString(ch);
70 return state.tokenize(stream, state);
71 } else if (ch == "." && stream.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/)) {
72 return ret("number", "number");
73 } else if (ch == "." && stream.match("..")) {
74 return ret("spread", "meta");
75 } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
76 return ret(ch);
77 } else if (ch == "=" && stream.eat(">")) {
78 return ret("=>", "operator");
79 } else if (ch == "0" && stream.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/)) {
80 return ret("number", "number");
81 } else if (/\d/.test(ch)) {
82 stream.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/);
83 return ret("number", "number");
84 } else if (ch == "/") {
85 if (stream.eat("*")) {
86 state.tokenize = tokenComment;
87 return tokenComment(stream, state);
88 } else if (stream.eat("/")) {
89 stream.skipToEnd();
90 return ret("comment", "comment");
91 } else if (expressionAllowed(stream, state, 1)) {
92 readRegexp(stream);
93 stream.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/);
94 return ret("regexp", "string-2");
95 } else {
96 stream.eat("=");
97 return ret("operator", "operator", stream.current());
98 }
99 } else if (ch == "`") {
100 state.tokenize = tokenQuasi;
101 return tokenQuasi(stream, state);
102 } else if (ch == "#" && stream.peek() == "!") {
103 stream.skipToEnd();
104 return ret("meta", "meta");
105 } else if (ch == "#" && stream.eatWhile(wordRE)) {
106 return ret("variable", "property")
107 } else if (ch == "<" && stream.match("!--") ||
108 (ch == "-" && stream.match("->") && !/\S/.test(stream.string.slice(0, stream.start)))) {
109 stream.skipToEnd()
110 return ret("comment", "comment")
111 } else if (isOperatorChar.test(ch)) {
112 if (ch != ">" || !state.lexical || state.lexical.type != ">") {
113 if (stream.eat("=")) {
114 if (ch == "!" || ch == "=") stream.eat("=")
115 } else if (/[<>*+\-|&?]/.test(ch)) {
116 stream.eat(ch)
117 if (ch == ">") stream.eat(ch)
118 }
119 }
120 if (ch == "?" && stream.eat(".")) return ret(".")
121 return ret("operator", "operator", stream.current());
122 } else if (wordRE.test(ch)) {
123 stream.eatWhile(wordRE);

Callers

nothing calls this directly

Calls 6

tokenStringFunction · 0.85
retFunction · 0.85
tokenCommentFunction · 0.85
expressionAllowedFunction · 0.85
readRegexpFunction · 0.85
tokenQuasiFunction · 0.85

Tested by

no test coverage detected