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

Differentiating between several parser and lexer issues #72

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

ftomassetti
Copy link
Member

I think that, in order to facilitate the translation of error messages, we need to produce different codes for different messages. We also need to provide all the arguments needed to recreate the messages in another language.

Unfortunately, that means looking at the actual strings being generated unless we replace the DefaultErrorStrategy with a different one (if you prefer that I go that route, let me know, and I will update the PR).

Note also that in some cases, we produce more than one argument with the same name, implicitly providing an array. This is the case, for example, for cases where we need to report multiple tokens that could be used at a certain point. We could report all of them in a single string with commas, but perhaps in certain languages, they do not use commas

Fix #71

@ftomassetti
Copy link
Member Author

Also, probably we will need to distinguish across more error types in the future, judging by the different strings produced in: https://github.com/antlr/antlr4/blob/7d4cea92bc3f7d709f09c3f1ac77c5bbc71a6749/runtime/Java/src/org/antlr/v4/runtime/DefaultErrorStrategy.java

@alessiostalla
Copy link
Member

While a custom error strategy would make this cleaner, given that the users of the library are expected to instantiate the ANTLR parser themselves, I don't think it's a great idea to impose our own custom strategy. We could try opening an issue on antlr4ng and/or the ANTLR main project.

@alessiostalla alessiostalla merged commit c2db2d8 into master Jun 20, 2024
2 checks passed
@alessiostalla alessiostalla deleted the bugfix/localized-issues branch June 20, 2024 09:41
@ftomassetti
Copy link
Member Author

Thank you @alessiostalla ! When you have time, could you do a new release?

@alessiostalla
Copy link
Member

Published now!

@ftomassetti
Copy link
Member Author

Thanks!

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.

Feedback on localized issues
2 participants