MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / tokenBase

Function tokenBase

static/js/codemirror/mode/plsql/plsql.js:19–77  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

17 }
18
19 function tokenBase(stream, state) {
20 var ch = stream.next();
21 // start of string?
22 if (ch == '"' || ch == "'")
23 return chain(stream, state, tokenString(ch));
24 // is it one of the special signs []{}().,;? Seperator?
25 else if (/[\[\]{}\(\),;\.]/.test(ch))
26 return ret(ch);
27 // start of a number value?
28 else if (/\d/.test(ch)) {
29 stream.eatWhile(/[\w\.]/);
30 return ret("number", "number");
31 }
32 // multi line comment or simple operator?
33 else if (ch == "/") {
34 if (stream.eat("*")) {
35 return chain(stream, state, tokenComment);
36 }
37 else {
38 stream.eatWhile(isOperatorChar);
39 return ret("operator", "operator");
40 }
41 }
42 // single line comment or simple operator?
43 else if (ch == "-") {
44 if (stream.eat("-")) {
45 stream.skipToEnd();
46 return ret("comment", "comment");
47 }
48 else {
49 stream.eatWhile(isOperatorChar);
50 return ret("operator", "operator");
51 }
52 }
53 // pl/sql variable?
54 else if (ch == "@" || ch == "$") {
55 stream.eatWhile(/[\w\d\$_]/);
56 return ret("word", "variable");
57 }
58 // is it a operator?
59 else if (isOperatorChar.test(ch)) {
60 stream.eatWhile(isOperatorChar);
61 return ret("operator", "operator");
62 }
63 else {
64 // get the whole word
65 stream.eatWhile(/[\w\$_]/);
66 // is it one of the listed keywords?
67 if (keywords && keywords.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "keyword");
68 // is it one of the listed functions?
69 if (functions && functions.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "builtin");
70 // is it one of the listed types?
71 if (types && types.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "variable-2");
72 // is it one of the listed sqlplus keywords?
73 if (sqlplus && sqlplus.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "variable-3");
74 // default: just a "variable"
75 return ret("word", "variable");
76 }

Callers

nothing calls this directly

Calls 5

chainFunction · 0.70
tokenStringFunction · 0.70
retFunction · 0.70
nextMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected