Skip to content

Adopt new structure for proper grammar generation #60

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

gravemalte
Copy link
Member

@gravemalte gravemalte commented Jun 30, 2025

This PR is a draft/suggestion PR. Collaboration with @MiriamGaus and @coemgen1992.

We discovered that this repository is in a very poor state, both in terms of documentation and dependencies. While we want to promote UVL, achieving this requires a proper structure and good understandability of the repository. Currently, the information in the README is outdated, the dependencies are outdated, and it is difficult to generate parsers for different languages. The CI (as far as I know) is not working properly. For these reasons, we decided to clean up the entire repository and document it thoroughly.

This effort introduces changes to the structure, the documentation, and the grammar files. I have split the grammar into lexer- and parser-relevant files to ensure modular behavior when generating UVL for different programming languages. Additionally, integrating new languages is now easier than ever. The CI can easily generate the parser/lexer, and in the future, we plan to introduce a proper test environment.

The tests will be moved to a new repository, and we will integrate them as a git submodule

Please provide feedback and bear with us if you encounter any mistakes.

@SundermannC SundermannC self-requested a review June 30, 2025 14:09
Copy link
Member

@SundermannC SundermannC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for putting this together. I think the repository is in a much better shape with your changes. I have some small comments, but all of those can also be performed later. From my tests, the parser generation for each language appears to work as expected.

@SundermannC
Copy link
Member

Thanks a lot for the quick answers. I guess we could merge this very soon. The main hindrance are the merge conflicts. Can you resolve them @gravemalte

@gravemalte
Copy link
Member Author

Thanks a lot for the quick answers. I guess we could merge this very soon. The main hindrance are the merge conflicts. Can you resolve them @gravemalte

Sure I will resolve them. Next week I have some time to do the rest.
Before merging I would like to have more people to try out the changes because they are breaking and critical. So please, to all of the UVL people try to build this locally.

@SundermannC
Copy link
Member

Makes sense. I asked @jagalindo and @rotkiv93 for further reviews as they appear to be the main users/developers for the Python and JS parsers respectively.

@jagalindo
Copy link
Collaborator

This PR makes sense to me. I'd agree on having different readmes for different targets if needed. We just got the uvl org in pypi, so we cab move the pypi package to the shared org. The organization seems right to me. What do you think @rotkiv93?

@rotkiv93
Copy link
Collaborator

rotkiv93 commented Jul 21, 2025

I checked our JS version, and we need to change the package.json file in order to be able to build the grammar properly.

We need to change this line:

"build-grammar": "antlr4 -Dlanguage=JavaScript -o src/lib -Xexact-output-dir ../uvl/UVLJavaScript.g4",

With this command:
antlr4 -lib ../uvl/ -Dlanguage=JavaScript -o ./src/lib ../uvl/JavaScript/UVLJavaScriptLexer.g4 ../uvl/JavaScript/UVLJavaScriptParser.g4

Also, we checked and the grammar doesnt compile properly with older antlr4 versions, for example, v4.7.2 does not work properly, we should put a disclaimer somewher (probably in the JS README)

@gravemalte
Copy link
Member Author

I checked our JS version, and we need to change the package.json file in order to be able to build the grammar properly.

We need to change this line:

"build-grammar": "antlr4 -Dlanguage=JavaScript -o src/lib -Xexact-output-dir ../uvl/UVLJavaScript.g4",

With this command: antlr4 -lib ../uvl/ -Dlanguage=JavaScript -o ./src/lib ../uvl/JavaScript/UVLJavaScriptLexer.g4 ../uvl/JavaScript/UVLJavaScriptParser.g4

Also, we checked and the grammar doesnt compile properly with older antlr4 versions, for example, v4.7.2 does not work properly, we should put a disclaimer somewher (probably in the JS README)

I will change this thanks for pointing out. Speaking of JS, I have a question about the export statement in the index.js.
The export of the UVL ANTLR UVLJavaScriptParser.js is marked there, is there any reason why? Because the parser itself is quite useless without the UVLJavaScriptCustomLexer. Also the UVLJavaScriptParser is exported in the FeatureModel.js again.

@rotkiv93
Copy link
Collaborator

@gravemalte You are right—it's weird to have it like this. There's no problem with deleting it from the index.js file. Also, I don't think it's relevant to have it exported in the FeatureModel.js file either. I think we can delete it for now, and if a case arises where it needs to be exported, we can change it in the future.

@gravemalte gravemalte marked this pull request as ready for review July 24, 2025 11:17
@gravemalte
Copy link
Member Author

I resolved all the conflicts and addressed the comments.

But please test this again.

I tried to run the test suite from @MiriamGaus in PR Universal-Variability-Language/java-fm-metamodel#15 with my changes, but two tests are failing. I don't know if they failed before. One is about the math expression that a result is wrong, the other is about the de.vill.parsing.ParsingTests.checkLanguageLevelInclude. But error is not very helpful. I didn't have time to investigate these errors, and I'm also not sure if they are from my parser changes here.

@MiriamGaus
Copy link
Contributor

In the old version the test on the de.vill.parsing.ParsingTests.checkLanguageLevelInclude runs and the other test is fixed in the second open PR for the UVL-Parser. There this is a parser problem.

@gravemalte
Copy link
Member Author

@MiriamGaus I will merge now your changes in my branch and try again.

@gravemalte
Copy link
Member Author

@MiriamGaus the Expression fixed the math error like you said, but the lanaguage_level test is still failing. Any ideas?

image

@gravemalte
Copy link
Member Author

Found the cause, was on me. I screwed some symbols up.

Test are passing.

image

@coemgen1992 coemgen1992 self-requested a review July 24, 2025 15:03
Copy link
Collaborator

@rotkiv93 rotkiv93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JS part LGTM

Copy link
Collaborator

@jagalindo jagalindo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd try to investigate if there is any mechanism to update automatically the version numbers so it doesn't crash in the ci actions.

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

Successfully merging this pull request may close these issues.

5 participants