OLD | NEW |
1 Parsing | 1 Parsing |
2 ======= | 2 ======= |
3 | 3 |
4 Parsing in Sky is a strict pipeline consisting of five stages: | 4 Parsing in Sky is a strict pipeline consisting of five stages: |
5 | 5 |
6 - decoding, which converts incoming bytes into Unicode characters | 6 - decoding, which converts incoming bytes into Unicode characters |
7 using UTF-8. | 7 using UTF-8. |
8 | 8 |
9 - normalising, which manipulates the sequence of characters. | 9 - normalising, which manipulates the sequence of characters. |
10 | 10 |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 follows. If a token is to be skipped, then jump straight to the | 791 follows. If a token is to be skipped, then jump straight to the |
792 next token, without doing any more work with the skipped token. | 792 next token, without doing any more work with the skipped token. |
793 - If _token_ is a string token, | 793 - If _token_ is a string token, |
794 1. If the value of the token contains only U+0020 and U+000A | 794 1. If the value of the token contains only U+0020 and U+000A |
795 characters, and there is no ``t`` element on the _stack of | 795 characters, and there is no ``t`` element on the _stack of |
796 open nodes_, then skip the token. | 796 open nodes_, then skip the token. |
797 2. Create a text node _node_ whose character data is the value of | 797 2. Create a text node _node_ whose character data is the value of |
798 the token. | 798 the token. |
799 3. Append _node_ to the top node in the _stack of open nodes_. | 799 3. Append _node_ to the top node in the _stack of open nodes_. |
800 - If _token_ is a start tag token, | 800 - If _token_ is a start tag token, |
801 1. Create an element _node_ with tag name and attributes given by | 801 1. If the tag name isn't a registered tag name, then yield until |
802 the token. | 802 _imported modules_ contains no entries with unresolved |
803 2. Append _node_ to the top node in the _stack of open nodes_. | 803 promises. |
804 3. Push _node_ onto the top of the _stack of open nodes_. | 804 2. If the tag name is registered, create an element _node_ with |
805 4. If _node_ is a ``template`` element, then: | 805 tag name and attributes given by the token. Otherwise, create |
| 806 an element with the tag name "error" and the attributes given |
| 807 by the token. |
| 808 3. Append _node_ to the top node in the _stack of open nodes_. |
| 809 4. Push _node_ onto the top of the _stack of open nodes_. |
| 810 5. If _node_ is a ``template`` element, then: |
806 1. Let _fragment_ be the ``DocumentFragment`` object that the | 811 1. Let _fragment_ be the ``DocumentFragment`` object that the |
807 ``template`` element uses as its template contents container. | 812 ``template`` element uses as its template contents container. |
808 2. Push _fragment_ onto the top of the _stack of open nodes_. | 813 2. Push _fragment_ onto the top of the _stack of open nodes_. |
809 If _node_ is an ``import`` element, then: | 814 If _node_ is an ``import`` element, then: |
810 1. Let ``url`` be the value of _node_'s ``src`` attribute. | 815 1. Let ``url`` be the value of _node_'s ``src`` attribute. |
811 2. Call ``parsing context``'s ``importModule()`` method, | 816 2. Call ``parsing context``'s ``importModule()`` method, |
812 passing it ``url``. | 817 passing it ``url``. |
813 3. Add the returned promise to _imported modules_; if _node_ | 818 3. Add the returned promise to _imported modules_; if _node_ |
814 has an ``as`` attribute, associate the entry with that | 819 has an ``as`` attribute, associate the entry with that |
815 name. | 820 name. |
816 - If _token_ is an end tag token: | 821 - If _token_ is an end tag token: |
817 1. Let _node_ be the topmost node in the _stack of open nodes_ | 822 1. If the tag name is registered, let _tag name_ be that tag |
818 whose tag name is the same as the token's tag name, if any. If | 823 name. Otherwise, let _tag name_ be "error". |
819 there isn't one, skip this token. | 824 2. Let _node_ be the topmost node in the _stack of open nodes_ |
820 2. If there's a ``template`` element in the _stack of open | 825 whose tag name is _tag name_, if any. If there isn't one, skip |
| 826 this token. |
| 827 3. If there's a ``template`` element in the _stack of open |
821 nodes_ above _node_, then skip this token. | 828 nodes_ above _node_, then skip this token. |
822 3. Pop nodes from the _stack of open nodes_ until _node_ has been | 829 4. Pop nodes from the _stack of open nodes_ until _node_ has been |
823 popped. | 830 popped. |
824 4. If _node_'s tag name is ``script``, then yield until _imported | 831 5. If _node_'s tag name is ``script``, then yield until _imported |
825 modules_ contains no entries with unresolved promises, then | 832 modules_ contains no entries with unresolved promises, then |
826 execute the script given by the element's contents, using the | 833 execute the script given by the element's contents, using the |
827 associated names as appropriate. | 834 associated names as appropriate. |
828 4. Yield until _imported modules_ has no promises. | 835 4. Yield until _imported modules_ has no promises. |
829 5. Fire a ``load`` event at the _parsing context_ object. | 836 5. Fire a ``load`` event at the _parsing context_ object. |
OLD | NEW |