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

Function haxeTokenBase

static/editor.md/lib/codemirror/mode/haxe/haxe.js:62–123  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

60 }
61
62 function haxeTokenBase(stream, state) {
63 var ch = stream.next();
64 if (ch == '"' || ch == "'")
65 return chain(stream, state, haxeTokenString(ch));
66 else if (/[\[\]{}\(\),;\:\.]/.test(ch))
67 return ret(ch);
68 else if (ch == "0" && stream.eat(/x/i)) {
69 stream.eatWhile(/[\da-f]/i);
70 return ret("number", "number");
71 }
72 else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) {
73 stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
74 return ret("number", "number");
75 }
76 else if (state.reAllowed && (ch == "~" && stream.eat(/\//))) {
77 nextUntilUnescaped(stream, "/");
78 stream.eatWhile(/[gimsu]/);
79 return ret("regexp", "string-2");
80 }
81 else if (ch == "/") {
82 if (stream.eat("*")) {
83 return chain(stream, state, haxeTokenComment);
84 }
85 else if (stream.eat("/")) {
86 stream.skipToEnd();
87 return ret("comment", "comment");
88 }
89 else {
90 stream.eatWhile(isOperatorChar);
91 return ret("operator", null, stream.current());
92 }
93 }
94 else if (ch == "#") {
95 stream.skipToEnd();
96 return ret("conditional", "meta");
97 }
98 else if (ch == "@") {
99 stream.eat(/:/);
100 stream.eatWhile(/[\w_]/);
101 return ret ("metadata", "meta");
102 }
103 else if (isOperatorChar.test(ch)) {
104 stream.eatWhile(isOperatorChar);
105 return ret("operator", null, stream.current());
106 }
107 else {
108 var word;
109 if(/[A-Z]/.test(ch))
110 {
111 stream.eatWhile(/[\w_<>]/);
112 word = stream.current();
113 return ret("type", "variable-3", word);
114 }
115 else
116 {
117 stream.eatWhile(/[\w_]/);
118 var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
119 return (known && state.kwAllowed) ? ret(known.type, known.style, word) :

Callers

nothing calls this directly

Calls 4

haxeTokenStringFunction · 0.85
chainFunction · 0.70
retFunction · 0.70
nextUntilUnescapedFunction · 0.70

Tested by

no test coverage detected