Hi,
When VS2022 opens the project file it upgrades the project to the latest Windows SDK version (10.0) and Platform Toolset (v143). After a lot of perseverance and diagnosis I discovered that a number of source files were included in the solution which are no longer included in the source code zip (no icon in Solution Explorer) so I removed them from the project.
I then discovered that a number of source files in the zip master were NOT included in the VS project file and added them. Specifically:
src\atn\PredictionContextCache.cpp
src\atn\PredictionContextMergeCache.cpp
src\misc\MurmurHash.cpp
src\support\Utf8.cpp
src\atn\PredictionContextCache.h
src\atn\PredictionContextMergeCache.h
src\support\Utf8.h
When I added them and compiled/linked the build ran successfully, albeit with a number of warnings.
I've attached my corrected version of the project file. It will work without adjustment on the current version of VS2022. On VS2019 or non-latest VS2022 you will need to correct the Windows SDK version and Platform Toolset versions in the build settings property pages.
You can use a differ to compare my version of the project file with the one in the downloaded zip to see what was removed / added to make to build successfully.
So, in theory, I should be 'all systems go'. However, I am now finding that the C++ code generated by antlr-4.10.1-complete.jar for the TSQL grammar files from
https://github.com/teverett/grammars-v4/tree/master/sql/tsql do not compile for me in VS2022, with hundreds of errors, which look syntactical. Specifically:
Code Description Number of errors
==== =========== ================
"C1003" "error count exceeds 100; stopping compilation" 5
"C2039" "'Constant_LOCAL_IDContext': is not a member of 'TSqlParser'" 355
"C2039" "'Entity_name_for_azure_dwContext': is not a member of 'TSqlParser'" 355
"C2039" "'Entity_name_for_parallel_dwContext': is not a member of 'TSqlParser'" 355
"C2039" "'Entity_nameContext': is not a member of 'TSqlParser'" 355
"C2039" "'Id_Context': is not a member of 'TSqlParser'" 355
"C2039" "'Sql_clausesContext': is not a member of 'TSqlParser'" 355
"C2059" "syntax error: ')'" 15
"C2059" "syntax error: 'constant'" 15
"C2086" "'int *input': redefinition" 5
"C2143" "syntax error: missing ')' before '*'" 35
"C2143" "syntax error: missing ';' before '&'" 35
"C2143" "syntax error: missing ';' before '*'" 35
"C2143" "syntax error: missing ';' before '}'" 35
"C2143" "syntax error: missing '}' before 'constant'" 35
"C2178" "'antlr4::TokenStream' cannot be declared with 'explicit' specifier" 5
"C2238" "unexpected token(s) preceding ';'" 5
"C2259" "'TSqlParser': cannot instantiate abstract class" 10
"C2270" "'getATN': modifiers not allowed on nonmember functions" 25
"C2270" "'getGrammarFileName': modifiers not allowed on nonmember functions" 25
"C2270" "'getRuleNames': modifiers not allowed on nonmember functions" 25
"C2270" "'getSerializedATN': modifiers not allowed on nonmember functions" 25
"C2270" "'getVocabulary': modifiers not allowed on nonmember functions" 25
"C2280" "'TSqlParser::TSqlParser(void)': attempting to reference a deleted function" 5
"C2530" "'options': references must be initialized" 5
"C2575" "'TSqlParser': only member functions and bases can be virtual" 5
"C2588" "'::~TSqlParser': illegal global destructor" 5
"C3158" "'getATN': 'override' can only be applied to a virtual member function" 30
"C3158" "'getGrammarFileName': 'override' can only be applied to a virtual member function" 30
"C3158" "'getRuleNames': 'override' can only be applied to a virtual member function" 30
"C3158" "'getSerializedATN': 'override' can only be applied to a virtual member function" 30
"C3158" "'getVocabulary': 'override' can only be applied to a virtual member function" 30
"C3158" "'TSqlParser': 'override' can only be applied to a virtual member function" 30
"C4430" "missing type specifier - int assumed. Note: C++ does not support default-int" 25
"E0020" "identifier ""_ctx"" is undefined" 116
"E0020" "identifier ""_input"" is undefined" 116
"E0020" "identifier ""_localctx"" is undefined" 116
"E0020" "identifier ""Begin_conversation_dialogContext"" is undefined" 116
"E0020" "identifier ""Column_name_listContext"" is undefined" 116
"E0020" "identifier ""CONCAT_WSContext"" is undefined" 116
"E0020" "identifier ""End_conversationContext"" is undefined" 116
"E0020" "identifier ""Entity_nameContext"" is undefined" 116
"E0020" "identifier ""Exist_methodContext"" is undefined" 116
"E0020" "identifier ""Expression_listContext"" is undefined" 116
"E0020" "identifier ""File_specContext"" is undefined" 116
"E0020" "identifier ""Full_column_nameContext"" is undefined" 116
"E0020" "identifier ""Full_table_nameContext"" is undefined" 116
"E0020" "identifier ""Func_proc_name_database_schemaContext"" is undefined" 116
"E0020" "identifier ""Func_proc_name_schemaContext"" is undefined" 116
"E0020" "identifier ""Func_proc_name_server_database_schemaContext"" is undefined" 116
"E0020" "identifier ""Get_conversationContext"" is undefined" 116
"E0020" "identifier ""getInterpreter"" is undefined" 116
"E0020" "identifier ""Hierarchyid_callContext"" is undefined" 116
"E0020" "identifier ""Modify_methodContext"" is undefined" 116
"E0020" "identifier ""Nodes_methodContext"" is undefined" 116
"E0020" "identifier ""Query_methodContext"" is undefined" 116
"E0020" "identifier ""Send_conversationContext"" is undefined" 116
"E0020" "identifier ""Simple_nameContext"" is undefined" 116
"E0020" "identifier ""Table_nameContext"" is undefined" 116
"E0020" "identifier ""TRIMContext"" is undefined" 116
"E0020" "identifier ""Value_callContext"" is undefined" 116
"E0020" "identifier ""Value_methodContext"" is undefined" 116
"E0029" "expected an expression" 38
"E0040" "expected an identifier" 9
"E0065" "expected a ';'" 83
"E0077" "this declaration has no storage class or type specifier" 287
"E0169" "expected a declaration" 407
"E0254" "type name is not allowed" 3
"E0260" "explicit type is missing ('int' assumed)" 14
I am currently, very reluctantly, considering whether it's worth the time to continue further with Antlr. It may indeed be that I am too stoopid to use it, but I have invested several days in trying to work through all this. Antlr does look perfect for what I'm hoping to achieve. Also, it was great that someone appears to have already done the heavy lifting on TSQL grammar files for Antlr, which is the specific language I'm hoping to work with.
But.... the above looks to be a bit of a brick wall for me. (I'm not 100% clear on this but am wondering whether the C++ that antlr-4.10.1-complete.jar generates from the language files is not compatible with Microsoft's version of C++ (though they do claim to be conformant among the various build options available)).
I'd be really happy if anyone can help get me over the line on this, though I realise it's asking a lot!
Sorry this post is so long, and I hope the attached VS2022 project file is of some help to anyone!
Pete