1

I use SqlParser class provided by SqlServer to parse the AST of a sql script, like I answered in this post: https://stackoverflow.com/a/34103965/3828013.

its output is a xml document like below. But I have searched a lot, and can not find any related document. Anyone knows can give me the link.

<?xml version="1.0" encoding="utf-8"?>
<SqlScript Location="((1,1), (92,1))">
  <Errors />
  <SqlBatch Location="((91,3), (92,1))">
    <!--
-->
    <Tokens>
      <Token location="((91,3), (92,1))" id="651" type="LEX_WHITE">\n</Token>
    </Tokens>
  </SqlBatch>
</SqlScript>
Community
  • 1
  • 1
BartMao
  • 651
  • 7
  • 21

1 Answers1

1

You can find the SQL Abstract Syntax Trees Vocabulary

Abstract syntax trees allow to build structured representations of code for any language with a grammar: AST nodes carrying labels can stand for keywords, objects, variables, constants or any language element while the tree structure allows to abstract away the language's concepts of scope or dependency. ASTs are a machine-readable format for concrete syntax code, and can be decorated with implicit or contextual knowledge from the grammar. We hereby propose to model ASTs with RDF graphs. AST structures naturally fit RDF graphs: nodes map resources, node labels map resources' types, and grammar knowledge map to vocabulary's semantics, e.g. with subsumption.

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
  • Appreciate your help. While seems that doc is for standard SQL. Is there any doc for MSSQL? Because I compared my generated AST xml to the doc you gave, still many differences. – BartMao Dec 17 '15 at 09:06
  • @BartMao:- I dont think there is any official document by MSDN on Abstract syntax tree. – Rahul Tripathi Dec 17 '15 at 09:07