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

Method parse

www/js/_hyperscript-max.js:4000–4046  ·  view source on GitHub ↗
(parser)

Source from the content-addressed store, hash-verified

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