-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Fix case *_ error #4280
Fix case *_ error #4280
Conversation
Wait a minute. I forgot to test targets other than Java and add test for the fixed error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a .py file to examples/ that tests the changed rules for this PR.
None of the examples/*.py tested |
Ok, I will write examples for them |
I've added examples from Python 3.12 Standard Lib, examples written by me and ChatGPT, and Cpp target. I am not sure whether all targets work correctly. |
test not passed: _bootstrap_external.py, _test_eintr.py, dump.py,test__interpchannels.py, test__interpreters.py,test_array.py, test_builtin.py, test_clinic.py,test_compile.py, test_exceptions.py, test_frame.py,test_fstring.py, test_imaplib.py, test_logging.py,test_opcache.py, test_os.py, test_posix.py,test_regrtest.py, test_str.py, test_subprocess.py,test_sys.py, test_tabnanny.py, test_traceback.py,test_type_params.py, test_venv.py |
fix("PythonParser.g4"); | ||
|
||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rewrite this as a Python (v3) script. The reason is that the build currently checks for file transformGrammar.py (in ps1:
grammars-v4/_scripts/templates/Cpp/st.build.ps1
Lines 11 to 13 in c82c128
if (Test-Path -Path transformGrammar.py -PathType Leaf) { | |
$(& python3 transformGrammar.py ) 2>&1 | Write-Host | |
} |
There are a multitude of examples in grammars-v4.
$ find . -name transformGrammar.py | grep Cpp
./bison/Cpp/transformGrammar.py
./cpp/Cpp/transformGrammar.py
./dart2/Cpp/transformGrammar.py
./fortran/fortran77/Cpp/transformGrammar.py
./fortran/fortran90/Cpp/transformGrammar.py
./golang/Cpp/transformGrammar.py
./gvpr/Cpp/transformGrammar.py
./javascript/javascript/Cpp/transformGrammar.py
./lua/Cpp/transformGrammar.py
./php/Cpp/transformGrammar.py
./python/python/Cpp/transformGrammar.py
./python/python3/Cpp/transformGrammar.py
./rust/Cpp/transformGrammar.py
./swift/swift5/Cpp/transformGrammar.py
10/13-09:29:45 ~/issues/g4-mysql-target-agnostic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The alternative is to create "transformGrammar.py" which has Python compiling the .cpp file using g++, then running it. I think g++ is a dependency which is probably ok even on Windows. But, you will need to test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The final alternative that I can think of is to alter the templates st.build.ps1 and st.build.sh scripts (in _scripts/templates/Cpp and maybe the other targets) to perform the g++/run. Wish Antlr handled actions a little better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I didn't noticed that, I think I will simply rewrite the transformGrammar with Python3.
I was able to reproduce the error. |
Adding a CPP port is fine, although I am working on such a port as well. The problem is that you are trying to overwrite the newer one with an older version, which causes a regression in many files. I don't see where you fixed the Please explain the many changes in PythonParser.g4. |
The real change that solve the problem is:
Other changes are useless and you can change them back.
I haven't solved it yet. |
Some fixes are in order.
|
Thanks for the feedback about the two errors.
I'll even look into your further simplifications on this. I am also working on the "escape quotes character in f-string" error: |
Looks like I managed to find and fix the "escape quotes character in f-string" bug. Please change only the things related to the error "soft_kw__not__wildcard failed predicate" in PythonParser.g4 in the new PR. Take
Once you have the runtime modification, you can test |
I will make this PR only adding star_pattern and delete others for now. And I will work on the Cpp after the exam if you haven't started that then. Thanks. Btw, the PR will be a part of my Learning Portfolio, something mandatory and counted in scores to hand in to universities when applying to back here. |
@Willie169 thanks! |
Fix that
case [a, *_] if a == 0:
throws errorrule soft_kw__not__wildcard failed predicate: {this.isnotEqualToCurrentTokenText("_")}?