Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Grammar describing SQL grammar in Books Online

$
0
0

I hope that the subject line does not confuse you. I am writing a parser, but I do not want to parse

CREATE TABLE mydb.myschema.t1(f1 int).

I want to parse the grammar used by Books Online to describe SQL statements, so I need a grammar that describes the SQL grammar, and not a grammar for SQL.  Such a grammar would look something like this:

<rule> ::= <rule_name> '::=' <expression>
<expression> :: <list> | <list> '|' <expression>
<list> :: <term> | <list> <term>
<term> ::= <literal> | <rule_name>
<rule_name> := '<' <alpha_sequence> '>'
/* plus rules for optional items, repeating items, etc. */

Using such a grammar, I could then parse something like:

<create_table_stmt> ::= 

CREATE TABLE     [ database_name . [ schema_name ] . | schema_name . ] table_name     [ AS FileTable ]    ( { <column_definition> | <computed_column_definition>         | <column_set_definition> | [ <table_constraint> ] [ ,...n ] } ) [ ON { partition_scheme_name ( partition_column_name ) | filegroup | "default" } ] [ { TEXTIMAGE_ON { filegroup | "default" } ] [ FILESTREAM_ON { partition_scheme_name | filegroup | "default" } ] [ WITH ( <table_option> [ ,...n ] ) ] [ ; ]

Does such a grammar exist?


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>