rcdev58
Hi Richard. It's good to hear you got it going. Actually, this was a flaw in the code, setting the lastConsumedToken
in the constructor, and then if somebody defined their own constructor without setting that... Well, you can see the (quite trivial change) here
I'm going to attempt to use CongoCC to generate Rust code. I'll use the fact that CongoCC already generates output in different languages as a model on how to approach the problem.
Well, that's interesting. That is a fairly significant undertaking. It is Vinay who has done the most work to get the Python and C# code generation working and he could tell you how much work it is! But the place to look, in terms of implementing code generation for another language is here: https://github.com/congo-cc/congo-parser-generator/tree/main/src/templates
So, in principle, it amounts to translating about 5000 lines of template code to generate Rust instead of the other languages. (There would be a bit of glue code to activate those templates as opposed to the others, but that is surely trivial.) One caveat I should mention is that the support for non-Java languages is still not really quite on a par with the Java implementation because, for example, INJECT
is still not supported. Actually, I intend to get it working, and there was a massive refactoring to support that I carried out maybe two years ago (!) but, well...
Of course, to get INJECT
working for Rust or any other language, you would need to have a reliable parser for the language. And, actually, to generate code, it is nice to be able to do a final pass where you run it through some dead code reaer and pretty-printer and that requires being able to parse the language. And then it is fairly trivial to have the Code formatter anddead code remover working for Rust, say. Of course, that said, the code generator would work without any beautification or dead code removal, but I guess what I'm thinking also is that if you want to get going, maybe it's a more manageable initial project to get the Rust parser working and the code beautifier and reaper, say. I mean, those things are even somewhat useful on their own. But they are necessary pieces if you really want to have a parser generator for Rust that is on a par with the one for Java...
So, I'm thinking maybe that contributing a Rust grammar/parser could be a better initial project to sink one's teeth into. But I don't really know what your ambitions with this are, so I'm just thinking out loud, I guess. By all means, don't be shy about batting around some ideas here.