@@ -56,7 +56,7 @@ Add the option ``--backend=mssql-freetds`` to the test command to run the tests
56
56
the ``freetds `` driver.
57
57
58
58
59
- Creating a grammar
59
+ Grammar
60
60
------------------
61
61
62
62
``pytsql `` relies on parsing the sql script at hand. In order to do so, it uses
@@ -66,7 +66,13 @@ and produces parsing Python code.
66
66
Additionally, code generated using ``speedy-antlr-tool `` package is used to parse SQL scripts
67
67
in C++ for better performance. The parsed tree is then converted into the Python equivalent.
68
68
69
- If you want to adapt the grammar please have a look at ``pytsql/src/pytsql/grammar/tsql.g4 ``.
69
+ ``pytsql ``'s Transact-SQL (TSQL) grammar is based on `antlr/grammars-v4 <https://github.com/antlr/grammars-v4/tree/master/sql/tsql >`_.
70
+ To keep the package structure lean, ``pytql `` aims to be in sync with the reference repository and generally does not maintain its own grammar.
71
+ Therefore, if you want to extend or modify the grammar please consider contributing to the external repository instead.
72
+
73
+ Update targets
74
+ ^^^^^^^^^^^^^^^^^
75
+
70
76
All files in ``pytsql/src/pytsql/grammar/cpp_src/antlr4-cpp-runtime `` are taken directly from
71
77
the `ANTLR repository release 4.11.1
72
78
<https://github.com/antlr/antlr4/tree/4.11.1/runtime/Cpp/runtime> `_
@@ -79,8 +85,11 @@ respective ``antlr`` jar file as follows:
79
85
80
86
::
81
87
82
- java -jar /usr/local/lib/antlr-4.9.2-complete.jar -Dlanguage=Cpp -visitor -no-listener -o cpp_src tsql.g4
83
- java -jar /usr/local/lib/antlr-4.9.2-complete.jar -Dlanguage=Python3 -no-visitor -no-listener -o . tsql.g4
88
+ java -jar /usr/local/lib/antlr-4.9.2-complete.jar -Dlanguage=Cpp -o cpp_src TSqlLexer.g4
89
+ java -jar /usr/local/lib/antlr-4.9.2-complete.jar -Dlanguage=Cpp -visitor -no-listener -o cpp_src TSqlParser.g4
90
+
91
+ java -jar /usr/local/lib/antlr-4.9.2-complete.jar -Dlanguage=Python3 -o . TSqlLexer.g4
92
+ java -jar /usr/local/lib/antlr-4.9.2-complete.jar -Dlanguage=Python3 -no-visitor -no-listener -o . TSqlParser.g4
84
93
85
94
And then running the ``speedy-antlr-tool `` in the same directory using Python
86
95
0 commit comments