update Readme
This commit is contained in:
parent
097d95d382
commit
68d04deafc
32
README.md
32
README.md
@ -1,6 +1,6 @@
|
|||||||
# dt-sql-parser-semantic-analyse-plugin
|
# dt-sql-parser-semantic-analyse-plugin
|
||||||
|
|
||||||
A [dt-sql-parser](https://github.com/DTStack/dt-sql-parser) plugin with semantic result. [Theory](https://github.com/Kijin-Seija/dt-sql-parser-analyse-demo).
|
A [dt-sql-parser](https://github.com/DTStack/dt-sql-parser) plugin with semantic result. [Theory(zh-CN)](https://github.com/Kijin-Seija/dt-sql-parser-analyse-demo).
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@ -29,6 +29,10 @@ import { PostgreSQLParser } from 'dt-sql-parser/dist/lib/pgsql/PostgreSQLParser'
|
|||||||
const myPlugin = new DtSqlParserSemAnalysePlugin({
|
const myPlugin = new DtSqlParserSemAnalysePlugin({
|
||||||
parse: {
|
parse: {
|
||||||
parser: new PostgresSQL()
|
parser: new PostgresSQL()
|
||||||
|
alias: {
|
||||||
|
selectstmt: 'selectStatement',
|
||||||
|
target_el: 'target_label'
|
||||||
|
}
|
||||||
stmts: [
|
stmts: [
|
||||||
'selectstmt'
|
'selectstmt'
|
||||||
],
|
],
|
||||||
@ -51,6 +55,32 @@ console.log(result)
|
|||||||
|
|
||||||
**Notice: A rule must start with a/an statement/entity and stop with an entity. You should add a node keywords(keyword is in your parser with format: `RULE_[keyword]`) into stmts/entities before using it.**
|
**Notice: A rule must start with a/an statement/entity and stop with an entity. You should add a node keywords(keyword is in your parser with format: `RULE_[keyword]`) into stmts/entities before using it.**
|
||||||
|
|
||||||
|
## Rule Chain Opeator
|
||||||
|
|
||||||
|
You can set a negative number whose abs equals to a ruleIndex. That means exclude this rule.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
select_target_alias: [
|
||||||
|
PostgreSqlParser.RULE_target_el,
|
||||||
|
-PostgreSqlParser.RULE_attr_name,
|
||||||
|
PostgreSqlParser.RULE_collabel
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
🚧 I will later work on `Operator.AND` and `Operator.OR`.
|
||||||
|
|
||||||
|
## Alias
|
||||||
|
|
||||||
|
Some node names in dt-sql-parser code are different from its antlr4's definition.
|
||||||
|
|
||||||
|
You can find possible alias in https://github.com/DTStack/dt-sql-parser/blob/main/src/grammar/postgresql/PostgreSqlParser.g4, then add it into `alias` option.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
![alt text](./assets/alias-example.png)
|
||||||
|
|
||||||
|
|
||||||
## Add a preprocessor
|
## Add a preprocessor
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
|
BIN
assets/alias-example.png
Normal file
BIN
assets/alias-example.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
Loading…
Reference in New Issue
Block a user