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

[postgresql] Fix for #4324; add ports. #4325

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

kaby76
Copy link
Contributor

@kaby76 kaby76 commented Nov 13, 2024

This is a fix for #4324. The grammar was not "target agnostic" and there were just two targets implemented. With this change almost all targets are supported. I didn't bother with the implementation of the PHP port because it is very slow in general and contains errors in ATN Config hash value and equality computions. This problem becomes accute with ambiguity and fallbacks. I also didn't write the Swift port because I don't develop on MacOS.

Target Agnostic is a specific coding style for .g4 files to allow any target to be generated from one copy of the .g4 files: All @members and @headers are replaced with a comment; Actions { ... } and { ... }?contain only parameterless method calls with a this. prefix; transformGrammar.py is used to modify the .g4s just prior calling the Antlr Tool specific for the target because there are still minor variations for targets from the established format. The purpose of Target Agnostic is to avoid the major problem of keeping multiple copies of the .g4 files in synch across ports.

The following ports were added: Antlr4ng, Cpp, Dart, Go, JavaScript, Python3, TypeScript. Existing ports are: CSharp, Java. Note, the Go port became out of synch because it was not plugged into the build. It now works.

Notes

  • The spaces on either side of the method call in an action have been removed. Python requires code to begin in very specific columns in order to nest within an if-statement.
  • The readme has been updated with a description of how to use transformGrammars.py.
  • All the methods in actions have been updated.
  • There is change in one of the rules from [postgresql] Fixes for #4321, #4322 #4323. This "disappears" when performing the merge after the other PR.
  • I'm unclear why there are lexer rules that match empty. I had to remove the empty curly actions { } in these rules because the code does not compile for Python3.

@kaby76
Copy link
Contributor Author

kaby76 commented Nov 14, 2024

(Requires #4323 to be merged first.)

@kaby76
Copy link
Contributor Author

kaby76 commented Nov 14, 2024

(Finally a clean build. Failures had nothing to do with this PR. It's all a matter of chance. See #4326.)

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.

1 participant