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

support for records #45

Open
hohwille opened this issue Feb 11, 2023 · 1 comment
Open

support for records #45

hohwille opened this issue Feb 11, 2023 · 1 comment

Comments

@hohwille
Copy link
Member

In Java 14 records have been introduced.
We need to extend mmm-code to support this new language construct.

@hohwille
Copy link
Member Author

Fundamentals are implemented, tested, and working.
However, parser needs to be adapted to parse the default record constructor and detect implicitly declared fields, etc.

During this change, I refactored the writing of source-code and moved a lot of that logic from the BaseItems to CodeLanguage. This does not perfectly align with polymorphism but gives the needed flexbility to implement other languages than Java. Initially my design idea was to create the entire CodeItem hierarchy for each programming language. However, I noticed that this would lead to a very large tree of classes for every supported language while most of them (and those in focus) all share the same constructs. So instead Base* types are already the implementation for almost all of the hierarchy and only language, context, and few other constructs need to be language specific.
This even makes it possible to more easily transform between JVM languages as constructs can be reused and just be written in a slightly different syntax (e.g. to write Java code as Kotlin). The current drawback is that very different languages like e.g. JavaScript or Haskel do not fit very well and also advanced languages like Scala need some quirks to support constructs like traits that do not exist in Java.

hohwille added a commit that referenced this issue Feb 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant