UNPKG

svelte-parse

Version:

An increidbly relaxed svelte-parser

1,666 lines (1,665 loc) 31.4 kB
{ "type": "root", "children": [ { "type": "svelteScript", "tagName": "script", "properties": [], "selfClosing": false, "children": [ { "type": "text", "value": "\n\tlet scoops = 1;\n\tlet flavours = ['Mint choc chip'];\n\n\tlet menu = [\n\t\t'Cookies and cream',\n\t\t'Mint choc chip',\n\t\t'Raspberry ripple'\n\t];\n\n\tfunction join(flavours) {\n\t\tif (flavours.length === 1) return flavours[0];\n\t\treturn `${flavours.slice(0, -1).join(', ')} and ${flavours[flavours.length - 1]}`;\n\t}\n", "position": { "start": { "line": 1, "column": 9, "offset": 8 }, "end": { "line": 15, "column": 1, "offset": 310 } } } ], "position": { "start": { "line": 1, "column": 1, "offset": 0 }, "end": { "line": 15, "column": 10, "offset": 319 } } }, { "type": "text", "value": "\n\n", "position": { "start": { "line": 15, "column": 10, "offset": 319 }, "end": { "line": 17, "column": 1, "offset": 321 } } }, { "type": "svelteElement", "tagName": "h2", "properties": [], "selfClosing": false, "children": [ { "type": "text", "value": "Size", "position": { "start": { "line": 17, "column": 5, "offset": 325 }, "end": { "line": 17, "column": 9, "offset": 329 } } } ], "position": { "start": { "line": 17, "column": 1, "offset": 321 }, "end": { "line": 17, "column": 14, "offset": 334 } } }, { "type": "text", "value": "\n\n", "position": { "start": { "line": 17, "column": 14, "offset": 334 }, "end": { "line": 19, "column": 1, "offset": 336 } } }, { "type": "svelteElement", "tagName": "label", "properties": [], "selfClosing": false, "children": [ { "type": "text", "value": "\n\t", "position": { "start": { "line": 19, "column": 8, "offset": 343 }, "end": { "line": 20, "column": 2, "offset": 345 } } }, { "type": "svelteElement", "tagName": "input", "properties": [ { "type": "svelteProperty", "name": "type", "value": [ { "type": "text", "value": "radio", "position": { "start": { "line": 20, "column": 14, "offset": 357 }, "end": { "line": 20, "column": 19, "offset": 362 } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 20, "column": 9, "offset": 352 }, "end": { "line": 20, "column": 19, "offset": 362 } } }, { "type": "svelteDirective", "name": "bind", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 20, "column": 31, "offset": 374 }, "end": { "line": 20, "column": 39, "offset": 382 } }, "expression": { "type": "svelteExpression", "value": "scoops", "position": { "start": { "line": 20, "column": 32, "offset": 375 }, "end": { "line": 20, "column": 38, "offset": 381 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 20, "column": 20, "offset": 363 }, "end": { "line": 20, "column": 39, "offset": 382 } }, "specifier": "group" }, { "type": "svelteProperty", "name": "value", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 20, "column": 46, "offset": 389 }, "end": { "line": 20, "column": 49, "offset": 392 } }, "expression": { "type": "svelteExpression", "value": "1", "position": { "start": { "line": 20, "column": 47, "offset": 390 }, "end": { "line": 20, "column": 48, "offset": 391 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 20, "column": 40, "offset": 383 }, "end": { "line": 20, "column": 49, "offset": 392 } } } ], "selfClosing": true, "children": [], "position": { "start": { "line": 20, "column": 2, "offset": 345 }, "end": { "line": 20, "column": 50, "offset": 393 } } }, { "type": "text", "value": "\n\tOne scoop\n", "position": { "start": { "line": 20, "column": 50, "offset": 393 }, "end": { "line": 22, "column": 1, "offset": 405 } } } ], "position": { "start": { "line": 19, "column": 1, "offset": 336 }, "end": { "line": 22, "column": 9, "offset": 413 } } }, { "type": "text", "value": "\n\n", "position": { "start": { "line": 22, "column": 9, "offset": 413 }, "end": { "line": 24, "column": 1, "offset": 415 } } }, { "type": "svelteElement", "tagName": "label", "properties": [], "selfClosing": false, "children": [ { "type": "text", "value": "\n\t", "position": { "start": { "line": 24, "column": 8, "offset": 422 }, "end": { "line": 25, "column": 2, "offset": 424 } } }, { "type": "svelteElement", "tagName": "input", "properties": [ { "type": "svelteProperty", "name": "type", "value": [ { "type": "text", "value": "radio", "position": { "start": { "line": 25, "column": 14, "offset": 436 }, "end": { "line": 25, "column": 19, "offset": 441 } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 25, "column": 9, "offset": 431 }, "end": { "line": 25, "column": 19, "offset": 441 } } }, { "type": "svelteDirective", "name": "bind", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 25, "column": 31, "offset": 453 }, "end": { "line": 25, "column": 39, "offset": 461 } }, "expression": { "type": "svelteExpression", "value": "scoops", "position": { "start": { "line": 25, "column": 32, "offset": 454 }, "end": { "line": 25, "column": 38, "offset": 460 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 25, "column": 20, "offset": 442 }, "end": { "line": 25, "column": 39, "offset": 461 } }, "specifier": "group" }, { "type": "svelteProperty", "name": "value", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 25, "column": 46, "offset": 468 }, "end": { "line": 25, "column": 49, "offset": 471 } }, "expression": { "type": "svelteExpression", "value": "2", "position": { "start": { "line": 25, "column": 47, "offset": 469 }, "end": { "line": 25, "column": 48, "offset": 470 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 25, "column": 40, "offset": 462 }, "end": { "line": 25, "column": 49, "offset": 471 } } } ], "selfClosing": true, "children": [], "position": { "start": { "line": 25, "column": 2, "offset": 424 }, "end": { "line": 25, "column": 50, "offset": 472 } } }, { "type": "text", "value": "\n\tTwo scoops\n", "position": { "start": { "line": 25, "column": 50, "offset": 472 }, "end": { "line": 27, "column": 1, "offset": 485 } } } ], "position": { "start": { "line": 24, "column": 1, "offset": 415 }, "end": { "line": 27, "column": 9, "offset": 493 } } }, { "type": "text", "value": "\n\n", "position": { "start": { "line": 27, "column": 9, "offset": 493 }, "end": { "line": 29, "column": 1, "offset": 495 } } }, { "type": "svelteElement", "tagName": "label", "properties": [], "selfClosing": false, "children": [ { "type": "text", "value": "\n\t", "position": { "start": { "line": 29, "column": 8, "offset": 502 }, "end": { "line": 30, "column": 2, "offset": 504 } } }, { "type": "svelteElement", "tagName": "input", "properties": [ { "type": "svelteProperty", "name": "type", "value": [ { "type": "text", "value": "radio", "position": { "start": { "line": 30, "column": 14, "offset": 516 }, "end": { "line": 30, "column": 19, "offset": 521 } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 30, "column": 9, "offset": 511 }, "end": { "line": 30, "column": 19, "offset": 521 } } }, { "type": "svelteDirective", "name": "bind", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 30, "column": 31, "offset": 533 }, "end": { "line": 30, "column": 39, "offset": 541 } }, "expression": { "type": "svelteExpression", "value": "scoops", "position": { "start": { "line": 30, "column": 32, "offset": 534 }, "end": { "line": 30, "column": 38, "offset": 540 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 30, "column": 20, "offset": 522 }, "end": { "line": 30, "column": 39, "offset": 541 } }, "specifier": "group" }, { "type": "svelteProperty", "name": "value", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 30, "column": 46, "offset": 548 }, "end": { "line": 30, "column": 49, "offset": 551 } }, "expression": { "type": "svelteExpression", "value": "3", "position": { "start": { "line": 30, "column": 47, "offset": 549 }, "end": { "line": 30, "column": 48, "offset": 550 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 30, "column": 40, "offset": 542 }, "end": { "line": 30, "column": 49, "offset": 551 } } } ], "selfClosing": true, "children": [], "position": { "start": { "line": 30, "column": 2, "offset": 504 }, "end": { "line": 30, "column": 50, "offset": 552 } } }, { "type": "text", "value": "\n\tThree scoops\n", "position": { "start": { "line": 30, "column": 50, "offset": 552 }, "end": { "line": 32, "column": 1, "offset": 567 } } } ], "position": { "start": { "line": 29, "column": 1, "offset": 495 }, "end": { "line": 32, "column": 9, "offset": 575 } } }, { "type": "text", "value": "\n\n", "position": { "start": { "line": 32, "column": 9, "offset": 575 }, "end": { "line": 34, "column": 1, "offset": 577 } } }, { "type": "svelteElement", "tagName": "h2", "properties": [], "selfClosing": false, "children": [ { "type": "text", "value": "Flavours", "position": { "start": { "line": 34, "column": 5, "offset": 581 }, "end": { "line": 34, "column": 13, "offset": 589 } } } ], "position": { "start": { "line": 34, "column": 1, "offset": 577 }, "end": { "line": 34, "column": 18, "offset": 594 } } }, { "type": "text", "value": "\n\n", "position": { "start": { "line": 34, "column": 18, "offset": 594 }, "end": { "line": 36, "column": 1, "offset": 596 } } }, { "type": "svelteBranchingBlock", "name": "each", "branches": [ { "type": "svelteBranch", "name": "each", "expression": { "type": "svelteExpression", "value": "menu as flavour", "position": { "start": { "line": 36, "column": 8, "offset": 603 }, "end": { "line": 36, "column": 23, "offset": 618 } } }, "children": [ { "type": "text", "value": "\n\t", "position": { "start": { "line": 36, "column": 24, "offset": 619 }, "end": { "line": 37, "column": 2, "offset": 621 } } }, { "type": "svelteElement", "tagName": "label", "properties": [], "selfClosing": false, "children": [ { "type": "text", "value": "\n\t\t", "position": { "start": { "line": 37, "column": 9, "offset": 628 }, "end": { "line": 38, "column": 3, "offset": 631 } } }, { "type": "svelteElement", "tagName": "input", "properties": [ { "type": "svelteProperty", "name": "type", "value": [ { "type": "text", "value": "checkbox", "position": { "start": { "line": 38, "column": 15, "offset": 643 }, "end": { "line": 38, "column": 23, "offset": 651 } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 38, "column": 10, "offset": 638 }, "end": { "line": 38, "column": 23, "offset": 651 } } }, { "type": "svelteDirective", "name": "bind", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 38, "column": 35, "offset": 663 }, "end": { "line": 38, "column": 45, "offset": 673 } }, "expression": { "type": "svelteExpression", "value": "flavours", "position": { "start": { "line": 38, "column": 36, "offset": 664 }, "end": { "line": 38, "column": 44, "offset": 672 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 38, "column": 24, "offset": 652 }, "end": { "line": 38, "column": 45, "offset": 673 } }, "specifier": "group" }, { "type": "svelteProperty", "name": "value", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 38, "column": 52, "offset": 680 }, "end": { "line": 38, "column": 61, "offset": 689 } }, "expression": { "type": "svelteExpression", "value": "flavour", "position": { "start": { "line": 38, "column": 53, "offset": 681 }, "end": { "line": 38, "column": 60, "offset": 688 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 38, "column": 46, "offset": 674 }, "end": { "line": 38, "column": 61, "offset": 689 } } } ], "selfClosing": true, "children": [], "position": { "start": { "line": 38, "column": 3, "offset": 631 }, "end": { "line": 38, "column": 62, "offset": 690 } } }, { "type": "text", "value": "\n\t\t", "position": { "start": { "line": 38, "column": 62, "offset": 690 }, "end": { "line": 39, "column": 3, "offset": 693 } } }, { "type": "svelteDynamicContent", "position": { "start": { "line": 39, "column": 3, "offset": 693 }, "end": { "line": 39, "column": 12, "offset": 702 } }, "expression": { "type": "svelteExpression", "value": "flavour", "position": { "start": { "line": 39, "column": 4, "offset": 694 }, "end": { "line": 39, "column": 11, "offset": 701 } } } }, { "type": "text", "value": "\n\t", "position": { "start": { "line": 39, "column": 12, "offset": 702 }, "end": { "line": 40, "column": 2, "offset": 704 } } } ], "position": { "start": { "line": 37, "column": 2, "offset": 621 }, "end": { "line": 40, "column": 10, "offset": 712 } } }, { "type": "text", "value": "\n", "position": { "start": { "line": 40, "column": 10, "offset": 712 }, "end": { "line": 41, "column": 1, "offset": 713 } } } ], "position": { "start": { "line": 36, "column": 1, "offset": 596 }, "end": { "line": 41, "column": 1, "offset": 713 } } } ], "position": { "start": { "line": 36, "column": 1, "offset": 596 }, "end": { "line": 41, "column": 8, "offset": 720 } } }, { "type": "text", "value": "\n\n", "position": { "start": { "line": 41, "column": 8, "offset": 720 }, "end": { "line": 43, "column": 1, "offset": 722 } } }, { "type": "svelteBranchingBlock", "name": "if", "branches": [ { "type": "svelteBranch", "name": "if", "expression": { "type": "svelteExpression", "value": "flavours.length === 0", "position": { "start": { "line": 43, "column": 6, "offset": 727 }, "end": { "line": 43, "column": 27, "offset": 748 } } }, "children": [ { "type": "text", "value": "\n\t", "position": { "start": { "line": 43, "column": 28, "offset": 749 }, "end": { "line": 44, "column": 2, "offset": 751 } } }, { "type": "svelteElement", "tagName": "p", "properties": [], "selfClosing": false, "children": [ { "type": "text", "value": "Please select at least one flavour", "position": { "start": { "line": 44, "column": 5, "offset": 754 }, "end": { "line": 44, "column": 39, "offset": 788 } } } ], "position": { "start": { "line": 44, "column": 2, "offset": 751 }, "end": { "line": 44, "column": 43, "offset": 792 } } }, { "type": "text", "value": "\n", "position": { "start": { "line": 44, "column": 43, "offset": 792 }, "end": { "line": 45, "column": 1, "offset": 793 } } } ], "position": { "start": { "line": 43, "column": 1, "offset": 722 }, "end": { "line": 45, "column": 1, "offset": 793 } } }, { "type": "svelteBranch", "name": "else if", "expression": { "type": "svelteExpression", "value": "flavours.length > scoops", "position": { "start": { "line": 45, "column": 11, "offset": 803 }, "end": { "line": 45, "column": 35, "offset": 827 } } }, "children": [ { "type": "text", "value": "\n\t", "position": { "start": { "line": 45, "column": 36, "offset": 828 }, "end": { "line": 46, "column": 2, "offset": 830 } } }, { "type": "svelteElement", "tagName": "p", "properties": [], "selfClosing": false, "children": [ { "type": "text", "value": "Can't order more flavours than scoops!", "position": { "start": { "line": 46, "column": 5, "offset": 833 }, "end": { "line": 46, "column": 43, "offset": 871 } } } ], "position": { "start": { "line": 46, "column": 2, "offset": 830 }, "end": { "line": 46, "column": 47, "offset": 875 } } }, { "type": "text", "value": "\n", "position": { "start": { "line": 46, "column": 47, "offset": 875 }, "end": { "line": 47, "column": 1, "offset": 876 } } } ], "position": { "start": { "line": 45, "column": 1, "offset": 793 }, "end": { "line": 47, "column": 1, "offset": 876 } } }, { "type": "svelteBranch", "name": "else", "expression": { "type": "svelteExpression", "value": "" }, "children": [ { "type": "text", "value": "\n\t", "position": { "start": { "line": 47, "column": 8, "offset": 883 }, "end": { "line": 48, "column": 2, "offset": 885 } } }, { "type": "svelteElement", "tagName": "p", "properties": [], "selfClosing": false, "children": [ { "type": "text", "value": "\n\t\tYou ordered ", "position": { "start": { "line": 48, "column": 5, "offset": 888 }, "end": { "line": 49, "column": 15, "offset": 903 } } }, { "type": "svelteDynamicContent", "position": { "start": { "line": 49, "column": 15, "offset": 903 }, "end": { "line": 49, "column": 23, "offset": 911 } }, "expression": { "type": "svelteExpression", "value": "scoops", "position": { "start": { "line": 49, "column": 16, "offset": 904 }, "end": { "line": 49, "column": 22, "offset": 910 } } } }, { "type": "text", "value": " ", "position": { "start": { "line": 49, "column": 23, "offset": 911 }, "end": { "line": 49, "column": 24, "offset": 912 } } }, { "type": "svelteDynamicContent", "position": { "start": { "line": 49, "column": 24, "offset": 912 }, "end": { "line": 49, "column": 59, "offset": 947 } }, "expression": { "type": "svelteExpression", "value": "scoops === 1 ? 'scoop' : 'scoops'", "position": { "start": { "line": 49, "column": 25, "offset": 913 }, "end": { "line": 49, "column": 58, "offset": 946 } } } }, { "type": "text", "value": "\n\t\tof ", "position": { "start": { "line": 49, "column": 59, "offset": 947 }, "end": { "line": 50, "column": 6, "offset": 953 } } }, { "type": "svelteDynamicContent", "position": { "start": { "line": 50, "column": 6, "offset": 953 }, "end": { "line": 50, "column": 22, "offset": 969 } }, "expression": { "type": "svelteExpression", "value": "join(flavours)", "position": { "start": { "line": 50, "column": 7, "offset": 954 }, "end": { "line": 50, "column": 21, "offset": 968 } } } }, { "type": "text", "value": "\n\t", "position": { "start": { "line": 50, "column": 22, "offset": 969 }, "end": { "line": 51, "column": 2, "offset": 971 } } } ], "position": { "start": { "line": 48, "column": 2, "offset": 885 }, "end": { "line": 51, "column": 6, "offset": 975 } } }, { "type": "text", "value": "\n", "position": { "start": { "line": 51, "column": 6, "offset": 975 }, "end": { "line": 52, "column": 1, "offset": 976 } } } ], "position": { "start": { "line": 47, "column": 1, "offset": 876 }, "end": { "line": 52, "column": 1, "offset": 976 } } } ], "position": { "start": { "line": 43, "column": 1, "offset": 722 }, "end": { "line": 52, "column": 6, "offset": 981 } } } ], "position": { "start": { "column": 1, "line": 1, "offset": 0 }, "end": { "line": 52, "column": 6, "offset": 981 } } }