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

Function tokenBase

static/editor.md/lib/codemirror/mode/xquery/xquery.js:86–217  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

84
85 // the primary mode tokenizer
86 function tokenBase(stream, state) {
87 var ch = stream.next(),
88 mightBeFunction = false,
89 isEQName = isEQNameAhead(stream);
90
91 // an XML tag (if not in some sub, chained tokenizer)
92 if (ch == "<") {
93 if(stream.match("!--", true))
94 return chain(stream, state, tokenXMLComment);
95
96 if(stream.match("![CDATA", false)) {
97 state.tokenize = tokenCDATA;
98 return ret("tag", "tag");
99 }
100
101 if(stream.match("?", false)) {
102 return chain(stream, state, tokenPreProcessing);
103 }
104
105 var isclose = stream.eat("/");
106 stream.eatSpace();
107 var tagName = "", c;
108 while ((c = stream.eat(/[^\s\u00a0=<>\"\'\/?]/))) tagName += c;
109
110 return chain(stream, state, tokenTag(tagName, isclose));
111 }
112 // start code block
113 else if(ch == "{") {
114 pushStateStack(state,{ type: "codeblock"});
115 return ret("", null);
116 }
117 // end code block
118 else if(ch == "}") {
119 popStateStack(state);
120 return ret("", null);
121 }
122 // if we're in an XML block
123 else if(isInXmlBlock(state)) {
124 if(ch == ">")
125 return ret("tag", "tag");
126 else if(ch == "/" && stream.eat(">")) {
127 popStateStack(state);
128 return ret("tag", "tag");
129 }
130 else
131 return ret("word", "variable");
132 }
133 // if a number
134 else if (/\d/.test(ch)) {
135 stream.match(/^\d*(?:\.\d*)?(?:E[+\-]?\d+)?/);
136 return ret("number", "atom");
137 }
138 // comment start
139 else if (ch === "(" && stream.eat(":")) {
140 pushStateStack(state, { type: "comment"});
141 return chain(stream, state, tokenComment);
142 }
143 // quoted string

Callers

nothing calls this directly

Calls 9

isEQNameAheadFunction · 0.85
tokenTagFunction · 0.85
pushStateStackFunction · 0.85
popStateStackFunction · 0.85
isInXmlBlockFunction · 0.85
isInXmlConstructorFunction · 0.85
chainFunction · 0.70
retFunction · 0.70
tokenStringFunction · 0.70

Tested by

no test coverage detected