-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[Feature Request] Target for Rust Programming Language #1839
Comments
This will only happen if someone from the community creates such a target and sends a pull request to the main ANTLR repo. |
I would be willing to contribute, is somebody working on this subject already, so I dont do double work? |
You can also create a new topic in ANTLR google group |
This would also be useful for a work project I'm working on. |
This would be great. A minimal implementation that omits some features would be fine (the Go implementation doesn't have a default visitor implementation for example). I just want to walk the tree myself. |
I'd like to give this a shot unless someone else is already working on it. |
Yes, I think it's a great idea! |
Would be awesome! Where can I watch the progress? |
@metadave I have done quite a lot of work on it recently. You can see it in https://github.com/rrevenantt/antlr4rust BTW How complete target implementation should be to be merged in? |
@rrevenantt I recommend to use a clone of the antlr repo instead of an own repo, with an own structure. This way you can later create a pull request to get your code merged in and you can directly use the scripts, folders and test infrastructure of the main repo. Keep in mind that your target has to run the entire test suite that's executed for each of the targets. It would also be good to announce this work on the ANTLR4 mailing list. |
@rrevenantt excellent! if that's the case, then perhaps I'll pick a different (new) target to work on, as I've wanted to learn all the internals of Antlr4 for quite some time. |
@mike-lischke Thanks. I was thinking about using git-subtree, so i have created it as a separate repo. Anyway I can easily merge them later. Nevertheless I am already using test infrastructure of the main repo, and quite some tests from test suit are already passing. So the only requirement for PR is to pass complete runtime test-suit (and I suppose integrate api tests to CI) and then I can continue to improve it as part of main repo? Is it better to ask subsequent questions on the mailing list as well? |
If that works out for you then fine! I had some trouble when I worked on the C++ target, which also used an own repo, that's why I mentioned it. If a number of the tests already succeed then you are already pretty far. That's very impressive! For further discussions I'd indeed recommend the mailing list. |
I like GitHub issues, I think it's also an appropriate place for feature/bug discussions. |
So I have implemented almost everything, less than 10 test are failing. Also there are some refactorings I would like to do beforehand. I think it will take couple more days. |
It's really awesome. |
Finally, I have made it pass all tests. Those last parts were heavily based on inheritance and RTTI, which does not integrate with Rust paradigm after some point. So I had to rewrite parser generation for labeled alternatives to create enums. But it can generate almost fully idiomatic Rust syntax tree now. Was also going to remove most of the redundant allocations and cloning, but it appeared much harder than I expected. It is a real problem only in some rare corner cases, though, so I think Rust target can already be used. Will still try to clean up and make a PR tomorrow. But I doubt that it will be merged quickly, also I will not be able to work on it much for about a week, so if anyone wants to use it ASAP, ping me and I will release it separately in my repo until it is merged. |
So while fixing that last issues, and preparing PR, I was thinking how everything is going to work if it gets merged in current state, and decided not to do it right now.
Nevertheless, I am not 100 % sure and if you prove me wrong, I can create PR next day. Meanwhile |
Hi, it's great that you've reached this state! The code for this target might be merged anytime. However, the pace of releases is low: there was only 1 last year, and there was one just a month ago. We might afford a release for this, I'd say it's definitely worth it. But you probably want to increase confidence in your API before letting anyone build on the current one only to find that it breaks 3 months later (I haven't looked at the API so only suggesting that from your own sayings). The recommended way of using ANTLR4 is through listeners or visitors, so make sure you get these right! Without inheritance, it's certainly a challenge! Early adopters can always get started using your branch, but then they know what to expect in terms of API stability. |
Thank you for all your work. I've tried rust target in my project. It worked with my previous grammar file. What is the status of the rust target now? When will it merge in? |
What is the status of the Rust target please? |
antlr4rust hasn't had a commit in almost a year and still seems to only work for rust nightly, are there any forks or something that anyone is working on? I'd really like a rust target, and I would do it myself but I don't think I'm experienced enough in Rust to figure that out. Any updates would be great |
Sorry for my absence, was really busy irl. I have just started working on it again, like a two days ago. Nevertheless there is rrevenantt/antlr4rust#29 PR which is where I left off and it already works on stable rust. I am going to publish a prerelease version with it in a couple of days. There are still some more things i wanted to do before a proper next version release though. And after that i will start working on a PR to merge it into this repository |
Maybe it's even better because I significantly simplified runtime test infrastructure. Just compare test classes for C++ in the old infrastructure and in the new infrastructure. Now it's much simpler to integrate new targets. |
@KvanTTT Do we have a document describing how to integrate a new target into the test infrastructure? I vaguely remember having read instructions in the past (after all I integrated the C++ target), but that info is probably outdated now and I don't remember where I read it. |
Yes, it's here: https://github.com/antlr/antlr4/blob/dev/doc/creating-a-language-target.md Also, I'm in process of updating some outdated docs. |
Also, I'd recommend looking at other targets and implementing a new one in the similar way. For instance, here is the setup for C++: https://github.com/antlr/antlr4/blob/dev/runtime-testsuite/test/org/antlr/v4/test/runtime/cpp/CppRunner.java |
A significant potential benefit of a Rust target is... WebAssembly. My own experiments trying to move some bits of the js runtime to webasm have not been encouraging (the cost of crossing the js/webasm fence is higher than the benefits). |
Guys...sorry but not sure I'd be interested in yet another platform to support / manage. |
Seems Rust is growing well. Really waiting for Rus target. |
@rrevenantt I saw that the 0.3-prerelease got merged. I'm curious to know where I should be using your repo or this if I want to have a rust target. |
@rrevenantt Friendly ping. Any update on your end? We are currently starting a ANTLR project and thinking about using your rust target. But it looks a bit stalled. Just to be clear: It's totally fine if you don't continue this, just us knowing that would be helpful ;) |
Me, too! @rrevenantt I just started looking at your fork, but don't have a good sense of how much work it would be to refactor based on the latest dev branch. I might play around on my own, but if you had any thoughts I'd love to hear them. |
I have the same impression - unfortunately.
It would be great if anybody had the time and skill to continue this. There are quite a few pull requests pending for that project. It's probably worth checking them first. It seems people have spend effort on creating patches to fix issues or realize additional functionality. It would make sense to go from there? |
I propose we have a target for Rust Programming Language since:
Rust has become a mature programming language with the constant effort from Mozilla. The I haven't found any good parser generators in the Rust world yet. Hopefully, ANTLR can be one.
The text was updated successfully, but these errors were encountered: