MCPcopy Create free account
hub / github.com/TruthHun/BookStack / tokenBase

Function tokenBase

static/editor.md/lib/codemirror/mode/vbscript/vbscript.js:116–257  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

114 }
115 // tokenizers
116 function tokenBase(stream, state) {
117 if (stream.eatSpace()) {
118 return 'space';
119 //return null;
120 }
121
122 var ch = stream.peek();
123
124 // Handle Comments
125 if (ch === "'") {
126 stream.skipToEnd();
127 return 'comment';
128 }
129 if (stream.match(comment)){
130 stream.skipToEnd();
131 return 'comment';
132 }
133
134
135 // Handle Number Literals
136 if (stream.match(/^((&H)|(&O))?[0-9\.]/i, false) && !stream.match(/^((&H)|(&O))?[0-9\.]+[a-z_]/i, false)) {
137 var floatLiteral = false;
138 // Floats
139 if (stream.match(/^\d*\.\d+/i)) { floatLiteral = true; }
140 else if (stream.match(/^\d+\.\d*/)) { floatLiteral = true; }
141 else if (stream.match(/^\.\d+/)) { floatLiteral = true; }
142
143 if (floatLiteral) {
144 // Float literals may be "imaginary"
145 stream.eat(/J/i);
146 return 'number';
147 }
148 // Integers
149 var intLiteral = false;
150 // Hex
151 if (stream.match(/^&H[0-9a-f]+/i)) { intLiteral = true; }
152 // Octal
153 else if (stream.match(/^&O[0-7]+/i)) { intLiteral = true; }
154 // Decimal
155 else if (stream.match(/^[1-9]\d*F?/)) {
156 // Decimal literals may be "imaginary"
157 stream.eat(/J/i);
158 // TODO - Can you have imaginary longs?
159 intLiteral = true;
160 }
161 // Zero by itself with no other piece of number.
162 else if (stream.match(/^0(?![\dx])/i)) { intLiteral = true; }
163 if (intLiteral) {
164 // Integer literals may be "long"
165 stream.eat(/L/i);
166 return 'number';
167 }
168 }
169
170 // Handle Strings
171 if (stream.match(stringPrefixes)) {
172 state.tokenize = tokenStringFactory(stream.current());
173 return state.tokenize(stream, state);

Callers

nothing calls this directly

Calls 3

tokenStringFactoryFunction · 0.70
indentFunction · 0.70
dedentFunction · 0.70

Tested by

no test coverage detected