Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[antlr] add LexerAdaptor for dart #3977

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

CorvusYe
Copy link

This PR may have some inappropriate aspects as I cannot find the contribution guide.
Please feel free to point it out.

@kaby76
Copy link
Contributor

kaby76 commented Feb 21, 2024

$ trgen -t Dart --force
C:\msys64\home\Kenne\issues\g4-3977\antlr\antlr4
CSharp  ANTLRv4Lexer.g4 success 0.0553075
CSharp  ANTLRv4Parser.g4 success 0.0093005
Rendering template file from Dart/pubspec.yaml to ./Generated-Dart/pubspec.yaml
Rendering template file from Dart/st.analysis_options.yaml to ./Generated-Dart/st.analysis_options.yaml
Rendering template file from Dart/st.build.ps1 to ./Generated-Dart/st.build.ps1
Rendering template file from Dart/st.build.sh to ./Generated-Dart/st.build.sh
Rendering template file from Dart/st.clean.ps1 to ./Generated-Dart/st.clean.ps1
Rendering template file from Dart/st.clean.sh to ./Generated-Dart/st.clean.sh
Rendering template file from Dart/st.makefile to ./Generated-Dart/st.makefile
Rendering template file from Dart/st.MyErrorListener.dart to ./Generated-Dart/st.MyErrorListener.dart
Rendering template file from Dart/st.perf.sh to ./Generated-Dart/st.perf.sh
Rendering template file from Dart/st.run.ps1 to ./Generated-Dart/st.run.ps1
Rendering template file from Dart/st.run.sh to ./Generated-Dart/st.run.sh
Rendering template file from Dart/st.Test.dart to ./Generated-Dart/st.Test.dart
Rendering template file from Dart/st.test.ps1 to ./Generated-Dart/st.test.ps1
Rendering template file from Dart/st.test.sh to ./Generated-Dart/st.test.sh
Copying source file from C:/msys64/home/Kenne/issues/g4-3977/antlr/antlr4/readme.md to ./Generated-Dart/readme.md
Copying source file from C:/msys64/home/Kenne/issues/g4-3977/antlr/antlr4/LexBasic.g4 to ./Generated-Dart/LexBasic.g4
Copying source file from C:/msys64/home/Kenne/issues/g4-3977/antlr/antlr4/desc.xml to ./Generated-Dart/desc.xml
Copying source file from C:/msys64/home/Kenne/issues/g4-3977/antlr/antlr4/ANTLRv4Parser.g4 to ./Generated-Dart/ANTLRv4Parser.g4
Copying source file from C:/msys64/home/Kenne/issues/g4-3977/antlr/antlr4/ANTLRv4Lexer.g4 to ./Generated-Dart/ANTLRv4Lexer.g4
Copying source file from C:/msys64/home/Kenne/issues/g4-3977/antlr/antlr4/Dart/LexerAdaptor.dart to ./Generated-Dart/LexerAdaptor.dart
02/21-05:51:34 ~/issues/g4-3977/antlr/antlr4
$ cd Generated-Dart/
02/21-05:51:37 ~/issues/g4-3977/antlr/antlr4/Generated-Dart
$ ls
analysis_options.yaml  build.ps1  clean.sh     LexerAdaptor.dart     perf.sh       run.ps1    test.ps1
ANTLRv4Lexer.g4        build.sh   desc.xml     makefile              pubspec.yaml  run.sh     test.sh
ANTLRv4Parser.g4       clean.ps1  LexBasic.g4  MyErrorListener.dart  readme.md     Test.dart
02/21-05:51:38 ~/issues/g4-3977/antlr/antlr4/Generated-Dart
$ make
bash build.sh
Resolving dependencies... (2.0s)
+ _fe_analyzer_shared 67.0.0
+ analyzer 6.4.1
+ antlr4 4.13.1
+ args 2.4.2
+ async 2.11.0
+ boolean_selector 2.1.1
+ collection 1.18.0
+ convert 3.1.1
+ coverage 1.7.2
+ crypto 3.0.3
+ file 7.0.0
+ frontend_server_client 3.2.0
+ glob 2.1.2
+ http_multi_server 3.2.1
+ http_parser 4.0.2
+ io 1.0.4
+ js 0.7.1
+ logging 1.2.0
+ matcher 0.12.16+1
+ meta 1.12.0
+ mime 1.0.5
+ node_preamble 2.0.2
+ package_config 2.1.0
+ path 1.9.0
+ pedantic 1.11.1 (discontinued replaced by lints)
+ pool 1.5.1
+ pub_semver 2.1.4
+ shelf 1.4.1
+ shelf_packages_handler 3.0.2
+ shelf_static 1.1.2
+ shelf_web_socket 1.0.4
+ source_map_stack_trace 2.1.1
+ source_maps 0.10.12
+ source_span 1.10.0
+ stack_trace 1.11.1
+ stream_channel 2.1.2
+ string_scanner 1.2.0
+ term_glyph 1.2.1
+ test 1.25.2
+ test_api 0.7.0
+ test_core 0.6.0
+ typed_data 1.3.2
+ vm_service 14.0.0
+ watcher 1.1.0
+ web 0.4.2 (0.5.0 available)
+ web_socket_channel 2.4.3 (2.4.4 available)
+ webkit_inspection_protocol 1.2.1
+ yaml 3.1.2
Changed 48 dependencies!
1 package is discontinued.
2 packages have newer versions incompatible with dependency constraints.
Try `dart pub outdated` for more information.
LexerAdaptor.dart:37:16: Error: The 'super-parameters' language feature is disabled for this library.
Try removing the package language version or setting the language version to 2.17 or higher.
  LexerAdaptor(super.input);
               ^^^^^
LexerAdaptor.dart:37:3: Error: The superclass, 'Lexer', has no unnamed constructor that takes no arguments.
  LexerAdaptor(super.input);
  ^^^^^^^^^^^^
Error: AOT compilation failed
Generating AOT kernel dill failed!
mingw32-make: *** [makefile:3: build] Error 64
02/21-05:51:54 ~/issues/g4-3977/antlr/antlr4/Generated-Dart
$ dart --version
Dart SDK version: 3.3.0-273.0.dev (dev) (Fri Dec 29 04:03:30 2023 -0800) on "windows_x64"
02/21-05:56:11 ~/issues/g4-3977/antlr/antlr4/Generated-Dart

I have a problem compiling the code. Also, the desc.xml should have "Dart" listed. All the driver code is in the repo, here: https://github.com/antlr/grammars-v4/tree/master/_scripts/templates/Dart

@CorvusYe
Copy link
Author

Although the SDK version of the environment is 3.3.0-273.0. dev, this line should play a crucial role.
The sdk version can be 2.12 in driver code.
We can try changing this version to 2.17 or higher.

@kaby76
Copy link
Contributor

kaby76 commented Feb 21, 2024

I changed the pubspec.yaml as you suggested, but the parser is not producing the correct output. I am expecting errors for examples/LexerElementLabel.g4. The Antlr4 tool, and the CSharp and Java target parsers all report the error, but the Dart target does not. Please update your code and test.

02/21-09:08:13 ~/issues/g4-3977/antlr/antlr4/xxx
$ antlr4 LexerElementLabel.g4
error(50): LexerElementLabel.g4:4:11: syntax error: '=' came as a complete surprise to me while looking for lexer rule element
02/21-09:08:19 ~/issues/g4-3977/antlr/antlr4/xxx
$ cd ../Generated-Dart/
02/21-09:08:25 ~/issues/g4-3977/antlr/antlr4/Generated-Dart
$ ./test.exe ../xxx/LexerElementLabel.g4
Dart 0 ../xxx/LexerElementLabel.g4 success 0.0
Total Time: 0.001
02/21-09:08:43 ~/issues/g4-3977/antlr/antlr4/Generated-Dart
$ bash run.sh ../examples/LexerElementLabel.g4
line 4:8 no viable alternative at input 'var'
line 4:11 mismatched input '=' expecting {BEGIN_ARGUMENT, OPTIONS, 'returns', 'locals', 'throws', COLON, AT}
Java 0 ../examples/LexerElementLabel.g4 fail 0.032
Total Time: 0.113
02/21-09:11:23 ~/issues/g4-3977/antlr/antlr4/Generated-java
$ cd ../Generated-CSharp/
02/21-09:11:28 ~/issues/g4-3977/antlr/antlr4/Generated-CSharp
$ bash run.sh ../examples/LexerElementLabel.g4
line 4:8 no viable alternative at input 'var'
line 4:11 mismatched input '=' expecting {BEGIN_ARGUMENT, OPTIONS, 'returns', 'locals', 'throws', COLON, AT}
CSharp 0 ../examples/LexerElementLabel.g4 fail 0.0313289
Total Time: 0.0822919
02/21-09:11:36 ~/issues/g4-3977/antlr/antlr4/Generated-CSharp
$

@CorvusYe
Copy link
Author

Ok, I will revise it as soon as possible. Thanks for your feedback~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants