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

Unified Diff: pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart

Issue 2567133002: Add support for the new function-type syntax. (Closed)
Patch Set: Fixes after rebase. Created 3 years, 10 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: pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
diff --git a/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart b/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
index f4de827c7fa5399a8d90e8207653e0b2503b8d77..e1dd5f4d2eab75789939f0072a15dbe7e28f65c1 100644
--- a/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
+++ b/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
@@ -241,7 +241,7 @@ abstract class AbstractScanner implements Scanner {
if (($A <= next && next <= $Z) ||
identical(next, $_) ||
identical(next, $$)) {
- return tokenizeIdentifier(next, scanOffset, true);
+ return tokenizeKeywordOrIdentifier(next, true);
}
if (identical(next, $LT)) {
@@ -808,6 +808,16 @@ abstract class AbstractScanner implements Scanner {
int tokenizeKeywordOrIdentifier(int next, bool allowDollar) {
KeywordState state = KeywordState.KEYWORD_STATE;
int start = scanOffset;
+ // We allow a leading capital character.
+ if ($A <= next && next <= $Z) {
+ state = state.nextCapital(next);
+ next = advance();
+ } else if ($a <= next && next <= $z){
+ // Do the first next call outside the loop to avoid an additional test
+ // and to make the loop monomorphic.
+ state = state.next(next);
+ next = advance();
+ }
while (state != null && $a <= next && next <= $z) {
state = state.next(next);
next = advance();
@@ -945,12 +955,11 @@ abstract class AbstractScanner implements Scanner {
int tokenizeInterpolatedIdentifier(int next) {
appendPrecedenceToken(STRING_INTERPOLATION_IDENTIFIER_INFO);
- if ($a <= next && next <= $z) {
+ if ($a <= next && next <= $z ||
+ $A <= next && next <= $Z ||
+ identical(next, $_)) {
beginToken(); // The identifier starts here.
next = tokenizeKeywordOrIdentifier(next, false);
- } else if (($A <= next && next <= $Z) || identical(next, $_)) {
- beginToken(); // The identifier starts here.
- next = tokenizeIdentifier(next, scanOffset, false);
} else {
unterminated(r'$', shouldAdvance: false);
}

Powered by Google App Engine
This is Rietveld 408576698