| OLD | NEW |
| 1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
| 2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
| 3 | 3 |
| 4 library engine.html.scanner; | 4 library engine.html; |
| 5 | 5 |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'java_core.dart'; | 7 import 'java_core.dart'; |
| 8 import 'source.dart'; | 8 import 'source.dart'; |
| 9 import 'error.dart'; | 9 import 'error.dart'; |
| 10 import 'instrumentation.dart'; | 10 import 'instrumentation.dart'; |
| 11 import 'element.dart' show HtmlElementImpl; |
| 11 | 12 |
| 12 /** | 13 /** |
| 13 * Instances of the class {@code Token} represent a token that was scanned from
the input. Each | 14 * Instances of the class {@code Token} represent a token that was scanned from
the input. Each |
| 14 * token knows which token follows it, acting as the head of a linked list of to
kens. | 15 * token knows which token follows it, acting as the head of a linked list of to
kens. |
| 16 * @coverage dart.engine.html |
| 15 */ | 17 */ |
| 16 class Token { | 18 class Token { |
| 17 /** | 19 /** |
| 18 * The offset from the beginning of the file to the first character in the tok
en. | 20 * The offset from the beginning of the file to the first character in the tok
en. |
| 19 */ | 21 */ |
| 20 int _offset = 0; | 22 int _offset = 0; |
| 21 /** | 23 /** |
| 22 * The previous token in the token stream. | 24 * The previous token in the token stream. |
| 23 */ | 25 */ |
| 24 Token _previous; | 26 Token _previous; |
| 25 /** | 27 /** |
| 26 * The next token in the token stream. | 28 * The next token in the token stream. |
| 27 */ | 29 */ |
| 28 Token _next; | 30 Token _next; |
| 29 /** | 31 /** |
| 30 * The type of the token. | 32 * The type of the token. |
| 31 */ | 33 */ |
| 32 TokenType _type; | 34 TokenType _type; |
| 33 /** | 35 /** |
| 34 * The lexeme represented by this token. | 36 * The lexeme represented by this token. |
| 35 */ | 37 */ |
| 36 String _value; | 38 String _value; |
| 37 /** | 39 /** |
| 38 * Initialize a newly created token. | 40 * Initialize a newly created token. |
| 39 * @param type the token type (not {@code null}) | 41 * @param type the token type (not {@code null}) |
| 40 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 42 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 41 */ | 43 */ |
| 42 Token.con1(TokenType type, int offset) { | 44 Token.con1(TokenType type, int offset) { |
| 43 _jtd_constructor_143_impl(type, offset); | 45 _jtd_constructor_145_impl(type, offset); |
| 44 } | 46 } |
| 45 _jtd_constructor_143_impl(TokenType type, int offset) { | 47 _jtd_constructor_145_impl(TokenType type, int offset) { |
| 46 _jtd_constructor_144_impl(type, offset, type.lexeme); | 48 _jtd_constructor_146_impl(type, offset, type.lexeme); |
| 47 } | 49 } |
| 48 /** | 50 /** |
| 49 * Initialize a newly created token. | 51 * Initialize a newly created token. |
| 50 * @param type the token type (not {@code null}) | 52 * @param type the token type (not {@code null}) |
| 51 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 53 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 52 * @param value the lexeme represented by this token (not {@code null}) | 54 * @param value the lexeme represented by this token (not {@code null}) |
| 53 */ | 55 */ |
| 54 Token.con2(TokenType type4, int offset3, String value7) { | 56 Token.con2(TokenType type4, int offset3, String value7) { |
| 55 _jtd_constructor_144_impl(type4, offset3, value7); | 57 _jtd_constructor_146_impl(type4, offset3, value7); |
| 56 } | 58 } |
| 57 _jtd_constructor_144_impl(TokenType type4, int offset3, String value7) { | 59 _jtd_constructor_146_impl(TokenType type4, int offset3, String value7) { |
| 58 this._type = type4; | 60 this._type = type4; |
| 59 this._value = value7; | 61 this._value = value7; |
| 60 this._offset = offset3; | 62 this._offset = offset3; |
| 61 } | 63 } |
| 62 /** | 64 /** |
| 63 * Return the offset from the beginning of the file to the character after las
t character of the | 65 * Return the offset from the beginning of the file to the character after las
t character of the |
| 64 * token. | 66 * token. |
| 65 * @return the offset from the beginning of the file to the first character af
ter last character | 67 * @return the offset from the beginning of the file to the first character af
ter last character |
| 66 * of the token | 68 * of the token |
| 67 */ | 69 */ |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 /** | 120 /** |
| 119 * Set the previous token in the token stream to the given token. | 121 * Set the previous token in the token stream to the given token. |
| 120 * @param previous the previous token in the token stream | 122 * @param previous the previous token in the token stream |
| 121 */ | 123 */ |
| 122 void set previous(Token previous2) { | 124 void set previous(Token previous2) { |
| 123 this._previous = previous2; | 125 this._previous = previous2; |
| 124 } | 126 } |
| 125 } | 127 } |
| 126 /** | 128 /** |
| 127 * Instances of {@code HtmlParseResult} hold the result of parsing an HTML file. | 129 * Instances of {@code HtmlParseResult} hold the result of parsing an HTML file. |
| 130 * @coverage dart.engine.html |
| 128 */ | 131 */ |
| 129 class HtmlParseResult extends HtmlScanResult { | 132 class HtmlParseResult extends HtmlScanResult { |
| 130 /** | 133 /** |
| 131 * The unit containing the parsed information (not {@code null}). | 134 * The unit containing the parsed information (not {@code null}). |
| 132 */ | 135 */ |
| 133 HtmlUnit _unit; | 136 HtmlUnit _unit; |
| 134 HtmlParseResult(Token token, List<int> lineStarts, HtmlUnit unit) : super(toke
n, lineStarts) { | 137 HtmlParseResult(Token token, List<int> lineStarts, HtmlUnit unit) : super(toke
n, lineStarts) { |
| 135 this._unit = unit; | 138 this._unit = unit; |
| 136 } | 139 } |
| 137 /** | 140 /** |
| 138 * Answer the unit generated by parsing the source | 141 * Answer the unit generated by parsing the source |
| 139 * @return the unit (not {@code null}) | 142 * @return the unit (not {@code null}) |
| 140 */ | 143 */ |
| 141 HtmlUnit get htmlUnit => _unit; | 144 HtmlUnit get htmlUnit => _unit; |
| 142 } | 145 } |
| 143 /** | 146 /** |
| 144 * Instances of the class {@code RecursiveXmlVisitor} implement an XML visitor t
hat will recursively | 147 * Instances of the class {@code RecursiveXmlVisitor} implement an XML visitor t
hat will recursively |
| 145 * visit all of the nodes in an XML structure. For example, using an instance of
this class to visit | 148 * visit all of the nodes in an XML structure. For example, using an instance of
this class to visit |
| 146 * a {@link XmlTagNode} will also cause all of the contained {@link XmlAttribute
Node}s and{@link XmlTagNode}s to be visited. | 149 * a {@link XmlTagNode} will also cause all of the contained {@link XmlAttribute
Node}s and{@link XmlTagNode}s to be visited. |
| 147 * <p> | 150 * <p> |
| 148 * Subclasses that override a visit method must either invoke the overridden vis
it method or must | 151 * Subclasses that override a visit method must either invoke the overridden vis
it method or must |
| 149 * explicitly ask the visited node to visit its children. Failure to do so will
cause the children | 152 * explicitly ask the visited node to visit its children. Failure to do so will
cause the children |
| 150 * of the visited node to not be visited. | 153 * of the visited node to not be visited. |
| 154 * @coverage dart.engine.html |
| 151 */ | 155 */ |
| 152 class RecursiveXmlVisitor<R> implements XmlVisitor<R> { | 156 class RecursiveXmlVisitor<R> implements XmlVisitor<R> { |
| 153 R visitHtmlUnit(HtmlUnit node) { | 157 R visitHtmlUnit(HtmlUnit node) { |
| 154 node.visitChildren(this); | 158 node.visitChildren(this); |
| 155 return null; | 159 return null; |
| 156 } | 160 } |
| 157 R visitXmlAttributeNode(XmlAttributeNode node) { | 161 R visitXmlAttributeNode(XmlAttributeNode node) { |
| 158 node.visitChildren(this); | 162 node.visitChildren(this); |
| 159 return null; | 163 return null; |
| 160 } | 164 } |
| 161 R visitXmlTagNode(XmlTagNode node) { | 165 R visitXmlTagNode(XmlTagNode node) { |
| 162 node.visitChildren(this); | 166 node.visitChildren(this); |
| 163 return null; | 167 return null; |
| 164 } | 168 } |
| 165 } | 169 } |
| 166 /** | 170 /** |
| 167 * The abstract class {@code XmlNode} defines behavior common to all XML/HTML no
des. | 171 * The abstract class {@code XmlNode} defines behavior common to all XML/HTML no
des. |
| 172 * @coverage dart.engine.html |
| 168 */ | 173 */ |
| 169 abstract class XmlNode { | 174 abstract class XmlNode { |
| 170 /** | 175 /** |
| 171 * The parent of the node, or {@code null} if the node is the root of an AST s
tructure. | 176 * The parent of the node, or {@code null} if the node is the root of an AST s
tructure. |
| 172 */ | 177 */ |
| 173 XmlNode _parent; | 178 XmlNode _parent; |
| 174 /** | 179 /** |
| 175 * Use the given visitor to visit this node. | 180 * Use the given visitor to visit this node. |
| 176 * @param visitor the visitor that will visit this node | 181 * @param visitor the visitor that will visit this node |
| 177 * @return the value returned by the visitor as a result of visiting this node | 182 * @return the value returned by the visitor as a result of visiting this node |
| (...skipping 14 matching lines...) Expand all Loading... |
| 192 /** | 197 /** |
| 193 * Return the last token included in this node's source range. | 198 * Return the last token included in this node's source range. |
| 194 * @return the last token or {@code null} if none | 199 * @return the last token or {@code null} if none |
| 195 */ | 200 */ |
| 196 Token get endToken; | 201 Token get endToken; |
| 197 /** | 202 /** |
| 198 * Return the number of characters in the node's source range. | 203 * Return the number of characters in the node's source range. |
| 199 * @return the number of characters in the node's source range | 204 * @return the number of characters in the node's source range |
| 200 */ | 205 */ |
| 201 int get length { | 206 int get length { |
| 202 Token beginToken5 = beginToken; | 207 Token beginToken4 = beginToken; |
| 203 Token endToken4 = endToken; | 208 Token endToken4 = endToken; |
| 204 if (beginToken5 == null || endToken4 == null) { | 209 if (beginToken4 == null || endToken4 == null) { |
| 205 return -1; | 210 return -1; |
| 206 } | 211 } |
| 207 return endToken4.offset + endToken4.length - beginToken5.offset; | 212 return endToken4.offset + endToken4.length - beginToken4.offset; |
| 208 } | 213 } |
| 209 /** | 214 /** |
| 210 * Return the offset from the beginning of the file to the first character in
the node's source | 215 * Return the offset from the beginning of the file to the first character in
the node's source |
| 211 * range. | 216 * range. |
| 212 * @return the offset from the beginning of the file to the first character in
the node's source | 217 * @return the offset from the beginning of the file to the first character in
the node's source |
| 213 * range | 218 * range |
| 214 */ | 219 */ |
| 215 int get offset { | 220 int get offset { |
| 216 Token beginToken6 = beginToken; | 221 Token beginToken5 = beginToken; |
| 217 if (beginToken6 == null) { | 222 if (beginToken5 == null) { |
| 218 return -1; | 223 return -1; |
| 219 } | 224 } |
| 220 return beginToken.offset; | 225 return beginToken.offset; |
| 221 } | 226 } |
| 222 /** | 227 /** |
| 223 * Return this node's parent node, or {@code null} if this node is the root of
an AST structure. | 228 * Return this node's parent node, or {@code null} if this node is the root of
an AST structure. |
| 224 * <p> | 229 * <p> |
| 225 * Note that the relationship between an AST node and its parent node may chan
ge over the lifetime | 230 * Note that the relationship between an AST node and its parent node may chan
ge over the lifetime |
| 226 * of a node. | 231 * of a node. |
| 227 * @return the parent of this node, or {@code null} if none | 232 * @return the parent of this node, or {@code null} if none |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 } | 266 } |
| 262 /** | 267 /** |
| 263 * Set the parent of this node to the given node. | 268 * Set the parent of this node to the given node. |
| 264 * @param newParent the node that is to be made the parent of this node | 269 * @param newParent the node that is to be made the parent of this node |
| 265 */ | 270 */ |
| 266 void set parent(XmlNode newParent) { | 271 void set parent(XmlNode newParent) { |
| 267 _parent = newParent; | 272 _parent = newParent; |
| 268 } | 273 } |
| 269 } | 274 } |
| 270 /** | 275 /** |
| 276 * Instances of the class {@code SimpleXmlVisitor} implement an AST visitor that
will do nothing |
| 277 * when visiting an AST node. It is intended to be a superclass for classes that
use the visitor |
| 278 * pattern primarily as a dispatch mechanism (and hence don't need to recursivel
y visit a whole |
| 279 * structure) and that only need to visit a small number of node types. |
| 280 */ |
| 281 class SimpleXmlVisitor<R> implements XmlVisitor<R> { |
| 282 R visitHtmlUnit(HtmlUnit htmlUnit) => null; |
| 283 R visitXmlAttributeNode(XmlAttributeNode xmlAttributeNode) => null; |
| 284 R visitXmlTagNode(XmlTagNode xmlTagNode) => null; |
| 285 } |
| 286 /** |
| 271 * The abstract class {@code AbstractScanner} implements a scanner for HTML code
. Subclasses are | 287 * The abstract class {@code AbstractScanner} implements a scanner for HTML code
. Subclasses are |
| 272 * required to implement the interface used to access the characters being scann
ed. | 288 * required to implement the interface used to access the characters being scann
ed. |
| 289 * @coverage dart.engine.html |
| 273 */ | 290 */ |
| 274 abstract class AbstractScanner { | 291 abstract class AbstractScanner { |
| 275 static List<String> _NO_PASS_THROUGH_ELEMENTS = <String> []; | 292 static List<String> _NO_PASS_THROUGH_ELEMENTS = <String> []; |
| 276 /** | 293 /** |
| 277 * The source being scanned. | 294 * The source being scanned. |
| 278 */ | 295 */ |
| 279 Source _source; | 296 Source _source; |
| 280 /** | 297 /** |
| 281 * The token pointing to the head of the linked list of tokens. | 298 * The token pointing to the head of the linked list of tokens. |
| 282 */ | 299 */ |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 emit3(TokenType.TAG, start, -1); | 537 emit3(TokenType.TAG, start, -1); |
| 521 } else { | 538 } else { |
| 522 emit3(TokenType.TEXT, start, 0); | 539 emit3(TokenType.TEXT, start, 0); |
| 523 c = advance(); | 540 c = advance(); |
| 524 } | 541 } |
| 525 } | 542 } |
| 526 } | 543 } |
| 527 } | 544 } |
| 528 /** | 545 /** |
| 529 * Instances of {@code HtmlScanResult} hold the result of scanning an HTML file. | 546 * Instances of {@code HtmlScanResult} hold the result of scanning an HTML file. |
| 547 * @coverage dart.engine.html |
| 530 */ | 548 */ |
| 531 class HtmlScanResult { | 549 class HtmlScanResult { |
| 532 /** | 550 /** |
| 533 * The first token in the token stream (not {@code null}). | 551 * The first token in the token stream (not {@code null}). |
| 534 */ | 552 */ |
| 535 Token _token; | 553 Token _token; |
| 536 /** | 554 /** |
| 537 * The line start information that was produced. | 555 * The line start information that was produced. |
| 538 */ | 556 */ |
| 539 List<int> _lineStarts; | 557 List<int> _lineStarts; |
| 540 HtmlScanResult(Token token, List<int> lineStarts) { | 558 HtmlScanResult(Token token, List<int> lineStarts) { |
| 541 this._token = token; | 559 this._token = token; |
| 542 this._lineStarts = lineStarts; | 560 this._lineStarts = lineStarts; |
| 543 } | 561 } |
| 544 /** | 562 /** |
| 545 * Answer the line start information that was produced. | 563 * Answer the line start information that was produced. |
| 546 * @return an array of line starts (not {@code null}) | 564 * @return an array of line starts (not {@code null}) |
| 547 */ | 565 */ |
| 548 List<int> get lineStarts => _lineStarts; | 566 List<int> get lineStarts => _lineStarts; |
| 549 /** | 567 /** |
| 550 * Answer the first token in the token stream. | 568 * Answer the first token in the token stream. |
| 551 * @return the token (not {@code null}) | 569 * @return the token (not {@code null}) |
| 552 */ | 570 */ |
| 553 Token get token => _token; | 571 Token get token => _token; |
| 554 } | 572 } |
| 555 /** | 573 /** |
| 556 * Instances of the class {@code StringScanner} implement a scanner that reads f
rom a string. The | 574 * Instances of the class {@code StringScanner} implement a scanner that reads f
rom a string. The |
| 557 * scanning logic is in the superclass. | 575 * scanning logic is in the superclass. |
| 576 * @coverage dart.engine.html |
| 558 */ | 577 */ |
| 559 class StringScanner extends AbstractScanner { | 578 class StringScanner extends AbstractScanner { |
| 560 /** | 579 /** |
| 561 * The string from which characters will be read. | 580 * The string from which characters will be read. |
| 562 */ | 581 */ |
| 563 String _string; | 582 String _string; |
| 564 /** | 583 /** |
| 565 * The number of characters in the string. | 584 * The number of characters in the string. |
| 566 */ | 585 */ |
| 567 int _stringLength = 0; | 586 int _stringLength = 0; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 594 int peek() { | 613 int peek() { |
| 595 if (_charOffset + 1 < _stringLength) { | 614 if (_charOffset + 1 < _stringLength) { |
| 596 return _string.codeUnitAt(_charOffset + 1); | 615 return _string.codeUnitAt(_charOffset + 1); |
| 597 } | 616 } |
| 598 return -1; | 617 return -1; |
| 599 } | 618 } |
| 600 } | 619 } |
| 601 /** | 620 /** |
| 602 * Instances of the class {@code CharBufferScanner} implement a scanner that rea
ds from a character | 621 * Instances of the class {@code CharBufferScanner} implement a scanner that rea
ds from a character |
| 603 * buffer. The scanning logic is in the superclass. | 622 * buffer. The scanning logic is in the superclass. |
| 623 * @coverage dart.engine.html |
| 604 */ | 624 */ |
| 605 class CharBufferScanner extends AbstractScanner { | 625 class CharBufferScanner extends AbstractScanner { |
| 606 /** | 626 /** |
| 607 * The buffer from which characters will be read. | 627 * The buffer from which characters will be read. |
| 608 */ | 628 */ |
| 609 CharBuffer _buffer; | 629 CharBuffer _buffer; |
| 610 /** | 630 /** |
| 611 * The number of characters in the buffer. | 631 * The number of characters in the buffer. |
| 612 */ | 632 */ |
| 613 int _bufferLength = 0; | 633 int _bufferLength = 0; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 637 int peek() { | 657 int peek() { |
| 638 if (_charOffset + 1 < _bufferLength) { | 658 if (_charOffset + 1 < _bufferLength) { |
| 639 return _buffer.charAt(_charOffset + 1); | 659 return _buffer.charAt(_charOffset + 1); |
| 640 } | 660 } |
| 641 return -1; | 661 return -1; |
| 642 } | 662 } |
| 643 } | 663 } |
| 644 /** | 664 /** |
| 645 * The enumeration {@code TokenType} defines the types of tokens that can be ret
urned by the | 665 * The enumeration {@code TokenType} defines the types of tokens that can be ret
urned by the |
| 646 * scanner. | 666 * scanner. |
| 667 * @coverage dart.engine.html |
| 647 */ | 668 */ |
| 648 class TokenType { | 669 class TokenType { |
| 649 /** | 670 /** |
| 650 * The type of the token that marks the end of the input. | 671 * The type of the token that marks the end of the input. |
| 651 */ | 672 */ |
| 652 static final TokenType EOF = new TokenType_EOF('EOF', 0, ""); | 673 static final TokenType EOF = new TokenType_EOF('EOF', 0, ""); |
| 653 static final TokenType EQ = new TokenType('EQ', 1, "="); | 674 static final TokenType EQ = new TokenType('EQ', 1, "="); |
| 654 static final TokenType GT = new TokenType('GT', 2, ">"); | 675 static final TokenType GT = new TokenType('GT', 2, ">"); |
| 655 static final TokenType LT_SLASH = new TokenType('LT_SLASH', 3, "</"); | 676 static final TokenType LT_SLASH = new TokenType('LT_SLASH', 3, "</"); |
| 656 static final TokenType LT = new TokenType('LT', 4, "<"); | 677 static final TokenType LT = new TokenType('LT', 4, "<"); |
| 657 static final TokenType SLASH_GT = new TokenType('SLASH_GT', 5, "/>"); | 678 static final TokenType SLASH_GT = new TokenType('SLASH_GT', 5, "/>"); |
| 658 static final TokenType COMMENT = new TokenType('COMMENT', 6, null); | 679 static final TokenType COMMENT = new TokenType('COMMENT', 6, null); |
| 659 static final TokenType DECLARATION = new TokenType('DECLARATION', 7, null); | 680 static final TokenType DECLARATION = new TokenType('DECLARATION', 7, null); |
| 660 static final TokenType DIRECTIVE = new TokenType('DIRECTIVE', 8, null); | 681 static final TokenType DIRECTIVE = new TokenType('DIRECTIVE', 8, null); |
| 661 static final TokenType STRING = new TokenType('STRING', 9, null); | 682 static final TokenType STRING = new TokenType('STRING', 9, null); |
| 662 static final TokenType TAG = new TokenType('TAG', 10, null); | 683 static final TokenType TAG = new TokenType('TAG', 10, null); |
| 663 static final TokenType TEXT = new TokenType('TEXT', 11, null); | 684 static final TokenType TEXT = new TokenType('TEXT', 11, null); |
| 664 static final List<TokenType> values = [EOF, EQ, GT, LT_SLASH, LT, SLASH_GT, CO
MMENT, DECLARATION, DIRECTIVE, STRING, TAG, TEXT]; | 685 static final List<TokenType> values = [EOF, EQ, GT, LT_SLASH, LT, SLASH_GT, CO
MMENT, DECLARATION, DIRECTIVE, STRING, TAG, TEXT]; |
| 665 final String __name; | 686 final String __name; |
| 666 final int __ordinal; | 687 final int __ordinal; |
| 688 int get ordinal => __ordinal; |
| 667 /** | 689 /** |
| 668 * The lexeme that defines this type of token, or {@code null} if there is mor
e than one possible | 690 * The lexeme that defines this type of token, or {@code null} if there is mor
e than one possible |
| 669 * lexeme for this type of token. | 691 * lexeme for this type of token. |
| 670 */ | 692 */ |
| 671 String _lexeme; | 693 String _lexeme; |
| 672 TokenType(this.__name, this.__ordinal, String lexeme) { | 694 TokenType(this.__name, this.__ordinal, String lexeme) { |
| 673 this._lexeme = lexeme; | 695 this._lexeme = lexeme; |
| 674 } | 696 } |
| 675 /** | 697 /** |
| 676 * Return the lexeme that defines this type of token, or {@code null} if there
is more than one | 698 * Return the lexeme that defines this type of token, or {@code null} if there
is more than one |
| 677 * possible lexeme for this type of token. | 699 * possible lexeme for this type of token. |
| 678 * @return the lexeme that defines this type of token | 700 * @return the lexeme that defines this type of token |
| 679 */ | 701 */ |
| 680 String get lexeme => _lexeme; | 702 String get lexeme => _lexeme; |
| 681 String toString() => __name; | 703 String toString() => __name; |
| 682 } | 704 } |
| 683 class TokenType_EOF extends TokenType { | 705 class TokenType_EOF extends TokenType { |
| 684 TokenType_EOF(String ___name, int ___ordinal, String arg0) : super(___name, __
_ordinal, arg0); | 706 TokenType_EOF(String ___name, int ___ordinal, String arg0) : super(___name, __
_ordinal, arg0); |
| 685 String toString() => "-eof-"; | 707 String toString() => "-eof-"; |
| 686 } | 708 } |
| 687 /** | 709 /** |
| 688 * Instances of {@code XmlAttributeNode} represent name/value pairs owned by an
{@link XmlTagNode}. | 710 * Instances of {@code XmlAttributeNode} represent name/value pairs owned by an
{@link XmlTagNode}. |
| 711 * @coverage dart.engine.html |
| 689 */ | 712 */ |
| 690 class XmlAttributeNode extends XmlNode { | 713 class XmlAttributeNode extends XmlNode { |
| 691 Token _name; | 714 Token _name; |
| 692 Token _equals; | 715 Token _equals; |
| 693 Token _value; | 716 Token _value; |
| 694 /** | 717 /** |
| 695 * Construct a new instance representing an XML attribute. | 718 * Construct a new instance representing an XML attribute. |
| 696 * @param name the name token (not {@code null}). This may be a zero length to
ken if the attribute | 719 * @param name the name token (not {@code null}). This may be a zero length to
ken if the attribute |
| 697 * is badly formed. | 720 * is badly formed. |
| 698 * @param equals the equals sign or {@code null} if none | 721 * @param equals the equals sign or {@code null} if none |
| (...skipping 11 matching lines...) Expand all Loading... |
| 710 * Answer the equals sign token that appears between the name and value tokens
. This may be{@code null} if the attribute is badly formed. | 733 * Answer the equals sign token that appears between the name and value tokens
. This may be{@code null} if the attribute is badly formed. |
| 711 * @return the token or {@code null} if there is no equals sign between the na
me and value | 734 * @return the token or {@code null} if there is no equals sign between the na
me and value |
| 712 */ | 735 */ |
| 713 Token get equals => _equals; | 736 Token get equals => _equals; |
| 714 /** | 737 /** |
| 715 * Answer the attribute name. This may be a zero length token if the attribute
is badly formed. | 738 * Answer the attribute name. This may be a zero length token if the attribute
is badly formed. |
| 716 * @return the name (not {@code null}) | 739 * @return the name (not {@code null}) |
| 717 */ | 740 */ |
| 718 Token get name => _name; | 741 Token get name => _name; |
| 719 /** | 742 /** |
| 743 * Answer the lexeme for the value token without the leading and trailing quot
es. |
| 744 * @return the text or {@code null} if the value is not specified |
| 745 */ |
| 746 String get text { |
| 747 if (_value == null) { |
| 748 return null; |
| 749 } |
| 750 String text = _value.lexeme; |
| 751 int len = text.length; |
| 752 if (len > 0) { |
| 753 if (text.codeUnitAt(0) == 0x22) { |
| 754 if (len > 1 && text.codeUnitAt(len - 1) == 0x22) { |
| 755 return text.substring(1, len - 1); |
| 756 } else { |
| 757 return text.substring(1); |
| 758 } |
| 759 } else if (text.codeUnitAt(0) == 0x27) { |
| 760 if (len > 1 && text.codeUnitAt(len - 1) == 0x27) { |
| 761 return text.substring(1, len - 1); |
| 762 } else { |
| 763 return text.substring(1); |
| 764 } |
| 765 } |
| 766 } |
| 767 return text; |
| 768 } |
| 769 /** |
| 720 * Answer the attribute value. A properly formed value will start and end with
matching quote | 770 * Answer the attribute value. A properly formed value will start and end with
matching quote |
| 721 * characters, but the value returned may not be properly formed. | 771 * characters, but the value returned may not be properly formed. |
| 722 * @return the value or {@code null} if this represents a badly formed attribu
te | 772 * @return the value or {@code null} if this represents a badly formed attribu
te |
| 723 */ | 773 */ |
| 724 Token get value => _value; | 774 Token get value => _value; |
| 725 void visitChildren(XmlVisitor<Object> visitor) { | 775 void visitChildren(XmlVisitor<Object> visitor) { |
| 726 } | 776 } |
| 727 } | 777 } |
| 728 /** | 778 /** |
| 729 * The interface {@code XmlVisitor} defines the behavior of objects that can be
used to visit an{@link XmlNode} structure. | 779 * The interface {@code XmlVisitor} defines the behavior of objects that can be
used to visit an{@link XmlNode} structure. |
| 780 * @coverage dart.engine.html |
| 730 */ | 781 */ |
| 731 abstract class XmlVisitor<R> { | 782 abstract class XmlVisitor<R> { |
| 732 R visitHtmlUnit(HtmlUnit htmlUnit); | 783 R visitHtmlUnit(HtmlUnit htmlUnit); |
| 733 R visitXmlAttributeNode(XmlAttributeNode xmlAttributeNode); | 784 R visitXmlAttributeNode(XmlAttributeNode xmlAttributeNode); |
| 734 R visitXmlTagNode(XmlTagNode xmlTagNode); | 785 R visitXmlTagNode(XmlTagNode xmlTagNode); |
| 735 } | 786 } |
| 736 /** | 787 /** |
| 737 * Instances of {@code HtmlScanner} receive and scan HTML content from a {@link
Source}.<br/> | 788 * Instances of {@code HtmlScanner} receive and scan HTML content from a {@link
Source}.<br/> |
| 738 * For example, the following code scans HTML source and returns the result: | 789 * For example, the following code scans HTML source and returns the result: |
| 739 * <pre> | 790 * <pre> |
| 740 * HtmlScanner scanner = new HtmlScanner(source); | 791 * HtmlScanner scanner = new HtmlScanner(source); |
| 741 * source.getContents(scanner); | 792 * source.getContents(scanner); |
| 742 * return scanner.getResult(); | 793 * return scanner.getResult(); |
| 743 * </pre> | 794 * </pre> |
| 795 * @coverage dart.engine.html |
| 744 */ | 796 */ |
| 745 class HtmlScanner implements Source_ContentReceiver { | 797 class HtmlScanner implements Source_ContentReceiver { |
| 746 List<String> _SCRIPT_TAG = <String> ["script"]; | 798 List<String> _SCRIPT_TAG = <String> ["script"]; |
| 747 /** | 799 /** |
| 748 * The source being scanned (not {@code null}) | 800 * The source being scanned (not {@code null}) |
| 749 */ | 801 */ |
| 750 Source _source; | 802 Source _source; |
| 751 /** | 803 /** |
| 752 * The scanner used to scan the source | 804 * The scanner used to scan the source |
| 753 */ | 805 */ |
| (...skipping 21 matching lines...) Expand all Loading... |
| 775 } | 827 } |
| 776 /** | 828 /** |
| 777 * Answer the result of scanning the source | 829 * Answer the result of scanning the source |
| 778 * @return the result (not {@code null}) | 830 * @return the result (not {@code null}) |
| 779 */ | 831 */ |
| 780 HtmlScanResult get result => new HtmlScanResult(_token, _scanner.lineStarts); | 832 HtmlScanResult get result => new HtmlScanResult(_token, _scanner.lineStarts); |
| 781 } | 833 } |
| 782 /** | 834 /** |
| 783 * Instances of the class {@code XmlParser} are used to parse tokens into a AST
structure comprised | 835 * Instances of the class {@code XmlParser} are used to parse tokens into a AST
structure comprised |
| 784 * of {@link XmlNode}s. | 836 * of {@link XmlNode}s. |
| 837 * @coverage dart.engine.html |
| 785 */ | 838 */ |
| 786 class XmlParser { | 839 class XmlParser { |
| 787 /** | 840 /** |
| 788 * The source being parsed. | 841 * The source being parsed. |
| 789 */ | 842 */ |
| 790 Source _source; | 843 Source _source; |
| 791 /** | 844 /** |
| 792 * The next token to be parsed. | 845 * The next token to be parsed. |
| 793 */ | 846 */ |
| 794 Token _currentToken; | 847 Token _currentToken; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 return new XmlTagNode(nodeStart, tag, attributes, attributeEnd, tagNodes, co
ntentEnd, closingTag, nodeEnd); | 1038 return new XmlTagNode(nodeStart, tag, attributes, attributeEnd, tagNodes, co
ntentEnd, closingTag, nodeEnd); |
| 986 } | 1039 } |
| 987 /** | 1040 /** |
| 988 * Report the current token as unexpected | 1041 * Report the current token as unexpected |
| 989 */ | 1042 */ |
| 990 void reportUnexpectedToken() { | 1043 void reportUnexpectedToken() { |
| 991 } | 1044 } |
| 992 } | 1045 } |
| 993 /** | 1046 /** |
| 994 * Instances of {@code XmlTagNode} represent XML or HTML elements such as {@code
<p>} and{@code <body foo="bar"> ... </body>}. | 1047 * Instances of {@code XmlTagNode} represent XML or HTML elements such as {@code
<p>} and{@code <body foo="bar"> ... </body>}. |
| 1048 * @coverage dart.engine.html |
| 995 */ | 1049 */ |
| 996 class XmlTagNode extends XmlNode { | 1050 class XmlTagNode extends XmlNode { |
| 997 /** | 1051 /** |
| 998 * Constant representing empty list of attributes. | 1052 * Constant representing empty list of attributes. |
| 999 */ | 1053 */ |
| 1000 static List<XmlAttributeNode> NO_ATTRIBUTES = new UnmodifiableListView(new Lis
t<XmlAttributeNode>()); | 1054 static List<XmlAttributeNode> NO_ATTRIBUTES = new UnmodifiableListView(new Lis
t<XmlAttributeNode>()); |
| 1001 /** | 1055 /** |
| 1002 * Constant representing empty list of tag nodes. | 1056 * Constant representing empty list of tag nodes. |
| 1003 */ | 1057 */ |
| 1004 static List<XmlTagNode> NO_TAG_NODES = new UnmodifiableListView(new List<XmlTa
gNode>()); | 1058 static List<XmlTagNode> NO_TAG_NODES = new UnmodifiableListView(new List<XmlTa
gNode>()); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 node.accept(visitor); | 1231 node.accept(visitor); |
| 1178 } | 1232 } |
| 1179 for (XmlTagNode node in _tagNodes) { | 1233 for (XmlTagNode node in _tagNodes) { |
| 1180 node.accept(visitor); | 1234 node.accept(visitor); |
| 1181 } | 1235 } |
| 1182 } | 1236 } |
| 1183 } | 1237 } |
| 1184 /** | 1238 /** |
| 1185 * Instances of the class {@code HtmlParser} are used to parse tokens into a AST
structure comprised | 1239 * Instances of the class {@code HtmlParser} are used to parse tokens into a AST
structure comprised |
| 1186 * of {@link XmlNode}s. | 1240 * of {@link XmlNode}s. |
| 1241 * @coverage dart.engine.html |
| 1187 */ | 1242 */ |
| 1188 class HtmlParser extends XmlParser { | 1243 class HtmlParser extends XmlParser { |
| 1189 static Set<String> SELF_CLOSING = new Set<String>(); | 1244 static Set<String> SELF_CLOSING = new Set<String>(); |
| 1190 /** | 1245 /** |
| 1191 * Construct a parser for the specified source. | 1246 * Construct a parser for the specified source. |
| 1192 * @param source the source being parsed | 1247 * @param source the source being parsed |
| 1193 */ | 1248 */ |
| 1194 HtmlParser(Source source) : super(source) { | 1249 HtmlParser(Source source) : super(source) { |
| 1195 } | 1250 } |
| 1196 /** | 1251 /** |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1211 */ | 1266 */ |
| 1212 HtmlParseResult parse2(Source source) { | 1267 HtmlParseResult parse2(Source source) { |
| 1213 HtmlScanner scanner = new HtmlScanner(source); | 1268 HtmlScanner scanner = new HtmlScanner(source); |
| 1214 source.getContents(scanner); | 1269 source.getContents(scanner); |
| 1215 return parse(scanner.result); | 1270 return parse(scanner.result); |
| 1216 } | 1271 } |
| 1217 bool isSelfClosing(Token tag) => SELF_CLOSING.contains(tag.lexeme); | 1272 bool isSelfClosing(Token tag) => SELF_CLOSING.contains(tag.lexeme); |
| 1218 } | 1273 } |
| 1219 /** | 1274 /** |
| 1220 * Instances of the class {@code HtmlUnit} represent the contents of an HTML fil
e. | 1275 * Instances of the class {@code HtmlUnit} represent the contents of an HTML fil
e. |
| 1276 * @coverage dart.engine.html |
| 1221 */ | 1277 */ |
| 1222 class HtmlUnit extends XmlNode { | 1278 class HtmlUnit extends XmlNode { |
| 1223 /** | 1279 /** |
| 1224 * The first token in the token stream that was parsed to form this HTML unit. | 1280 * The first token in the token stream that was parsed to form this HTML unit. |
| 1225 */ | 1281 */ |
| 1226 Token _beginToken; | 1282 Token _beginToken; |
| 1227 /** | 1283 /** |
| 1228 * The last token in the token stream that was parsed to form this compilation
unit. This token | 1284 * The last token in the token stream that was parsed to form this compilation
unit. This token |
| 1229 * should always have a type of {@link TokenType.EOF}. | 1285 * should always have a type of {@link TokenType.EOF}. |
| 1230 */ | 1286 */ |
| 1231 Token _endToken; | 1287 Token _endToken; |
| 1232 /** | 1288 /** |
| 1233 * The tag nodes contained in the receiver (not {@code null}, contains no {@co
de null}s). | 1289 * The tag nodes contained in the receiver (not {@code null}, contains no {@co
de null}s). |
| 1234 */ | 1290 */ |
| 1235 List<XmlTagNode> _tagNodes; | 1291 List<XmlTagNode> _tagNodes; |
| 1236 /** | 1292 /** |
| 1293 * The element associated with this HTML unit or {@code null} if the receiver
is not resolved. |
| 1294 */ |
| 1295 HtmlElementImpl _element; |
| 1296 /** |
| 1237 * Construct a new instance representing the content of an HTML file. | 1297 * Construct a new instance representing the content of an HTML file. |
| 1238 * @param beginToken the first token in the file (not {@code null}) | 1298 * @param beginToken the first token in the file (not {@code null}) |
| 1239 * @param tagNodes child tag nodes of the receiver (not {@code null}, contains
no {@code null}s) | 1299 * @param tagNodes child tag nodes of the receiver (not {@code null}, contains
no {@code null}s) |
| 1240 * @param endToken the last token in the token stream which should be of type{
@link TokenType.EOF} | 1300 * @param endToken the last token in the token stream which should be of type{
@link TokenType.EOF} |
| 1241 */ | 1301 */ |
| 1242 HtmlUnit(Token beginToken, List<XmlTagNode> tagNodes, Token endToken) { | 1302 HtmlUnit(Token beginToken, List<XmlTagNode> tagNodes, Token endToken) { |
| 1243 this._beginToken = beginToken; | 1303 this._beginToken = beginToken; |
| 1244 this._tagNodes = becomeParentOf(tagNodes); | 1304 this._tagNodes = becomeParentOf(tagNodes); |
| 1245 this._endToken = endToken; | 1305 this._endToken = endToken; |
| 1246 } | 1306 } |
| 1247 accept(XmlVisitor visitor) => visitor.visitHtmlUnit(this); | 1307 accept(XmlVisitor visitor) => visitor.visitHtmlUnit(this); |
| 1248 Token get beginToken => _beginToken; | 1308 Token get beginToken => _beginToken; |
| 1309 /** |
| 1310 * Return the element associated with this HTML unit. |
| 1311 * @return the element or {@code null} if the receiver is not resolved |
| 1312 */ |
| 1313 HtmlElementImpl get element => _element; |
| 1249 Token get endToken => _endToken; | 1314 Token get endToken => _endToken; |
| 1250 /** | 1315 /** |
| 1251 * Answer the tag nodes contained in the receiver. Callers should not manipula
te the returned list | 1316 * Answer the tag nodes contained in the receiver. Callers should not manipula
te the returned list |
| 1252 * to edit the AST structure. | 1317 * to edit the AST structure. |
| 1253 * @return the children (not {@code null}, contains no {@code null}s) | 1318 * @return the children (not {@code null}, contains no {@code null}s) |
| 1254 */ | 1319 */ |
| 1255 List<XmlTagNode> get tagNodes => _tagNodes; | 1320 List<XmlTagNode> get tagNodes => _tagNodes; |
| 1321 /** |
| 1322 * Set the element associated with this HTML unit. |
| 1323 * @param element the element |
| 1324 */ |
| 1325 void set element(HtmlElementImpl element18) { |
| 1326 this._element = element18; |
| 1327 } |
| 1256 void visitChildren(XmlVisitor<Object> visitor) { | 1328 void visitChildren(XmlVisitor<Object> visitor) { |
| 1257 for (XmlTagNode node in _tagNodes) { | 1329 for (XmlTagNode node in _tagNodes) { |
| 1258 node.accept(visitor); | 1330 node.accept(visitor); |
| 1259 } | 1331 } |
| 1260 } | 1332 } |
| 1261 } | 1333 } |
| OLD | NEW |