antlr / antlr4

ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.
http://antlr.org
BSD 3-Clause "New" or "Revised" License
17.22k stars 3.29k forks source link

[Cpp] XPath with v4.12.1/HEAD fails on splitting the xpath under evaluate #4135

Open rimmartin opened 1 year ago

rimmartin commented 1 year ago

The generated antlr code in https://github.com/antlr/antlr4/tree/master/runtime/Cpp/runtime/src/tree/xpath from https://github.com/antlr/antlr4/blob/master/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.g4 breaks in https://github.com/antlr/antlr4/blob/master/runtime/Cpp/runtime/src/tree/xpath/XPath.cpp#L30 before the fill https://github.com/antlr/antlr4/blob/master/runtime/Cpp/runtime/src/tree/xpath/XPath.cpp#L38

Perhaps it needs regenerated as it is 10 months old and may no longer be compatible with v4.12?

rimmartin commented 1 year ago

Yea, in directory antlr4/runtime/Cpp ran

export JAVA_HOME=/home/roger/jdk-15.0.2
export PATH=$JAVA_HOME/bin:$PATH

java -Duser.dir=`pwd`/runtime/src/tree/xpath -cp /home/roger/Software/antlr4-dev5/tool/target/antlr4-4.12.1-SNAPSHOT-complete.jar org.antlr.v4.Tool -Dlanguage=Cpp -o `pwd`/runtime/src/tree/xpath ./XPathLexer.g4

and my code that relies on the XPath is now happy.

If you have a quick script to run to do the same, okay. If noone gets to it I can make a pull request

kaby76 commented 1 year ago

Not only Cpp, but for each of the runtimes, the file should be generated with a build of the runtime.

pushd runtime/CSharp/src/Tree/Xpath
antlr4 -Dlanguage=CSharp *.g4
popd

pushd runtime/Cpp/runtime/src/Tree/xpath
antlr4 -Dlanguage=Cpp *.g4
popd

# no XPath for Dart
# no XPath for Go

pushd runtime/Java/src/org/antlr/v4/runtime/tree/xpath
antlr4 -Dlanguage=Java *.g4
popd

# no XPath for JavaScript/TypeScript

pushd runtime/Python2/src/antlr4/xpath
antlr4 -Dlanguage=Python2 *.g4
popd

pushd runtime/Python3/src/antlr4/xpath
antlr4 -Dlanguage=Python3 *.g4
popd

# no XPath for Swift
# no XPath for PHP

The problem is that the generated files are checked in. They should not for exactly that reason: they are generated. Would people check in .obj's, .o's, .dll's, .so's, etc?