Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library fasta.scanner.array_based_scanner; | 5 library fasta.scanner.array_based_scanner; |
| 6 | 6 |
| 7 import 'error_token.dart' show ErrorToken; | 7 import 'error_token.dart' show ErrorToken; |
| 8 | 8 |
| 9 import 'keyword.dart' show Keyword; | 9 import 'keyword.dart' show Keyword; |
| 10 | 10 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 * Notifies on [$LF] characters in multi-line comments or strings. | 118 * Notifies on [$LF] characters in multi-line comments or strings. |
| 119 * | 119 * |
| 120 * This method is used by the scanners to track line breaks and create the | 120 * This method is used by the scanners to track line breaks and create the |
| 121 * [lineStarts] map. | 121 * [lineStarts] map. |
| 122 */ | 122 */ |
| 123 void lineFeedInMultiline() { | 123 void lineFeedInMultiline() { |
| 124 lineStarts.add(stringOffset + 1); | 124 lineStarts.add(stringOffset + 1); |
| 125 } | 125 } |
| 126 | 126 |
| 127 /** | 127 /** |
| 128 * Appends a token that begins a new group, represented by [value]. | 128 * Appends a token that begins a new group, represented by [lexeme]. |
|
ahe
2017/03/10 07:26:11
I think this should be [info] instead.
danrubel
2017/03/11 22:10:38
Good point. Fixed.
| |
| 129 * Group begin tokens are '{', '(', '[' and '${'. | 129 * Group begin tokens are '{', '(', '[' and '${'. |
| 130 */ | 130 */ |
| 131 void appendBeginGroup(PrecedenceInfo info) { | 131 void appendBeginGroup(PrecedenceInfo info) { |
| 132 Token token = new BeginGroupToken(info, tokenStart); | 132 Token token = new BeginGroupToken(info, tokenStart); |
| 133 appendToken(token); | 133 appendToken(token); |
| 134 | 134 |
| 135 // { ( [ ${ cannot appear inside a type parameters / arguments. | 135 // { ( [ ${ cannot appear inside a type parameters / arguments. |
| 136 if (!identical(info.kind, LT_TOKEN)) discardOpenLt(); | 136 if (!identical(info.kind, LT_TOKEN)) discardOpenLt(); |
| 137 groupingStack = groupingStack.prepend(token); | 137 groupingStack = groupingStack.prepend(token); |
| 138 } | 138 } |
| 139 | 139 |
| 140 /** | 140 /** |
| 141 * Appends a token that begins an end group, represented by [value]. | 141 * Appends a token that begins an end group, represented by [lexeme]. |
|
ahe
2017/03/10 07:26:11
Ditto.
danrubel
2017/03/11 22:10:38
Done.
| |
| 142 * It handles the group end tokens '}', ')' and ']'. The tokens '>' and | 142 * It handles the group end tokens '}', ')' and ']'. The tokens '>' and |
| 143 * '>>' are handled separately bo [appendGt] and [appendGtGt]. | 143 * '>>' are handled separately bo [appendGt] and [appendGtGt]. |
| 144 */ | 144 */ |
| 145 int appendEndGroup(PrecedenceInfo info, int openKind) { | 145 int appendEndGroup(PrecedenceInfo info, int openKind) { |
| 146 assert(!identical(openKind, LT_TOKEN)); // openKind is < for > and >> | 146 assert(!identical(openKind, LT_TOKEN)); // openKind is < for > and >> |
| 147 discardBeginGroupUntil(openKind); | 147 discardBeginGroupUntil(openKind); |
| 148 appendPrecedenceToken(info); | 148 appendPrecedenceToken(info); |
| 149 Token close = tail; | 149 Token close = tail; |
| 150 if (groupingStack.isEmpty) { | 150 if (groupingStack.isEmpty) { |
| 151 return advance(); | 151 return advance(); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 265 * something which cannot possibly be part of a type parameter/argument | 265 * something which cannot possibly be part of a type parameter/argument |
| 266 * list, like the '=' in the above example. | 266 * list, like the '=' in the above example. |
| 267 */ | 267 */ |
| 268 void discardOpenLt() { | 268 void discardOpenLt() { |
| 269 while (!groupingStack.isEmpty && | 269 while (!groupingStack.isEmpty && |
| 270 identical(groupingStack.head.kind, LT_TOKEN)) { | 270 identical(groupingStack.head.kind, LT_TOKEN)) { |
| 271 groupingStack = groupingStack.tail; | 271 groupingStack = groupingStack.tail; |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 } | 274 } |
| OLD | NEW |