|
|
|||||||||||||||||||
|
|
Parsing SQL with ProGrammar
The ProGrammar ActiveX control makes it easy to parse SQL
statements from Visual Basic, Visual C++, Delphi, and other
Windows-based applications.
The following example shows how to parse SQL from
a Visual Basic program. While this example is
intentionally very simple, it demonstrates the main steps
involved in using ProGrammar in your applications.
The first step is to initialize the ProGrammar ActiveX control:
The next step is loading the SQL grammar. The grammar is stored
as a binary file named "SQL.GMR", which was generated by the
ProGrammar IDE when the
The following SQL grammars are currently available:
Next, the program sets the SQL text that will be parsed. The parser
can load the text from a file or parse it directly from a memory
buffer. In this example, the SQL text is contained in a file
named "myfile.sql".
The program then parses the file and checks for parse errors.
When the Parse method
is called, ProGrammar parses the input text using the SQL grammar and
builds a parse tree data structure in memory.
The program then calls ActiveX methods to retrieve relevant data
items from the parse tree.
In this example, the program creates a list of all tables that
are referenced by name in the SQL statements. In the SQL grammar definition,
a table name is represented by a symbol named "table".
Therefore, each reference to a table in the input text will have a
corresponding node in the parse tree labeled "table", whose value is the name of the table.
|
||||||||||||||||||
|
For comments or questions about this site, please contact webmaster@programmar.com Copyright © 1998-2008 NorKen Technologies, Inc. All rights reserved. |
|||||||||||||||||||