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

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

Issue 10836351: Parse metadata, but ignore it. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 8 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 side-by-side diff with in-line comments
Download patch
Index: dart/lib/compiler/implementation/scanner/parser.dart
diff --git a/dart/lib/compiler/implementation/scanner/parser.dart b/dart/lib/compiler/implementation/scanner/parser.dart
index 9e5a9454b32a7723c3c8b70991fe73c24595996e..112ca051eb74299fe83552b52880cc27b8c183f6 100644
--- a/dart/lib/compiler/implementation/scanner/parser.dart
+++ b/dart/lib/compiler/implementation/scanner/parser.dart
@@ -10,12 +10,26 @@
* file scanner.dart.
*
* Subclasses of the class [Listener] are used to listen to events.
+ *
+ * Most methods of this class belong in one of two major categories:
+ * parse metods and peek methods. Parse methods all have the prefix
+ * parse, and peek methods all have the prefix peek.
+ *
+ * Parse methods generate events (by calling methods on [listener])
+ * and return the next token to parse. Peek methods do not generate
+ * events (except for errors) and may return null.
+ *
+ * Parse methods are generally named parseGrammarProductionSuffix. The
+ * suffix can be one of "opt", or "star". "opt" means zero or one
+ * matches, "star" means zero or more matches. For example,
ngeoffray 2012/08/21 10:51:21 zero or one match
ahe 2012/08/21 10:55:37 I don't think that is correct. "star" means i rep
+ * [parseMetadataStar] corresponds to this grammar snippet: [:
+ * metadata* :], and [parseTypeOpt] corresponds to: [: type? :].
*/
class Parser {
final Listener listener;
bool mayParseFunctionExpressions = true;
- Parser(Listener this.listener);
+ Parser(this.listener);
void parseUnit(Token token) {
while (token.kind !== EOF_TOKEN) {
@@ -24,6 +38,7 @@ class Parser {
}
Token parseTopLevelDeclaration(Token token) {
+ token = parseMetadataStar(token);
final String value = token.stringValue;
if (value === 'interface') {
return parseInterface(token);
@@ -38,6 +53,24 @@ class Parser {
}
}
+ Token parseMetadataStar(Token token) {
+ while (optional('@', token)) {
+ token = parseMetadata(token);
+ }
+ return token;
+ }
+
+ Token parseMetadata(Token token) {
+ listener.beginMetadata(token);
+ Token atToken = token;
+ assert(optional('@', token));
+ token = parseIdentifier(token.next);
+ token = parseQualifiedRestOpt(token);
+ token = parseArgumentsOpt(token);
+ listener.endMetadata(atToken, token);
+ return token;
+ }
+
Token parseInterface(Token token) {
Token interfaceKeyword = token;
listener.beginInterface(token);
@@ -586,6 +619,7 @@ class Parser {
}
Token parseMember(Token token) {
+ token = parseMetadataStar(token);
String value = token.stringValue;
if (value === 'factory' ||
(value === 'external' && optional('factory', token.next))) {
« no previous file with comments | « dart/lib/compiler/implementation/scanner/listener.dart ('k') | dart/lib/compiler/implementation/scanner/partial_parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698