Closed yuripourre closed 2 years ago
This should be moved to the discussion area. I think that you are talking about the candy generator?
Yes, I was talking about the candy-generator. I have no idea how much effort would be to replace the current generator.
At the time I developed it, I did not find any parser to do it. I looked at your basic example but besides parsing, we need an AST to visit the nodes and generate the corresponding Java code. So I guess the difficult part would be to translate the parsing result to the AST in https://github.com/cincheo/jsweet/tree/develop/candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast.
Once you have this AST up, then it is just a matter of calling the generation visitor (like in https://github.com/cincheo/jsweet/blob/develop/candy-generator/src/main/java/org/jsweet/input/typescriptdef/TypescriptDef2Java.java).
@renaudpawlak thank you for explaining what is needed. I got frustrated again when tried to generate the candy for babylonjs (I tried 2 years ago). This time I was downgrading the typescript file so they could match what the current parser of JSweet was expecting. It may work but I am afraid that it would be too much work every time a new version of babylonjs is released.
I am studying alternatives but for most of them I will have to write the code from scratch.
The current parser cannot parse newer versions of typescript, replacing it should be easier than keeping the cup/lex files updated.
https://github.com/eclipsesource/J2V8
A basic example: https://sangupta.com/tech/parsing-typescript-in-java.html