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

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

Issue 940593003: Specs: clean up the last remaining mentions of documents (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 months 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/modules.md ('k') | sky/specs/pointer.md » ('j') | 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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 776
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 an element
787 _document_ (this is implemented in JS): 787 tree rooted at a `Root` node _root_ (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 _root_.
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.
798 2. Create a text node _node_ whose character data is the value of 798 2. Create a text node _node_ whose character data is the value of
799 the token. 799 the token.
800 3. Append _node_ to the top node in the _stack of open nodes_. 800 3. Append _node_ to the top node in the _stack of open nodes_.
801 - If _token_ is a start tag token, 801 - If _token_ is a start tag token,
802 1. If the tag name isn't a registered tag name, then yield until 802 1. If the tag name isn't a registered tag name, then yield until
803 _imported modules_ contains no entries with unresolved 803 _imported modules_ contains no entries with unresolved
804 promises. 804 promises.
805 2. If the tag name is not registered, then let the ErrorElement 805 2. If the tag name is not registered, then let the ErrorElement
806 constructor from dart:sky be the element constructor. 806 constructor from dart:sky be the element constructor.
807 Otherwise, let the element constructor be the registered 807 Otherwise, let the element constructor be the registered
808 element's constructor for that tag name in this module. 808 element's constructor for that tag name in this module.
809 3. Create an element _node_ with the attributes given by the 809 3. Create an element _node_ with the attributes given by the
810 token by calling the constructor. 810 token by calling the constructor.
811 4. If _node_ is not an Element object, then let the constructor 811 4. If _node_ is not an Element object, then let the constructor
812 be the ErrorElement constructor and return to the previous 812 be the ErrorElement constructor and return to the previous
813 step. 813 step.
814 5. Append _node_ to the top node in the _stack of open nodes_. 814 5. Append _node_ to the top node in the _stack of open nodes_.
815 6. Push _node_ onto the top of the _stack of open nodes_. 815 6. Push _node_ onto the top of the _stack of open nodes_.
816 7. If _node_ is a ``template`` element, then: 816 7. If _node_ is a ``template`` element, then:
817 1. Let _fragment_ be the ``DocumentFragment`` object that the 817 1. Let _fragment_ be the ``Fragment`` object that the
818 ``template`` element uses as its template contents container. 818 ``template`` element uses as its template contents
819 container.
819 2. Push _fragment_ onto the top of the _stack of open nodes_. 820 2. Push _fragment_ onto the top of the _stack of open nodes_.
820 If _node_ is an ``import`` element, then: 821 If _node_ is an ``import`` element, then:
821 1. Let ``url`` be the value of _node_'s ``src`` attribute. 822 1. Let ``url`` be the value of _node_'s ``src`` attribute.
822 2. Call ``parsing context``'s ``importModule()`` method, 823 2. Call ``parsing context``'s ``importModule()`` method,
823 passing it ``url``. 824 passing it ``url``.
824 3. Add the returned promise to _imported modules_; if _node_ 825 3. Add the returned promise to _imported modules_; if _node_
825 has an ``as`` attribute, associate the entry with that 826 has an ``as`` attribute, associate the entry with that
826 name. 827 name.
827 - If _token_ is an end tag token: 828 - If _token_ is an end tag token:
828 1. If the tag name is registered, let _tag name_ be that tag 829 1. If the tag name is registered, let _tag name_ be that tag
829 name. Otherwise, let _tag name_ be "error". 830 name. Otherwise, let _tag name_ be "error".
830 2. Let _node_ be the topmost node in the _stack of open nodes_ 831 2. Let _node_ be the topmost node in the _stack of open nodes_
831 whose tag name is _tag name_, if any. If there isn't one, skip 832 whose tag name is _tag name_, if any. If there isn't one, skip
832 this token. 833 this token.
833 3. If there's a ``template`` element in the _stack of open 834 3. If there's a ``template`` element in the _stack of open
834 nodes_ above _node_, then skip this token. 835 nodes_ above _node_, then skip this token.
835 4. Pop nodes from the _stack of open nodes_ until _node_ has been 836 4. Pop nodes from the _stack of open nodes_ until _node_ has been
836 popped. 837 popped.
837 5. If _node_'s tag name is ``script``, then yield until _imported 838 5. If _node_'s tag name is ``script``, then yield until _imported
838 modules_ contains no entries with unresolved promises, then 839 modules_ contains no entries with unresolved promises, then
839 execute the script given by the element's contents, using the 840 execute the script given by the element's contents, using the
840 associated names as appropriate. 841 associated names as appropriate.
841 - If _token_ is an automatic end tag token: 842 - If _token_ is an automatic end tag token:
842 1. Pop the top node from the _stack of open nodes_, unless it is 843 1. Pop the top node from the _stack of open nodes_, unless it is
843 the document. 844 the _root_ node.
844 4. Yield until _imported modules_ has no promises. 845 4. Yield until _imported modules_ has no promises.
845 5. Fire a ``load`` event at the _parsing context_ object. 846 5. Fire a ``load`` event at the _parsing context_ object.
OLDNEW
« no previous file with comments | « sky/specs/modules.md ('k') | sky/specs/pointer.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698