mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:19:48 +00:00
4124e85f09
This CL uses Martins suggested fix (adding 1 to avoid shifting a negative), and adds a simple test that compiles the parser to dart2js (with asserts enabled) and runs it via d8. This will perhaps catch breakage up front another time. To my knowledge this is not a supported use case though, so likely we can't but in much effort for any future big breakages. Fixes https://github.com/dart-lang/sdk/issues/50048 Change-Id: Ic5ac6e63f2d6d32e38ba562ed21dbe85328935cc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261301 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Jens Johansen <jensj@google.com>
39 lines
1.4 KiB
Dart
39 lines
1.4 KiB
Dart
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'package:_fe_analyzer_shared/src/parser/forwarding_listener.dart'
|
|
show ForwardingListener;
|
|
import 'package:_fe_analyzer_shared/src/parser/parser.dart' show Parser;
|
|
import 'package:_fe_analyzer_shared/src/scanner/scanner.dart'
|
|
show ScannerConfiguration, StringScanner;
|
|
import 'package:_fe_analyzer_shared/src/scanner/token.dart' show Token;
|
|
|
|
void main(List<String> args) {
|
|
String source = """
|
|
void main(List<String> args) {
|
|
print("Hello, World!");
|
|
}
|
|
""";
|
|
|
|
ScannerConfiguration scannerConfiguration = new ScannerConfiguration(
|
|
enableExtensionMethods: true,
|
|
enableNonNullable: true,
|
|
enableTripleShift: true);
|
|
|
|
StringScanner scanner = new StringScanner(
|
|
source,
|
|
includeComments: true,
|
|
configuration: scannerConfiguration,
|
|
languageVersionChanged: (scanner, languageVersion) {
|
|
// For now don't do anything, but having it (making it non-null) means the
|
|
// configuration won't be reset.
|
|
},
|
|
);
|
|
Token firstToken = scanner.tokenize();
|
|
ForwardingListener listener = new ForwardingListener();
|
|
Parser parser = new Parser(listener);
|
|
parser.parseUnit(firstToken);
|
|
print("--- End of parsing ---");
|
|
}
|