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 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 If the token is a start tag token, notify the JavaScript token stream | 777 If the token is a start tag token, notify the JavaScript token stream |
778 callback of the token. | 778 callback of the token. |
779 | 779 |
780 Then, pass the tokens to the tree construction stage. | 780 Then, pass the tokens to the tree construction stage. |
781 | 781 |
782 | 782 |
783 Tree construction stage | 783 Tree construction stage |
784 ----------------------- | 784 ----------------------- |
785 | 785 |
786 To construct a node tree from a _sequence of tokens_ and a document | 786 To construct a node tree from a _sequence of tokens_ and a document |
787 _document_: | 787 _document_ (this is implemented in JS): |
788 | 788 |
789 1. Initialize the _stack of open nodes_ to be _document_. | 789 1. Initialize the _stack of open nodes_ to be _document_. |
790 2. Initialize _imported modules_ to an empty list. | 790 2. Initialize _imported modules_ to an empty list. |
791 3. Consider each token _token_ in the _sequence of tokens_ in turn, as | 791 3. Consider each token _token_ in the _sequence of tokens_ in turn, as |
792 follows. If a token is to be skipped, then jump straight to the | 792 follows. If a token is to be skipped, then jump straight to the |
793 next token, without doing any more work with the skipped token. | 793 next token, without doing any more work with the skipped token. |
794 - If _token_ is a string token, | 794 - If _token_ is a string token, |
795 1. If the value of the token contains only U+0020 and U+000A | 795 1. If the value of the token contains only U+0020 and U+000A |
796 characters, and there is no ``t`` element on the _stack of | 796 characters, and there is no ``t`` element on the _stack of |
797 open nodes_, then skip the token. | 797 open nodes_, then skip the token. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 popped. | 836 popped. |
837 5. If _node_'s tag name is ``script``, then yield until _imported | 837 5. If _node_'s tag name is ``script``, then yield until _imported |
838 modules_ contains no entries with unresolved promises, then | 838 modules_ contains no entries with unresolved promises, then |
839 execute the script given by the element's contents, using the | 839 execute the script given by the element's contents, using the |
840 associated names as appropriate. | 840 associated names as appropriate. |
841 - If _token_ is an automatic end tag token: | 841 - If _token_ is an automatic end tag token: |
842 1. Pop the top node from the _stack of open nodes_, unless it is | 842 1. Pop the top node from the _stack of open nodes_, unless it is |
843 the document. | 843 the document. |
844 4. Yield until _imported modules_ has no promises. | 844 4. Yield until _imported modules_ has no promises. |
845 5. Fire a ``load`` event at the _parsing context_ object. | 845 5. Fire a ``load`` event at the _parsing context_ object. |
OLD | NEW |