MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / parse

Method parse

www/js/_hyperscript.esm.js:3999–4045  ·  view source on GitHub ↗
(parser)

Source from the content-addressed store, hash-verified

3997 this.targetExpr = targetExpr || null;
3998 }
3999 static parse(parser) {
4000 var scope = null;
4001 if (parser.matchToken("global")) {
4002 scope = "global";
4003 } else if (parser.matchToken("element")) {
4004 scope = "element";
4005 if (parser.matchOpToken("'")) {
4006 parser.requireToken("s");
4007 }
4008 } else if (parser.matchToken("dom")) {
4009 scope = "inherited";
4010 } else if (parser.matchToken("local")) {
4011 scope = "local";
4012 }
4013 let eltPrefix = parser.matchOpToken(":");
4014 let caretPrefix = !eltPrefix && parser.matchOpToken("^");
4015 let identifier = parser.matchTokenType("IDENTIFIER");
4016 if (identifier && identifier.value) {
4017 var name = identifier.value;
4018 if (eltPrefix) {
4019 name = ":" + name;
4020 } else if (caretPrefix) {
4021 name = "^" + name;
4022 }
4023 if (scope === null) {
4024 if (name.startsWith("$")) {
4025 scope = "global";
4026 } else if (name.startsWith(":")) {
4027 scope = "element";
4028 } else if (name.startsWith("^")) {
4029 scope = "inherited";
4030 } else {
4031 scope = "local";
4032 }
4033 }
4034 var targetExpr = null;
4035 if (scope === "inherited" && parser.matchToken("on")) {
4036 var follows = parser.pushFollows("to", "into", "before", "after", "then");
4037 try {
4038 targetExpr = parser.requireElement("expression");
4039 } finally {
4040 parser.popFollows(follows);
4041 }
4042 }
4043 return new _SymbolRef(identifier, scope, name, targetExpr);
4044 }
4045 }
4046 resolve(context) {
4047 return context.meta.runtime.resolveSymbol(
4048 this.name,

Callers

nothing calls this directly

Calls 7

matchTokenMethod · 0.45
matchOpTokenMethod · 0.45
requireTokenMethod · 0.45
matchTokenTypeMethod · 0.45
pushFollowsMethod · 0.45
requireElementMethod · 0.45
popFollowsMethod · 0.45

Tested by

no test coverage detected