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

Side by Side Diff: pkg/csslib/lib/src/token.dart

Issue 814113004: Pull args, intl, logging, shelf, and source_maps out of the SDK. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Also csslib. Created 6 years 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
« no previous file with comments | « pkg/csslib/lib/src/property.dart ('k') | pkg/csslib/lib/src/tokenizer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 part of csslib.parser;
6
7 /**
8 * A single token in the Dart language.
9 */
10 class Token {
11 /** A member of [TokenKind] specifying what kind of token this is. */
12 final int kind;
13
14 /** The location where this token was parsed from. */
15 final FileSpan span;
16
17 /** The start offset of this token. */
18 int get start => span.start.offset;
19
20 /** The end offset of this token. */
21 int get end => span.end.offset;
22
23 /** Returns the source text corresponding to this [Token]. */
24 String get text => span.text;
25
26 Token(this.kind, this.span);
27
28 /** Returns a pretty representation of this token for error messages. **/
29 String toString() {
30 var kindText = TokenKind.kindToString(kind);
31 var actualText = text.trim();
32 if (kindText != actualText) {
33 if (actualText.length > 10) {
34 actualText = '${actualText.substring(0, 8)}...';
35 }
36 return '$kindText($actualText)';
37 } else {
38 return kindText;
39 }
40 }
41 }
42
43 /** A token containing a parsed literal value. */
44 class LiteralToken extends Token {
45 var value;
46 LiteralToken(int kind, FileSpan span, this.value) : super(kind, span);
47 }
48
49 /** A token containing error information. */
50 class ErrorToken extends Token {
51 String message;
52 ErrorToken(int kind, FileSpan span, this.message) : super(kind, span);
53 }
54
55 /**
56 * CSS ident-token.
57 *
58 * See <http://dev.w3.org/csswg/css-syntax/#typedef-ident-token> and
59 * <http://dev.w3.org/csswg/css-syntax/#ident-token-diagram>.
60 */
61 class IdentifierToken extends Token {
62 final String text;
63
64 IdentifierToken(this.text, int kind, FileSpan span)
65 : super(kind, span);
66 }
OLDNEW
« no previous file with comments | « pkg/csslib/lib/src/property.dart ('k') | pkg/csslib/lib/src/tokenizer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698