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

Use grammars from the TS project for C++ port testing #161

Merged
merged 7 commits into from
Jan 5, 2025

Conversation

vityaman
Copy link
Contributor

@vityaman vityaman commented Dec 5, 2024

Once, I was surprised with different ATN State numbers in program traces of C++ and TS ports, but the problem was in different grammar files usage, so I decided to share grammars between ports to prevent copy-paste problems in the future.

Signed-off-by: vityaman <vityaman.dev@yandex.ru>
@vityaman vityaman changed the title Take grammars for C++ port testing from the TS project Draft: Take grammars for C++ port testing from the TS project Dec 5, 2024
@vityaman vityaman changed the title Draft: Take grammars for C++ port testing from the TS project Take grammars for C++ port testing from the TS project Dec 5, 2024
@vityaman vityaman marked this pull request as draft December 5, 2024 07:48
Signed-off-by: vityaman <vityaman.dev@yandex.ru>
@vityaman vityaman marked this pull request as ready for review December 5, 2024 07:52
Copy link
Owner

@mike-lischke mike-lischke left a comment

Choose a reason for hiding this comment

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

If you remove purespecifier, is that still a valid C++ grammar? The keypoint for the tests was not to change the grammars but work around problems (to also demonstrate what to do if you cannot change a grammar).

@vityaman
Copy link
Contributor Author

vityaman commented Dec 5, 2024

@mike-lischke, hmm, I thought the purpose is just to show that c3 works even with such complex examples. Ok, then I will think how to reuse this grammar without changing it. Maybe will use some script to patch it or come up with some other solution.

Signed-off-by: vityaman <vityaman.dev@yandex.ru>
@vityaman
Copy link
Contributor Author

vityaman commented Dec 6, 2024

@mike-lischke, I edited the Cpp14 grammar to workaround language dependency.

Signed-off-by: vityaman <vityaman.dev@yandex.ru>
Copy link
Owner

@mike-lischke mike-lischke left a comment

Choose a reason for hiding this comment

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

There's no way to work with the C++ grammar unchanged? The point is not only having a complex example, but also to find a way to work around certain grammar rules which make it difficult to get candidates easily.

And then you remove some of the generated files (good!) but left in and changed some (why?).

And finally, why did you remove the whitebox grammar? I would expect you to implement the entire TS test suite.

@mike-lischke
Copy link
Owner

@vityaman are you going to address my questions?

@vityaman
Copy link
Contributor Author

@mike-lischke, sorry, currently overwhelmed with university tasks. I will continue working on this MR on January 29th.

About C++ grammar. Originally it uses embedded code in TS, which is not valid C++ code and therefore requires patching to generate C++ parser. So I see only 2 options to deal with this state: either change the grammar or write some python script to patch it.

About deletion of the Whitebox grammar. It seems to me, that I deleted all grammars from ports/cpp/tests, but left all grammars at TS tests.

About added generated files. I made these changes before merging an MR with removal and ignorance of generated sources, so I need to rebase on the main branch.

Signed-off-by: vityaman <vityaman.dev@yandex.ru>
Signed-off-by: vityaman <vityaman.dev@yandex.ru>
@vityaman vityaman changed the title Take grammars for C++ port testing from the TS project Use grammars from the TS project for C++ port testing Jan 5, 2025
@vityaman
Copy link
Contributor Author

vityaman commented Jan 5, 2025

@mike-lischke, the MR is considered ready. Sorry for a long absence, I just forgot about this MR.

I synced the branch with the main, so now diff looks as expected: just removed copy-pasted grammars from C++ port, changes in C++ port build configuration and C++ grammar changes.

I left C++ grammar changed as it is still valid C++ grammar with the same semantics and leaving it like this is much more simpler than writing patches potentially for each language port.

@mike-lischke
Copy link
Owner

@vityaman Looks like you need to rebase first.

@vityaman
Copy link
Contributor Author

vityaman commented Jan 5, 2025

@mike-lischke, GitHub says that there are no conflicts with the base branch. Can you just squash all commits from this MR into a single one on merge?

@mike-lischke mike-lischke merged commit 91a5db0 into mike-lischke:main Jan 5, 2025
6 checks passed
@mike-lischke
Copy link
Owner

Odd, but the squash merge worked. Thanks!

@vityaman vityaman deleted the cpp-shared-grammar branch January 6, 2025 10:22
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.

2 participants