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

Side by Side Diff: pkg/third_party/html5lib/lib/src/token.dart

Issue 22375011: move html5lib code into dart svn repo (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: change location of html5lib to pkg/third_party/html5lib Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 /** This library contains token types used by the html5 tokenizer. */
2 library token;
3
4 import 'dart:collection';
5 import 'package:source_maps/span.dart' show FileSpan;
6
7 /** An html5 token. */
8 abstract class Token {
9 FileSpan span;
10
11 int get kind;
12 }
13
14 abstract class TagToken extends Token {
15 String name;
16
17 bool selfClosing;
18
19 TagToken(this.name, this.selfClosing);
20 }
21
22 class StartTagToken extends TagToken {
23 /**
24 * The tag's attributes. A map from the name to the value, where the name
25 * can be a [String] or [AttributeName].
26 */
27 LinkedHashMap<dynamic, String> data;
28
29 /** The attribute spans if requested. Otherwise null. */
30 List<TagAttribute> attributeSpans;
31
32 bool selfClosingAcknowledged;
33
34 /** The namespace. This is filled in later during tree building. */
35 String namespace;
36
37 StartTagToken(String name, {this.data, bool selfClosing: false,
38 this.selfClosingAcknowledged: false, this.namespace})
39 : super(name, selfClosing);
40
41 int get kind => TokenKind.startTag;
42 }
43
44 class EndTagToken extends TagToken {
45 EndTagToken(String name, {bool selfClosing: false})
46 : super(name, selfClosing);
47
48 int get kind => TokenKind.endTag;
49 }
50
51 abstract class StringToken extends Token {
52 String data;
53 StringToken(this.data);
54 }
55
56 class ParseErrorToken extends StringToken {
57 /** Extra information that goes along with the error message. */
58 Map messageParams;
59
60 ParseErrorToken(String data, {this.messageParams}) : super(data);
61
62 int get kind => TokenKind.parseError;
63 }
64
65 class CharactersToken extends StringToken {
66 CharactersToken([String data]) : super(data);
67
68 int get kind => TokenKind.characters;
69 }
70
71 class SpaceCharactersToken extends StringToken {
72 SpaceCharactersToken([String data]) : super(data);
73
74 int get kind => TokenKind.spaceCharacters;
75 }
76
77 class CommentToken extends StringToken {
78 CommentToken([String data]) : super(data);
79
80 int get kind => TokenKind.comment;
81 }
82
83 class DoctypeToken extends Token {
84 String publicId;
85 String systemId;
86 String name = "";
87 bool correct;
88
89 DoctypeToken({this.publicId, this.systemId, this.correct: false});
90
91 int get kind => TokenKind.doctype;
92 }
93
94 /**
95 * These are used by the tokenizer to build up the attribute map.
96 * They're also used by [StartTagToken.attributeSpans] if attribute spans are
97 * requested.
98 */
99 class TagAttribute {
100 String name;
101 String value;
102
103 // The spans of the attribute. This is not used unless we are computing an
104 // attribute span on demand.
105 int start;
106 int end;
107 int startValue;
108 int endValue;
109
110 TagAttribute(this.name, [this.value = '']);
111 }
112
113
114 class TokenKind {
115 static const int spaceCharacters = 0;
116 static const int characters = 1;
117 static const int startTag = 2;
118 static const int endTag = 3;
119 static const int comment = 4;
120 static const int doctype = 5;
121 static const int parseError = 6;
122 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698