| 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 'java_core.dart'; | 10 import 'java_core.dart'; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 /** | 60 /** |
| 61 * Initialize a newly created holder with the given data. | 61 * Initialize a newly created holder with the given data. |
| 62 * | 62 * |
| 63 * @param keyword the 'final', 'const' or 'var' keyword | 63 * @param keyword the 'final', 'const' or 'var' keyword |
| 64 * @param type the type | 64 * @param type the type |
| 65 */ | 65 */ |
| 66 FinalConstVarOrType(this.keyword, this.type); | 66 FinalConstVarOrType(this.keyword, this.type); |
| 67 } | 67 } |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * Instances of the class `Modifiers` implement a simple data-holder for a metho
d that needs | |
| 71 * to return multiple values. | |
| 72 */ | |
| 73 class Modifiers { | |
| 74 /** | |
| 75 * The token representing the keyword 'abstract', or `null` if the keyword was
not found. | |
| 76 */ | |
| 77 Token abstractKeyword; | |
| 78 | |
| 79 /** | |
| 80 * The token representing the keyword 'const', or `null` if the keyword was no
t found. | |
| 81 */ | |
| 82 Token constKeyword; | |
| 83 | |
| 84 /** | |
| 85 * The token representing the keyword 'external', or `null` if the keyword was
not found. | |
| 86 */ | |
| 87 Token externalKeyword; | |
| 88 | |
| 89 /** | |
| 90 * The token representing the keyword 'factory', or `null` if the keyword was
not found. | |
| 91 */ | |
| 92 Token factoryKeyword; | |
| 93 | |
| 94 /** | |
| 95 * The token representing the keyword 'final', or `null` if the keyword was no
t found. | |
| 96 */ | |
| 97 Token finalKeyword; | |
| 98 | |
| 99 /** | |
| 100 * The token representing the keyword 'static', or `null` if the keyword was n
ot found. | |
| 101 */ | |
| 102 Token staticKeyword; | |
| 103 | |
| 104 /** | |
| 105 * The token representing the keyword 'var', or `null` if the keyword was not
found. | |
| 106 */ | |
| 107 Token varKeyword; | |
| 108 | |
| 109 @override | |
| 110 String toString() { | |
| 111 JavaStringBuilder builder = new JavaStringBuilder(); | |
| 112 bool needsSpace = _appendKeyword(builder, false, abstractKeyword); | |
| 113 needsSpace = _appendKeyword(builder, needsSpace, constKeyword); | |
| 114 needsSpace = _appendKeyword(builder, needsSpace, externalKeyword); | |
| 115 needsSpace = _appendKeyword(builder, needsSpace, factoryKeyword); | |
| 116 needsSpace = _appendKeyword(builder, needsSpace, finalKeyword); | |
| 117 needsSpace = _appendKeyword(builder, needsSpace, staticKeyword); | |
| 118 _appendKeyword(builder, needsSpace, varKeyword); | |
| 119 return builder.toString(); | |
| 120 } | |
| 121 | |
| 122 /** | |
| 123 * If the given keyword is not `null`, append it to the given builder, prefixi
ng it with a | |
| 124 * space if needed. | |
| 125 * | |
| 126 * @param builder the builder to which the keyword will be appended | |
| 127 * @param needsSpace `true` if the keyword needs to be prefixed with a space | |
| 128 * @param keyword the keyword to be appended | |
| 129 * @return `true` if subsequent keywords need to be prefixed with a space | |
| 130 */ | |
| 131 bool _appendKeyword(JavaStringBuilder builder, bool needsSpace, Token keyword)
{ | |
| 132 if (keyword != null) { | |
| 133 if (needsSpace) { | |
| 134 builder.appendChar(0x20); | |
| 135 } | |
| 136 builder.append(keyword.lexeme); | |
| 137 return true; | |
| 138 } | |
| 139 return needsSpace; | |
| 140 } | |
| 141 } | |
| 142 | |
| 143 /** | |
| 144 * Instances of the class `IncrementalParseDispatcher` implement a dispatcher th
at will invoke | 70 * Instances of the class `IncrementalParseDispatcher` implement a dispatcher th
at will invoke |
| 145 * the right parse method when re-parsing a specified child of the visited node.
All of the methods | 71 * the right parse method when re-parsing a specified child of the visited node.
All of the methods |
| 146 * in this class assume that the parser is positioned to parse the replacement f
or the node. All of | 72 * in this class assume that the parser is positioned to parse the replacement f
or the node. All of |
| 147 * the methods will throw an [IncrementalParseException] if the node could not b
e parsed for | 73 * the methods will throw an [IncrementalParseException] if the node could not b
e parsed for |
| 148 * some reason. | 74 * some reason. |
| 149 */ | 75 */ |
| 150 class IncrementalParseDispatcher implements AstVisitor<AstNode> { | 76 class IncrementalParseDispatcher implements AstVisitor<AstNode> { |
| 151 /** | 77 /** |
| 152 * The parser used to parse the replacement for the node. | 78 * The parser used to parse the replacement for the node. |
| 153 */ | 79 */ |
| (...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1413 | 1339 |
| 1414 /** | 1340 /** |
| 1415 * Initialize a newly created exception to have no message and to have the giv
en cause. | 1341 * Initialize a newly created exception to have no message and to have the giv
en cause. |
| 1416 * | 1342 * |
| 1417 * @param cause the exception that caused this exception | 1343 * @param cause the exception that caused this exception |
| 1418 */ | 1344 */ |
| 1419 InsufficientContextException.con2(Exception cause) : super.con2(cause); | 1345 InsufficientContextException.con2(Exception cause) : super.con2(cause); |
| 1420 } | 1346 } |
| 1421 | 1347 |
| 1422 /** | 1348 /** |
| 1349 * Instances of the class `Modifiers` implement a simple data-holder for a metho
d that needs |
| 1350 * to return multiple values. |
| 1351 */ |
| 1352 class Modifiers { |
| 1353 /** |
| 1354 * The token representing the keyword 'abstract', or `null` if the keyword was
not found. |
| 1355 */ |
| 1356 Token abstractKeyword; |
| 1357 |
| 1358 /** |
| 1359 * The token representing the keyword 'const', or `null` if the keyword was no
t found. |
| 1360 */ |
| 1361 Token constKeyword; |
| 1362 |
| 1363 /** |
| 1364 * The token representing the keyword 'external', or `null` if the keyword was
not found. |
| 1365 */ |
| 1366 Token externalKeyword; |
| 1367 |
| 1368 /** |
| 1369 * The token representing the keyword 'factory', or `null` if the keyword was
not found. |
| 1370 */ |
| 1371 Token factoryKeyword; |
| 1372 |
| 1373 /** |
| 1374 * The token representing the keyword 'final', or `null` if the keyword was no
t found. |
| 1375 */ |
| 1376 Token finalKeyword; |
| 1377 |
| 1378 /** |
| 1379 * The token representing the keyword 'static', or `null` if the keyword was n
ot found. |
| 1380 */ |
| 1381 Token staticKeyword; |
| 1382 |
| 1383 /** |
| 1384 * The token representing the keyword 'var', or `null` if the keyword was not
found. |
| 1385 */ |
| 1386 Token varKeyword; |
| 1387 |
| 1388 @override |
| 1389 String toString() { |
| 1390 JavaStringBuilder builder = new JavaStringBuilder(); |
| 1391 bool needsSpace = _appendKeyword(builder, false, abstractKeyword); |
| 1392 needsSpace = _appendKeyword(builder, needsSpace, constKeyword); |
| 1393 needsSpace = _appendKeyword(builder, needsSpace, externalKeyword); |
| 1394 needsSpace = _appendKeyword(builder, needsSpace, factoryKeyword); |
| 1395 needsSpace = _appendKeyword(builder, needsSpace, finalKeyword); |
| 1396 needsSpace = _appendKeyword(builder, needsSpace, staticKeyword); |
| 1397 _appendKeyword(builder, needsSpace, varKeyword); |
| 1398 return builder.toString(); |
| 1399 } |
| 1400 |
| 1401 /** |
| 1402 * If the given keyword is not `null`, append it to the given builder, prefixi
ng it with a |
| 1403 * space if needed. |
| 1404 * |
| 1405 * @param builder the builder to which the keyword will be appended |
| 1406 * @param needsSpace `true` if the keyword needs to be prefixed with a space |
| 1407 * @param keyword the keyword to be appended |
| 1408 * @return `true` if subsequent keywords need to be prefixed with a space |
| 1409 */ |
| 1410 bool _appendKeyword(JavaStringBuilder builder, bool needsSpace, Token keyword)
{ |
| 1411 if (keyword != null) { |
| 1412 if (needsSpace) { |
| 1413 builder.appendChar(0x20); |
| 1414 } |
| 1415 builder.append(keyword.lexeme); |
| 1416 return true; |
| 1417 } |
| 1418 return needsSpace; |
| 1419 } |
| 1420 } |
| 1421 |
| 1422 /** |
| 1423 * Instances of the class `Parser` are used to parse tokens into an AST structur
e. | 1423 * Instances of the class `Parser` are used to parse tokens into an AST structur
e. |
| 1424 */ | 1424 */ |
| 1425 class Parser { | 1425 class Parser { |
| 1426 /** | 1426 /** |
| 1427 * The source being parsed. | 1427 * The source being parsed. |
| 1428 */ | 1428 */ |
| 1429 final Source _source; | 1429 final Source _source; |
| 1430 | 1430 |
| 1431 /** | 1431 /** |
| 1432 * The error listener that will be informed of any errors that are found durin
g the parse. | 1432 * The error listener that will be informed of any errors that are found durin
g the parse. |
| (...skipping 5986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7419 if (modifiers.finalKeyword != null) { | 7419 if (modifiers.finalKeyword != null) { |
| 7420 _reportErrorForToken(ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword
, []); | 7420 _reportErrorForToken(ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword
, []); |
| 7421 } | 7421 } |
| 7422 if (modifiers.varKeyword != null) { | 7422 if (modifiers.varKeyword != null) { |
| 7423 _reportErrorForToken(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword, []
); | 7423 _reportErrorForToken(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword, []
); |
| 7424 } | 7424 } |
| 7425 } | 7425 } |
| 7426 } | 7426 } |
| 7427 | 7427 |
| 7428 /** | 7428 /** |
| 7429 * Instances of the class `SyntheticKeywordToken` implement a synthetic keyword
token. | |
| 7430 */ | |
| 7431 class Parser_SyntheticKeywordToken extends KeywordToken { | |
| 7432 /** | |
| 7433 * Initialize a newly created token to represent the given keyword. | |
| 7434 * | |
| 7435 * @param keyword the keyword being represented by this token | |
| 7436 * @param offset the offset from the beginning of the file to the first charac
ter in the token | |
| 7437 */ | |
| 7438 Parser_SyntheticKeywordToken(Keyword keyword, int offset) : super(keyword, off
set); | |
| 7439 | |
| 7440 @override | |
| 7441 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset); | |
| 7442 | |
| 7443 @override | |
| 7444 int get length => 0; | |
| 7445 } | |
| 7446 | |
| 7447 /** | |
| 7448 * The enumeration `ParserErrorCode` defines the error codes used for errors det
ected by the | 7429 * The enumeration `ParserErrorCode` defines the error codes used for errors det
ected by the |
| 7449 * parser. The convention for this class is for the name of the error code to in
dicate the problem | 7430 * parser. The convention for this class is for the name of the error code to in
dicate the problem |
| 7450 * that caused the error to be generated and for the error message to explain wh
at is wrong and, | 7431 * that caused the error to be generated and for the error message to explain wh
at is wrong and, |
| 7451 * when appropriate, how the problem can be corrected. | 7432 * when appropriate, how the problem can be corrected. |
| 7452 */ | 7433 */ |
| 7453 class ParserErrorCode extends Enum<ParserErrorCode> implements ErrorCode { | 7434 class ParserErrorCode extends Enum<ParserErrorCode> implements ErrorCode { |
| 7454 static const ParserErrorCode ABSTRACT_CLASS_MEMBER = const ParserErrorCode.con
3('ABSTRACT_CLASS_MEMBER', 0, "Members of classes cannot be declared to be 'abst
ract'"); | 7435 static const ParserErrorCode ABSTRACT_CLASS_MEMBER = const ParserErrorCode.con
3('ABSTRACT_CLASS_MEMBER', 0, "Members of classes cannot be declared to be 'abst
ract'"); |
| 7455 | 7436 |
| 7456 static const ParserErrorCode ABSTRACT_STATIC_METHOD = const ParserErrorCode.co
n3('ABSTRACT_STATIC_METHOD', 1, "Static methods cannot be declared to be 'abstra
ct'"); | 7437 static const ParserErrorCode ABSTRACT_STATIC_METHOD = const ParserErrorCode.co
n3('ABSTRACT_STATIC_METHOD', 1, "Static methods cannot be declared to be 'abstra
ct'"); |
| 7457 | 7438 |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7890 * | 7871 * |
| 7891 * @param message the message template used to create the message to be displa
yed for the error | 7872 * @param message the message template used to create the message to be displa
yed for the error |
| 7892 */ | 7873 */ |
| 7893 const ParserErrorCode.con3(String name, int ordinal, String message) : this.co
n2(name, ordinal, ErrorSeverity.ERROR, message, null); | 7874 const ParserErrorCode.con3(String name, int ordinal, String message) : this.co
n2(name, ordinal, ErrorSeverity.ERROR, message, null); |
| 7894 | 7875 |
| 7895 @override | 7876 @override |
| 7896 ErrorType get type => ErrorType.SYNTACTIC_ERROR; | 7877 ErrorType get type => ErrorType.SYNTACTIC_ERROR; |
| 7897 } | 7878 } |
| 7898 | 7879 |
| 7899 /** | 7880 /** |
| 7881 * Instances of the class `SyntheticKeywordToken` implement a synthetic keyword
token. |
| 7882 */ |
| 7883 class Parser_SyntheticKeywordToken extends KeywordToken { |
| 7884 /** |
| 7885 * Initialize a newly created token to represent the given keyword. |
| 7886 * |
| 7887 * @param keyword the keyword being represented by this token |
| 7888 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 7889 */ |
| 7890 Parser_SyntheticKeywordToken(Keyword keyword, int offset) : super(keyword, off
set); |
| 7891 |
| 7892 @override |
| 7893 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset); |
| 7894 |
| 7895 @override |
| 7896 int get length => 0; |
| 7897 } |
| 7898 |
| 7899 /** |
| 7900 * Instances of the class `ResolutionCopier` copies resolution information from
one AST | 7900 * Instances of the class `ResolutionCopier` copies resolution information from
one AST |
| 7901 * structure to another as long as the structures of the corresponding children
of a pair of nodes | 7901 * structure to another as long as the structures of the corresponding children
of a pair of nodes |
| 7902 * are the same. | 7902 * are the same. |
| 7903 */ | 7903 */ |
| 7904 class ResolutionCopier implements AstVisitor<bool> { | 7904 class ResolutionCopier implements AstVisitor<bool> { |
| 7905 /** | 7905 /** |
| 7906 * Copy resolution data from one node to another. | 7906 * Copy resolution data from one node to another. |
| 7907 * | 7907 * |
| 7908 * @param fromNode the node from which resolution information will be copied | 7908 * @param fromNode the node from which resolution information will be copied |
| 7909 * @param toNode the node to which resolution information will be copied | 7909 * @param toNode the node to which resolution information will be copied |
| (...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9083 return trampoline(target, arguments[0], arguments[1]); | 9083 return trampoline(target, arguments[0], arguments[1]); |
| 9084 case 3: | 9084 case 3: |
| 9085 return trampoline(target, arguments[0], arguments[1], arguments[2]); | 9085 return trampoline(target, arguments[0], arguments[1], arguments[2]); |
| 9086 case 4: | 9086 case 4: |
| 9087 return trampoline(target, arguments[0], arguments[1], arguments[2], argu
ments[3]); | 9087 return trampoline(target, arguments[0], arguments[1], arguments[2], argu
ments[3]); |
| 9088 default: | 9088 default: |
| 9089 throw new IllegalArgumentException("Not implemented for > 4 arguments"); | 9089 throw new IllegalArgumentException("Not implemented for > 4 arguments"); |
| 9090 } | 9090 } |
| 9091 } | 9091 } |
| 9092 } | 9092 } |
| OLD | NEW |