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

Function tokenBase

static/js/codemirror/mode/xquery/xquery.js:95–226  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 12

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
nextMethod · 0.45
matchMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected