OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
7 | 7 |
8 library engine.parser; | 8 library engine.parser; |
9 | 9 |
10 import "dart:math" as math; | 10 import "dart:math" as math; |
(...skipping 3412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3423 } | 3423 } |
3424 if (scalarValue < Character.MAX_VALUE) { | 3424 if (scalarValue < Character.MAX_VALUE) { |
3425 buffer.writeCharCode(scalarValue); | 3425 buffer.writeCharCode(scalarValue); |
3426 } else { | 3426 } else { |
3427 buffer.write(Character.toChars(scalarValue)); | 3427 buffer.write(Character.toChars(scalarValue)); |
3428 } | 3428 } |
3429 } | 3429 } |
3430 | 3430 |
3431 /** | 3431 /** |
3432 * Return the content of a string with the given literal representation. The | 3432 * Return the content of a string with the given literal representation. The |
3433 * [lexeme] is the literal representation of the string. The flag [first] is | 3433 * [lexeme] is the literal representation of the string. The flag [isFirst] is |
3434 * `true` if this is the first token in a string literal. The flag [last] is | 3434 * `true` if this is the first token in a string literal. The flag [isLast] is |
3435 * `true` if this is the last token in a string literal. | 3435 * `true` if this is the last token in a string literal. |
3436 */ | 3436 */ |
3437 String _computeStringValue(String lexeme, bool first, bool last) { | 3437 String _computeStringValue(String lexeme, bool isFirst, bool isLast) { |
3438 bool isRaw = false; | 3438 bool isRaw = false; |
3439 int start = 0; | 3439 int start = 0; |
3440 if (first) { | 3440 if (isFirst) { |
3441 if (StringUtilities.startsWith4(lexeme, 0, 0x72, 0x22, 0x22, 0x22) || | 3441 if (StringUtilities.startsWith4(lexeme, 0, 0x72, 0x22, 0x22, 0x22) || |
3442 StringUtilities.startsWith4(lexeme, 0, 0x72, 0x27, 0x27, 0x27)) { | 3442 StringUtilities.startsWith4(lexeme, 0, 0x72, 0x27, 0x27, 0x27)) { |
3443 isRaw = true; | 3443 isRaw = true; |
3444 start += 4; | 3444 start += 4; |
| 3445 if (isFirst) { |
| 3446 start = _trimInitialWhitespace(lexeme, start); |
| 3447 } |
3445 } else if (StringUtilities.startsWith2(lexeme, 0, 0x72, 0x22) || | 3448 } else if (StringUtilities.startsWith2(lexeme, 0, 0x72, 0x22) || |
3446 StringUtilities.startsWith2(lexeme, 0, 0x72, 0x27)) { | 3449 StringUtilities.startsWith2(lexeme, 0, 0x72, 0x27)) { |
3447 isRaw = true; | 3450 isRaw = true; |
3448 start += 2; | 3451 start += 2; |
3449 } else if (StringUtilities.startsWith3(lexeme, 0, 0x22, 0x22, 0x22) || | 3452 } else if (StringUtilities.startsWith3(lexeme, 0, 0x22, 0x22, 0x22) || |
3450 StringUtilities.startsWith3(lexeme, 0, 0x27, 0x27, 0x27)) { | 3453 StringUtilities.startsWith3(lexeme, 0, 0x27, 0x27, 0x27)) { |
3451 start += 3; | 3454 start += 3; |
| 3455 if (isFirst) { |
| 3456 start = _trimInitialWhitespace(lexeme, start); |
| 3457 } |
3452 } else if (StringUtilities.startsWithChar(lexeme, 0x22) || | 3458 } else if (StringUtilities.startsWithChar(lexeme, 0x22) || |
3453 StringUtilities.startsWithChar(lexeme, 0x27)) { | 3459 StringUtilities.startsWithChar(lexeme, 0x27)) { |
3454 start += 1; | 3460 start += 1; |
3455 } | 3461 } |
3456 } | 3462 } |
3457 int end = lexeme.length; | 3463 int end = lexeme.length; |
3458 if (last) { | 3464 if (isLast) { |
3459 if (StringUtilities.endsWith3(lexeme, 0x22, 0x22, 0x22) || | 3465 if (StringUtilities.endsWith3(lexeme, 0x22, 0x22, 0x22) || |
3460 StringUtilities.endsWith3(lexeme, 0x27, 0x27, 0x27)) { | 3466 StringUtilities.endsWith3(lexeme, 0x27, 0x27, 0x27)) { |
3461 end -= 3; | 3467 end -= 3; |
3462 } else if (StringUtilities.endsWithChar(lexeme, 0x22) || | 3468 } else if (StringUtilities.endsWithChar(lexeme, 0x22) || |
3463 StringUtilities.endsWithChar(lexeme, 0x27)) { | 3469 StringUtilities.endsWithChar(lexeme, 0x27)) { |
3464 end -= 1; | 3470 end -= 1; |
3465 } | 3471 } |
3466 } | 3472 } |
3467 if (end - start + 1 < 0) { | 3473 if (end - start + 1 < 0) { |
3468 AnalysisEngine.instance.logger.logError( | 3474 AnalysisEngine.instance.logger.logError( |
3469 "Internal error: computeStringValue($lexeme, $first, $last)"); | 3475 "Internal error: computeStringValue($lexeme, $isFirst, $isLast)"); |
3470 return ""; | 3476 return ""; |
3471 } | 3477 } |
3472 if (isRaw) { | 3478 if (isRaw) { |
3473 return lexeme.substring(start, end); | 3479 return lexeme.substring(start, end); |
3474 } | 3480 } |
3475 StringBuffer buffer = new StringBuffer(); | 3481 StringBuffer buffer = new StringBuffer(); |
3476 int index = start; | 3482 int index = start; |
3477 while (index < end) { | 3483 while (index < end) { |
3478 index = _translateCharacter(buffer, lexeme, index); | 3484 index = _translateCharacter(buffer, lexeme, index); |
3479 } | 3485 } |
(...skipping 4763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8243 } | 8249 } |
8244 return currentIndex + 4; | 8250 return currentIndex + 4; |
8245 } | 8251 } |
8246 } else { | 8252 } else { |
8247 buffer.writeCharCode(currentChar); | 8253 buffer.writeCharCode(currentChar); |
8248 } | 8254 } |
8249 return currentIndex + 1; | 8255 return currentIndex + 1; |
8250 } | 8256 } |
8251 | 8257 |
8252 /** | 8258 /** |
| 8259 * Given the [lexeme] for a multi-line string whose content begins at the |
| 8260 * given [start] index, return the index of the first character that is |
| 8261 * included in the value of the string. According to the specification: |
| 8262 * |
| 8263 * If the first line of a multiline string consists solely of the whitespace |
| 8264 * characters defined by the production WHITESPACE 20.1), possibly prefixed |
| 8265 * by \, then that line is ignored, including the new line at its end. |
| 8266 */ |
| 8267 int _trimInitialWhitespace(String lexeme, int start) { |
| 8268 int length = lexeme.length; |
| 8269 int index = start; |
| 8270 while (index < length) { |
| 8271 int currentChar = lexeme.codeUnitAt(index); |
| 8272 if (currentChar == 0x0D) { |
| 8273 if (index + 1 < length && lexeme.codeUnitAt(index + 1) == 0x0A) { |
| 8274 return index + 2; |
| 8275 } |
| 8276 return index + 1; |
| 8277 } else if (currentChar == 0x0A) { |
| 8278 return index + 1; |
| 8279 } else if (currentChar == 0x5C) { |
| 8280 if (index + 1 >= length) { |
| 8281 return start; |
| 8282 } |
| 8283 currentChar = lexeme.codeUnitAt(index + 1); |
| 8284 if (currentChar != 0x0D && |
| 8285 currentChar != 0x0A && |
| 8286 currentChar != 0x09 && |
| 8287 currentChar != 0x20) { |
| 8288 return start; |
| 8289 } |
| 8290 } else if (currentChar != 0x09 && currentChar != 0x20) { |
| 8291 return start; |
| 8292 } |
| 8293 index++; |
| 8294 } |
| 8295 return start; |
| 8296 } |
| 8297 |
| 8298 /** |
8253 * Decrements the error reporting lock level. If level is more than `0`, then | 8299 * Decrements the error reporting lock level. If level is more than `0`, then |
8254 * [reportError] wont report any error. | 8300 * [reportError] wont report any error. |
8255 */ | 8301 */ |
8256 void _unlockErrorListener() { | 8302 void _unlockErrorListener() { |
8257 if (_errorListenerLock == 0) { | 8303 if (_errorListenerLock == 0) { |
8258 throw new IllegalStateException( | 8304 throw new IllegalStateException( |
8259 "Attempt to unlock not locked error listener."); | 8305 "Attempt to unlock not locked error listener."); |
8260 } | 8306 } |
8261 _errorListenerLock--; | 8307 _errorListenerLock--; |
8262 } | 8308 } |
(...skipping 2274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10537 } | 10583 } |
10538 | 10584 |
10539 /** | 10585 /** |
10540 * Copy resolution data from the [fromNode] to the [toNode]. | 10586 * Copy resolution data from the [fromNode] to the [toNode]. |
10541 */ | 10587 */ |
10542 static void copyResolutionData(AstNode fromNode, AstNode toNode) { | 10588 static void copyResolutionData(AstNode fromNode, AstNode toNode) { |
10543 ResolutionCopier copier = new ResolutionCopier(); | 10589 ResolutionCopier copier = new ResolutionCopier(); |
10544 copier._isEqualNodes(fromNode, toNode); | 10590 copier._isEqualNodes(fromNode, toNode); |
10545 } | 10591 } |
10546 } | 10592 } |
OLD | NEW |