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 3423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 [last] 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 first, bool last) { |
3438 bool isRaw = false; | 3438 bool isRaw = false; |
3439 int start = 0; | 3439 int start = 0; |
3440 if (first) { | 3440 if (first) { |
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 = _skipInitialWhitespace(lexeme, start + 4); |
3445 } else if (StringUtilities.startsWith2(lexeme, 0, 0x72, 0x22) || | 3445 } else if (StringUtilities.startsWith2(lexeme, 0, 0x72, 0x22) || |
3446 StringUtilities.startsWith2(lexeme, 0, 0x72, 0x27)) { | 3446 StringUtilities.startsWith2(lexeme, 0, 0x72, 0x27)) { |
3447 isRaw = true; | 3447 isRaw = true; |
3448 start += 2; | 3448 start += 2; |
3449 } else if (StringUtilities.startsWith3(lexeme, 0, 0x22, 0x22, 0x22) || | 3449 } else if (StringUtilities.startsWith3(lexeme, 0, 0x22, 0x22, 0x22) || |
3450 StringUtilities.startsWith3(lexeme, 0, 0x27, 0x27, 0x27)) { | 3450 StringUtilities.startsWith3(lexeme, 0, 0x27, 0x27, 0x27)) { |
3451 start += 3; | 3451 start = _skipInitialWhitespace(lexeme, start + 3); |
3452 } else if (StringUtilities.startsWithChar(lexeme, 0x22) || | 3452 } else if (StringUtilities.startsWithChar(lexeme, 0x22) || |
3453 StringUtilities.startsWithChar(lexeme, 0x27)) { | 3453 StringUtilities.startsWithChar(lexeme, 0x27)) { |
3454 start += 1; | 3454 start += 1; |
3455 } | 3455 } |
3456 } | 3456 } |
3457 int end = lexeme.length; | 3457 int end = lexeme.length; |
3458 if (last) { | 3458 if (last) { |
3459 if (StringUtilities.endsWith3(lexeme, 0x22, 0x22, 0x22) || | 3459 if (StringUtilities.endsWith3(lexeme, 0x22, 0x22, 0x22) || |
3460 StringUtilities.endsWith3(lexeme, 0x27, 0x27, 0x27)) { | 3460 StringUtilities.endsWith3(lexeme, 0x27, 0x27, 0x27)) { |
3461 end -= 3; | 3461 end -= 3; |
(...skipping 12 matching lines...) Expand all Loading... | |
3474 } | 3474 } |
3475 StringBuffer buffer = new StringBuffer(); | 3475 StringBuffer buffer = new StringBuffer(); |
3476 int index = start; | 3476 int index = start; |
3477 while (index < end) { | 3477 while (index < end) { |
3478 index = _translateCharacter(buffer, lexeme, index); | 3478 index = _translateCharacter(buffer, lexeme, index); |
3479 } | 3479 } |
3480 return buffer.toString(); | 3480 return buffer.toString(); |
3481 } | 3481 } |
3482 | 3482 |
3483 /** | 3483 /** |
3484 * Given the [lexeme] for a multi-line string whose content begins at the | |
3485 * given [start] index, return the index of the first character that is | |
3486 * included in the value of the string. According to the specification: | |
3487 * | |
3488 * If the first line of a multiline string consists solely of the whitespace | |
3489 * characters defined by the production WHITESPACE 20.1), possibly prefixed | |
3490 * by \, then that line is ignored, including the new line at its end. | |
3491 */ | |
3492 int _skipInitialWhitespace(String lexeme, int start) { | |
3493 int length = lexeme.length; | |
3494 int index = start; | |
3495 while (index < length) { | |
3496 int currentChar = lexeme.codeUnitAt(index); | |
3497 if (currentChar == 0x0D) { | |
3498 if (index + 1 < length && lexeme.codeUnitAt(index) == 0x0A) { | |
3499 return index + 2; | |
3500 } | |
3501 return index + 1; | |
3502 } else if (currentChar == 0x0A) { | |
3503 return index + 1; | |
3504 } else if (currentChar != 0x09 && currentChar != 0x20 && currentChar != 0x 5C) { | |
Paul Berry
2015/03/26 17:59:13
As discussed in person, this doesn't match the VM
| |
3505 return start; | |
3506 } | |
3507 index++; | |
3508 } | |
3509 return index; | |
3510 } | |
3511 | |
3512 /** | |
3484 * Convert the given [method] declaration into the nearest valid top-level | 3513 * Convert the given [method] declaration into the nearest valid top-level |
3485 * function declaration (that is, the function declaration that most closely | 3514 * function declaration (that is, the function declaration that most closely |
3486 * captures the components of the given method declaration). | 3515 * captures the components of the given method declaration). |
3487 */ | 3516 */ |
3488 FunctionDeclaration _convertToFunctionDeclaration(MethodDeclaration method) => | 3517 FunctionDeclaration _convertToFunctionDeclaration(MethodDeclaration method) => |
3489 new FunctionDeclaration(method.documentationComment, method.metadata, | 3518 new FunctionDeclaration(method.documentationComment, method.metadata, |
3490 method.externalKeyword, method.returnType, method.propertyKeyword, | 3519 method.externalKeyword, method.returnType, method.propertyKeyword, |
3491 method.name, new FunctionExpression(method.parameters, method.body)); | 3520 method.name, new FunctionExpression(method.parameters, method.body)); |
3492 | 3521 |
3493 /** | 3522 /** |
(...skipping 7043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10537 } | 10566 } |
10538 | 10567 |
10539 /** | 10568 /** |
10540 * Copy resolution data from the [fromNode] to the [toNode]. | 10569 * Copy resolution data from the [fromNode] to the [toNode]. |
10541 */ | 10570 */ |
10542 static void copyResolutionData(AstNode fromNode, AstNode toNode) { | 10571 static void copyResolutionData(AstNode fromNode, AstNode toNode) { |
10543 ResolutionCopier copier = new ResolutionCopier(); | 10572 ResolutionCopier copier = new ResolutionCopier(); |
10544 copier._isEqualNodes(fromNode, toNode); | 10573 copier._isEqualNodes(fromNode, toNode); |
10545 } | 10574 } |
10546 } | 10575 } |
OLD | NEW |