Closed markcanary closed 1 year ago
Sorry, but the install script that I give on the instructions gives a trprint with an older version that isn't compatible with the newer version of trparse/trconvert. For now, just type trparse NCalc.g3 | trconvert | trtext
. Make sure trparse, trconvert, and trtext are all using the 0.20.17 version.
trparse --version
trconvert --version
trtext --version
trprint --version
I'll update the instructions to make sure the install is correct. So, try this for now.
dotnet tool uninstall -g trparse
dotnet tool uninstall -g trtext
dotnet tool uninstall -g trconvert
dotnet tool uninstall -g trprint
dotnet tool install -g trparse --version 0.20.17
dotnet tool install -g trtext --version 0.20.17
dotnet tool install -g trconvert --version 0.20.17
Note, trconvert brings the grammar over to Antlr4 syntactically. The output of trconvert is a tree, but that tree isn't really an Antlr4 parse of the grammar, and it isn't anymore an Antlr3 parse tree because trconvert mucks around with it. To work with it further, you'll need to re-parse the saved file text as NCalc.g4 (an Antlr4 file). I think the grammar may need to be hand-patched: replace "( :
" with just "(
". I'm not sure if the Antlr4 grammar needs to be updated or whether I need to remove that extra colon in trconvert.
You may want to strip out all the actions if that's unnecessary for parsing. Although I have started to update trstrip, it's not working for this grammar.
You are correct that trprint was not version 0.20.17, but the rest were.
I used trtext instead of trprint as you suggested. trparse NCalc.g3 | trconvert | trtext > NCalc.g4
This gave me an output file.
To work with it further, you'll need to re-parse the saved file text as NCalc.g4 (an Antlr4 file).
I don't know what this means. Are you saying I need to run the output file from trprint (NCalc.g4) through trparse again?
To work with it further, you'll need to re-parse the saved file text as NCalc.g4 (an Antlr4 file).
I don't know what this means. Are you saying I need to run the output file from trprint (NCalc.g4) through trparse again?
I'm just saying that if you wanted to edit or query the code further using a Trash tool, it would be best to parse it over as an Antlr4 grammar. trparse NCalc.g3 | trconvert | trtree
outputs a modified Antlr3 parse tree. trparse NCalc.g4 | trtree
, after you fix the colon problems, outputs an Antlr4 parse tree. So, if you wanted to use some scripts to work with Antlr4 grammars, it expects the tree to be really Antlr4 parse tees.
I'm still working out some nice scripts, but you can see some in my blog, http://codinggorilla.com/.
Thanks for the help. I was able to convert the file using your tools and some hand editing.
I am trying to convert a grammar file for the NCalc Async library from ANTLR3 to ANTLR4 so I can switch NCalc Async to use the ANTLR4 library. I am not very familiar with ANTLR so I was hoping to use this utility to do the conversion. Does anyone know how I can get this to work? Below is the grammar file. I am using the following command line:
This produces the following exception:
NCalc.g3: