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

Method parse

src/parsetree/commands/basic.js:866–904  ·  view source on GitHub ↗
(parser)

Source from the content-addressed store, hash-verified

864 }
865
866 static parse(parser) {
867 if (!parser.matchToken("go")) return;
868
869 if (parser.matchToken("back")) {
870 return new GoCommand(null, null, true);
871 }
872
873 parser.matchToken("to");
874
875 // deprecated: go [to] url <stringLike>
876 if (parser.matchToken("url")) {
877 var target = parser.requireElement("stringLike");
878 var newWindow = false;
879 if (parser.matchToken("in")) {
880 parser.requireToken("new");
881 parser.requireToken("window");
882 newWindow = true;
883 }
884 return new GoCommand(target, null, false, newWindow);
885 }
886
887 // deprecated: go [to] [the] top/middle/bottom ... of <expr> (scroll form)
888 var cur = parser.currentToken();
889 if (cur.value === "the" || cur.value === "top" || cur.value === "middle" || cur.value === "bottom"
890 || cur.value === "left" || cur.value === "center" || cur.value === "right") {
891 var scroll = _parseScrollModifiers(parser);
892 return new GoCommand(scroll.target, scroll.offset, false, false, scroll.plusOrMinus, scroll.scrollOptions);
893 }
894
895 // new: go [to] <url-or-expression> [in new window]
896 var target = parser.parseURLOrExpression();
897 var newWindow = false;
898 if (parser.matchToken("in")) {
899 parser.requireToken("new");
900 parser.requireToken("window");
901 newWindow = true;
902 }
903 return new GoCommand(target, null, false, newWindow);
904 }
905
906 resolve(ctx, { target: to, offset }) {
907 if (this.back) {

Callers

nothing calls this directly

Calls 6

_parseScrollModifiersFunction · 0.70
matchTokenMethod · 0.45
requireElementMethod · 0.45
requireTokenMethod · 0.45
currentTokenMethod · 0.45
parseURLOrExpressionMethod · 0.45

Tested by

no test coverage detected