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

[Feature Request] Target for Rust Programming Language #1839

Open
ikarienator opened this issue Apr 25, 2017 · 34 comments
Open

[Feature Request] Target for Rust Programming Language #1839

ikarienator opened this issue Apr 25, 2017 · 34 comments

Comments

@ikarienator
Copy link

ikarienator commented Apr 25, 2017

I propose we have a target for Rust Programming Language since:

  1. Rust has finally delivered stable release last year (currently version 1.16).
  2. Rust has attracted more and more engineers recent years.

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.

@mike-lischke
Copy link
Member

mike-lischke commented Apr 26, 2017

This will only happen if someone from the community creates such a target and sends a pull request to the main ANTLR repo.

@neatnerd
Copy link
Contributor

I would be willing to contribute, is somebody working on this subject already, so I dont do double work?

@KvanTTT
Copy link
Member

KvanTTT commented Jul 22, 2017

You can also create a new topic in ANTLR google group

@spease
Copy link

spease commented Jun 18, 2019

This would also be useful for a work project I'm working on.

@keppel2
Copy link

keppel2 commented Nov 11, 2019

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.

@bookshelfdave
Copy link

I'd like to give this a shot unless someone else is already working on it.

@KvanTTT
Copy link
Member

KvanTTT commented Dec 23, 2019

Yes, I think it's a great idea!

@progral
Copy link

progral commented Dec 25, 2019

Would be awesome! Where can I watch the progress?

@rrevenantt
Copy link

@metadave I have done quite a lot of work on it recently. You can see it in https://github.com/rrevenantt/antlr4rust
A decent bit of things are already working. If anybody wants to help i would gladly appreciate it.

BTW How complete target implementation should be to be merged in?

@mike-lischke
Copy link
Member

mike-lischke commented Dec 26, 2019

@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.

@bookshelfdave
Copy link

@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.

@rrevenantt
Copy link

@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?

@mike-lischke
Copy link
Member

mike-lischke commented Dec 28, 2019

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.

@KvanTTT
Copy link
Member

KvanTTT commented Dec 28, 2019

I like GitHub issues, I think it's also an appropriate place for feature/bug discussions.

@rrevenantt
Copy link

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.

@phodal
Copy link

phodal commented Jan 23, 2020

It's really awesome.

@rrevenantt
Copy link

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.

@rrevenantt
Copy link

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.

  • Firstly, the more I look at my current API design, the more I find ways to improve it ( if you know nothing about Rust, it is very different language in a lot of aspects, which forces you to design API differently). and they can break backward compatibility. Also feels like it needs much more tests than there currently is. And I have looked into other targets and it looks like they were merged in more finished state.
  • Also it feels to me that this repository is not well suited for active development. And there is still quite a lot I can do. So I think that for everyone it would be more convenient, if I will continue to develop Rust target in my own repo for some more time.

Nevertheless, I am not 100 % sure and if you prove me wrong, I can create PR next day. Meanwhile
I have published first version on crates.io, so everyone is welcome to try it out and fill an issue on rrevenantt/antlr4rust if something is wrong.

@ericvergnaud
Copy link
Contributor

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.

@mshijie
Copy link

mshijie commented Jul 13, 2021

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?

@younes-io
Copy link

younes-io commented Nov 11, 2021

What is the status of the Rust target please?

@TabulateJarl8
Copy link

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

@rrevenantt
Copy link

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

@KvanTTT
Copy link
Member

KvanTTT commented Jun 29, 2022

Sorry for my absence, was really busy irl.

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.

@mike-lischke
Copy link
Member

@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.

@KvanTTT
Copy link
Member

KvanTTT commented Jul 9, 2022

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.

@KvanTTT
Copy link
Member

KvanTTT commented Jul 9, 2022

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

@ericvergnaud
Copy link
Contributor

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).
Chances are that with a significant part of the runtime natively optimized for webasm, this balance will revert and we could use a rust originating webasm runtime to power the core of the js/ts one.

@parrt
Copy link
Member

parrt commented Sep 20, 2022

Guys...sorry but not sure I'd be interested in yet another platform to support / manage.

@khoshrou
Copy link

khoshrou commented Oct 5, 2022

Seems Rust is growing well. Really waiting for Rus target.

@rkrishnasanka
Copy link

@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.

@t-b
Copy link

t-b commented Jul 21, 2023

@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 ;)

@sax
Copy link

sax commented Jul 20, 2024

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.

@luzidchris
Copy link

luzidchris commented Jul 27, 2024

@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.

I have the same impression - unfortunately.

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.

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?

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

No branches or pull requests