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

Function tokenBase

static/editor.md/lib/codemirror/mode/sql/sql.js:26–117  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

24 dateSQL = parserConfig.dateSQL || {"date" : true, "time" : true, "timestamp" : true};
25
26 function tokenBase(stream, state) {
27 var ch = stream.next();
28
29 // call hooks from the mime type
30 if (hooks[ch]) {
31 var result = hooks[ch](stream, state);
32 if (result !== false) return result;
33 }
34
35 if (support.hexNumber == true &&
36 ((ch == "0" && stream.match(/^[xX][0-9a-fA-F]+/))
37 || (ch == "x" || ch == "X") && stream.match(/^'[0-9a-fA-F]+'/))) {
38 // hex
39 // ref: http://dev.mysql.com/doc/refman/5.5/en/hexadecimal-literals.html
40 return "number";
41 } else if (support.binaryNumber == true &&
42 (((ch == "b" || ch == "B") && stream.match(/^'[01]+'/))
43 || (ch == "0" && stream.match(/^b[01]+/)))) {
44 // bitstring
45 // ref: http://dev.mysql.com/doc/refman/5.5/en/bit-field-literals.html
46 return "number";
47 } else if (ch.charCodeAt(0) > 47 && ch.charCodeAt(0) < 58) {
48 // numbers
49 // ref: http://dev.mysql.com/doc/refman/5.5/en/number-literals.html
50 stream.match(/^[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/);
51 support.decimallessFloat == true && stream.eat('.');
52 return "number";
53 } else if (ch == "?" && (stream.eatSpace() || stream.eol() || stream.eat(";"))) {
54 // placeholders
55 return "variable-3";
56 } else if (ch == "'" || (ch == '"' && support.doubleQuote)) {
57 // strings
58 // ref: http://dev.mysql.com/doc/refman/5.5/en/string-literals.html
59 state.tokenize = tokenLiteral(ch);
60 return state.tokenize(stream, state);
61 } else if ((((support.nCharCast == true && (ch == "n" || ch == "N"))
62 || (support.charsetCast == true && ch == "_" && stream.match(/[a-z][a-z0-9]*/i)))
63 && (stream.peek() == "'" || stream.peek() == '"'))) {
64 // charset casting: _utf8'str', N'str', n'str'
65 // ref: http://dev.mysql.com/doc/refman/5.5/en/string-literals.html
66 return "keyword";
67 } else if (/^[\(\),\;\[\]]/.test(ch)) {
68 // no highlightning
69 return null;
70 } else if (support.commentSlashSlash && ch == "/" && stream.eat("/")) {
71 // 1-line comment
72 stream.skipToEnd();
73 return "comment";
74 } else if ((support.commentHash && ch == "#")
75 || (ch == "-" && stream.eat("-") && (!support.commentSpaceRequired || stream.eat(" ")))) {
76 // 1-line comments
77 // ref: https://kb.askmonty.org/en/comment-syntax/
78 stream.skipToEnd();
79 return "comment";
80 } else if (ch == "/" && stream.eat("*")) {
81 // multi-line comments
82 // ref: https://kb.askmonty.org/en/comment-syntax/
83 state.tokenize = tokenComment;

Callers

nothing calls this directly

Calls 1

tokenLiteralFunction · 0.70

Tested by

no test coverage detected