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

Unified Diff: sdk/lib/_internal/compiler/implementation/scanner/parser.dart

Issue 21511003: Support symbol literals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/scanner/parser.dart
diff --git a/sdk/lib/_internal/compiler/implementation/scanner/parser.dart b/sdk/lib/_internal/compiler/implementation/scanner/parser.dart
index 064136f9ec6ed8bd7e69421c27a921dc02c757c6..dcfbc59a8c783ac8722cff723fe17a80aae4707a 100644
--- a/sdk/lib/_internal/compiler/implementation/scanner/parser.dart
+++ b/sdk/lib/_internal/compiler/implementation/scanner/parser.dart
@@ -1672,6 +1672,8 @@ class Parser {
return parseLiteralDouble(token);
} else if (identical(kind, STRING_TOKEN)) {
return parseLiteralString(token);
+ } else if (identical(kind, HASH_TOKEN)) {
+ return parseLiteralSymbol(token);
} else if (identical(kind, KEYWORD_TOKEN)) {
final value = token.stringValue;
if ((identical(value, 'true')) || (identical(value, 'false'))) {
@@ -1892,6 +1894,26 @@ class Parser {
return token;
}
+ Token parseLiteralSymbol(Token token) {
+ Token hashToken = token;
+ listener.beginLiteralSymbol(hashToken);
+ token = token.next;
+ if (isUserDefinableOperator(token.stringValue)) {
+ listener.handleOperator(token);
+ listener.endLiteralSymbol(hashToken, 1);
+ return token.next;
+ } else {
+ int count = 1;
+ token = parseIdentifier(token);
+ while (identical(token.stringValue, '.')) {
+ count++;
+ token = parseIdentifier(token.next);
+ }
+ listener.endLiteralSymbol(hashToken, count);
+ return token;
+ }
+ }
+
/**
* Only called when [:token.kind === STRING_TOKEN:].
*/

Powered by Google App Engine
This is Rietveld 408576698