You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs-ch/Parser Module Development Guide.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -245,8 +245,9 @@ The comment in `p_delete` corresponds to the syntax rule for the `DELETE` statem
245
245
Once the grammar rules are written, they can be used to parse SQL statements. Taking `mysql_parser` as an example, you can use this grammar rule for parsing SQL statements.
246
246
247
247
```python
248
-
from src.parser.mysql_parser.parser import parser as mysql_parser
249
-
from src.parser.mysql_parser.lexer import lexer as mysql_lexer
248
+
from sqlgpt_parser.parser.mysql_parser.parser import parser as mysql_parser
249
+
from sqlgpt_parser.parser.mysql_parser.lexer import lexer as mysql_lexer
250
+
250
251
sql ="DELETE FROM t WHERE a=1"
251
252
result = mysql_parser.parse(sql, lexer=mysql_lexer)
Copy file name to clipboardExpand all lines: docs/docs-en/SQL Parser Development Guide.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
The `parser` module is the foundational module of `sqlgpt-parser`. It parses SQL statements according to predefined SQL grammar rules, converting them from text into an abstract syntax tree (`AST`).
4
4
5
-
The `parser` module in `sqlgpt-parser` is written using [PLY](https://github.com/dabeaz/ply). PLY is a Python tool for building lexical and parsing analyzers. It can analyze input text based on specified patterns and automatically compile the lexical and grammar rule files in the [sql-parser](../../src/sql_parser/) folder of the project before the program runs, generating executable code.
5
+
The `parser` module in `sqlgpt-parser` is written using [PLY](https://github.com/dabeaz/ply). PLY is a Python tool for building lexical and parsing analyzers. It can analyze input text based on specified patterns and automatically compile the lexical and grammar rule files in the [sql-parser](../../sqlgpt_parser/sql_parser/) folder of the project before the program runs, generating executable code.
6
6
7
7
## Lexical Analysis and Syntax Analysis
8
8
@@ -158,7 +158,7 @@ PLY uses the notation `p[position]` to access the stack, where `p[0]` correspond
158
158
159
159
## Implementation of the `parser` for `sqlgpt-parser`
160
160
161
-
There are a total of three SQL parsers in `sqlgpt-parser`, located in the [mysql_parser](../../src/sql_parser/mysql_parser), [oceanbase_parser](../../src/sql_parser/oceanbase_parser), and [odps_parser](../../src/sql_parser/odps_parser) folders. Each of these folders contains three files: `lexer.py`, `reserved.py`, and `parser.py`.
161
+
There are a total of three SQL parsers in `sqlgpt-parser`, located in the [mysql_parser](../../sqlgpt_parser/sql_parser/mysql_parser), [oceanbase_parser](../../sqlgpt_parser/sql_parser/oceanbase_parser), and [odps_parser](../../sqlgpt_parser/sql_parser/odps_parser) folders. Each of these folders contains three files: `lexer.py`, `reserved.py`, and `parser.py`.
162
162
163
163
The `lexer.py` and `reserved.py` files are both used for lexical analysis. In `reserved.py`, SQL keywords are defined and stored in two variables: `reserved` and `nonreserved`. The `reserved` variable contains all the keywords that cannot be used as column names, table names, or aliases in SQL. On the other hand, `nonreserved` contains keywords that can be used as column names, table names, or aliases.
164
164
@@ -245,7 +245,8 @@ The comment in `p_delete` corresponds to the syntax rule for the `DELETE` statem
245
245
Once the grammar rules are written, they can be used to parse SQL statements. Taking `mysql_parser` as an example, you can use this grammar rule for parsing SQL statements.
246
246
247
247
```python
248
-
from src.sql_parser.mysql_parser import parser as mysql_parser
248
+
from sqlgpt_parser.sql_parser.mysql_parser import parser as mysql_parser
0 commit comments