Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: sky/specs/parsing.md

Issue 705443002: Specs: Explain the parser a bit better. Make the output of registerElement() something you can pass… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/specs/apis.md ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 Then, pass the tokens to the tree construction stage. 779 Then, pass the tokens to the tree construction stage.
780 780
781 781
782 Tree construction stage 782 Tree construction stage
783 ----------------------- 783 -----------------------
784 784
785 To construct a node tree from a _sequence of tokens_ and a document 785 To construct a node tree from a _sequence of tokens_ and a document
786 _document_: 786 _document_:
787 787
788 1. Initialize the _stack of open nodes_ to be _document_. 788 1. Initialize the _stack of open nodes_ to be _document_.
789 2. Consider each token _token_ in the _sequence of tokens_ in turn, as 789 2. Initialize _imported modules_ to an empty list.
790 3. Consider each token _token_ in the _sequence of tokens_ in turn, as
790 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
791 next token, without doing any more work with the skipped token. 792 next token, without doing any more work with the skipped token.
792 - If _token_ is a string token, 793 - If _token_ is a string token,
793 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
794 characters, and there is no ``t`` element on the _stack of 795 characters, and there is no ``t`` element on the _stack of
795 open nodes_, then skip the token. 796 open nodes_, then skip the token.
796 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
797 the token. 798 the token.
798 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_.
799 - If _token_ is a start tag token, 800 - If _token_ is a start tag token,
800 1. Create an element _node_ with tag name and attributes given by 801 1. Create an element _node_ with tag name and attributes given by
801 the token. 802 the token.
802 2. Append _node_ to the top node in the _stack of open nodes_. 803 2. Append _node_ to the top node in the _stack of open nodes_.
803 3. Push _node_ onto the top of the _stack of open nodes_. 804 3. Push _node_ onto the top of the _stack of open nodes_.
804 4. If _node_ is a ``template`` element, then: 805 4. If _node_ is a ``template`` element, then:
805 1. Let _fragment_ be the ``DocumentFragment`` object that the 806 1. Let _fragment_ be the ``DocumentFragment`` object that the
806 ``template`` element uses as its template contents container. 807 ``template`` element uses as its template contents container.
807 2. Push _fragment_ onto the top of the _stack of open nodes_. 808 2. Push _fragment_ onto the top of the _stack of open nodes_.
809 If _node_ is an ``import`` element, then:
810 1. Let ``url`` be the value of _node_'s ``src`` attribute.
811 2. Call ``parsing context``'s ``importModule()`` method,
812 passing it ``url``.
813 3. Add the returned promise to _imported modules_; if _node_
814 has an ``as`` attribute, associate the entry with that
815 name.
808 - If _token_ is an end tag token: 816 - If _token_ is an end tag token:
809 1. Let _node_ be the topmost node in the _stack of open nodes_ 817 1. Let _node_ be the topmost node in the _stack of open nodes_
810 whose tag name is the same as the token's tag name, if any. If 818 whose tag name is the same as the token's tag name, if any. If
811 there isn't one, skip this token. 819 there isn't one, skip this token.
812 2. If there's a ``template`` element in the _stack of open 820 2. If there's a ``template`` element in the _stack of open
813 nodes_ above _node_, then skip this token. 821 nodes_ above _node_, then skip this token.
814 3. Pop nodes from the _stack of open nodes_ until _node_ has been 822 3. Pop nodes from the _stack of open nodes_ until _node_ has been
815 popped. 823 popped.
816 4. If _node_'s tag name is ``script``, then yield until there 824 4. If _node_'s tag name is ``script``, then yield until _imported
817 are no pending import loads, then execute the script given by 825 modules_ contains no entries with unresolved promises, then
818 the element's contents. 826 execute the script given by the element's contents, using the
819 3. Yield until there are no pending import loads. 827 associated names as appropriate.
820 3. Fire a ``load`` event at the _parsing context_ object. 828 4. Yield until _imported modules_ has no promises.
829 5. Fire a ``load`` event at the _parsing context_ object.
OLDNEW
« no previous file with comments | « sky/specs/apis.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698