Looking for Microsoft.SqlServer.TransactSql.ScriptDom grammar

Copper Contributor

Hi!

I'm looking for any info/contact for antlr grammar used by Microsoft.SqlServer.TransactSql.ScriptDom assembly

Looks like https://github.com/microsoft/ doesn't contains any useful info

 

5 Replies

@OleksiiKovalov 

 

ANTLR = ANother Tool for Language Recognition? Don't understand that.

 

ScriptDom is a "simple" parser for Transact-SQL, with the MS SQL Server specific SQL dialect.

No need to "recognite" anything, it's for T-SQL.

yes, ANother Tool for Language Recognition

Scriptdom is built using ANTLR (version/implementation is unknown to me) grammar.
And generated parser is very fast.

Now I'm working on a set of similar SQL parsers and I have some performance problems.
Some of the issues I've resolved by simplification, removing ambiguities, and extra LA in grammar/parser, but my implementation of SQL grammar still way too slow as compared to ScriptDOM parser.

I'm sure that I missed some simple, but important things when developing SQL grammar. I think it would be very useful to take a look/receive a consultation from developers of original ScriptDOM grammar.
Now I'm working on a set of similar SQL parsers 

Why re-inventing the wheel, use the existing MS SqlScriptDom.

@olafhelper 

Now I'm working on pl/sql and  pl/pgsql grammars, with MySQL in future plans.

For t-sql related tasks i'm using ScriptDOM, of course

 

While I can't access the specific ANTLR grammar used within the Microsoft.SqlServer.TransactSql.ScriptDom assembly, I can provide information based on available resources and general ANTLR usage:

Likely Grammar Location:

The grammar file likely resides within the assembly itself, but it's not directly accessible or editable.
Accessing Grammar Information:

Reflection: Use tools like ILSpy or dotPeek to inspect the assembly and potentially view generated parser/lexer classes, hinting at grammar structure.
Documentation: Consult official Microsoft documentation or community resources for insights.
Using the Assembly:

Scripting: The assembly primarily supports parsing and working with Transact-SQL scripts programmatically.
Grammar Exploration: To delve deeper into the grammar, consider using ANTLR to create a custom T-SQL parser from a publicly available grammar or crafting one yourself.
Additional Considerations:

Grammar Version: The specific grammar version employed within the assembly might vary.
Grammar Changes: Microsoft could update the grammar in future releases.
Recommendations:

Specific Needs: Clarify your goals for understanding the grammar. This will guide next steps.
Alternate Solutions: Explore alternative methods to achieve your objectives, such as using publicly available T-SQL grammars with ANTLR directly.
I'm ready to assist further based on your specific requirements.