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

Method parse

www/js/_hyperscript.js:4001–4047  ·  view source on GitHub ↗
(parser)

Source from the content-addressed store, hash-verified

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