MCPcopy Index your code
hub / github.com/bigskysoftware/_hyperscript / parseHyperscriptProgram

Method parseHyperscriptProgram

src/core/kernel.js:175–211  ·  view source on GitHub ↗
(parser)

Source from the content-addressed store, hash-verified

173 }
174
175 parseHyperscriptProgram(parser) {
176 var features = [];
177 if (parser.hasMore()) {
178 while (parser.currentToken().type !== "EOF") {
179 var keyword = parser.currentToken().value;
180 if (parser.featureStart(parser.currentToken()) || parser.currentToken().value === "(") {
181 try {
182 var feature = parser.requireElement("feature");
183 features.push(feature);
184 parser.matchToken("end"); // optional end
185 } catch (e) {
186 if (e instanceof ParseRecoverySentinel) {
187 features.push(new FailedFeature(e.parseError, keyword));
188 this.#syncToFeature(parser);
189 } else {
190 throw e;
191 }
192 }
193 } else if (parser.currentToken().value === "end") {
194 break; // scope terminator (e.g. behavior body) - leave for outer parser
195 } else {
196 // Unconsumed token between features - report and sync
197 try {
198 parser.raiseError();
199 } catch (e) {
200 if (e instanceof ParseRecoverySentinel) {
201 features.push(new FailedFeature(e.parseError, keyword));
202 this.#syncToFeature(parser);
203 } else {
204 throw e;
205 }
206 }
207 }
208 }
209 }
210 return new HyperscriptProgram(features);
211 }
212
213 use(plugin) {
214 plugin(this)

Callers

nothing calls this directly

Calls 7

#syncToFeatureMethod · 0.95
hasMoreMethod · 0.45
currentTokenMethod · 0.45
featureStartMethod · 0.45
requireElementMethod · 0.45
matchTokenMethod · 0.45
raiseErrorMethod · 0.45

Tested by

no test coverage detected