PostgreSQLParser
所属分类:collect
开发工具:Smalltalk
文件大小:0KB
下载次数:0
上传日期:2021-03-18 17:37:01
上 传 者:
sh-1993
说明: 使用PetitParser.,用Pharo编写的PostgreSQL解析器。,
(A parser for PostgreSQL written in Pharo using PetitParser.,)
文件列表:
.project (27, 2021-03-18)
.smalltalk.ston (606, 2021-03-18)
.travis.yml (195, 2021-03-18)
LICENSE (1074, 2021-03-18)
ressources/ (0, 2021-03-18)
ressources/dependencies.png (222584, 2021-03-18)
ressources/visitor_methods_generator.png (129907, 2021-03-18)
src/ (0, 2021-03-18)
src/.properties (21, 2021-03-18)
src/BaselineOfPostgreSQLParser/ (0, 2021-03-18)
src/BaselineOfPostgreSQLParser/BaselineOfPostgreSQLParser.class.st (3602, 2021-03-18)
src/BaselineOfPostgreSQLParser/package.st (48, 2021-03-18)
src/PostgreSQL-AST-Builder-SmokeTests/ (0, 2021-03-18)
src/PostgreSQL-AST-Builder-SmokeTests/PSQLASTBuilderDeleteSmokeTest.class.st (353, 2021-03-18)
src/PostgreSQL-AST-Builder-SmokeTests/PSQLASTBuilderInsertSmokeTest.class.st (353, 2021-03-18)
src/PostgreSQL-AST-Builder-SmokeTests/PSQLASTBuilderPLpgSQLBodySmokeTest.class.st (364, 2021-03-18)
src/PostgreSQL-AST-Builder-SmokeTests/PSQLASTBuilderSelectSmokeTest.class.st (353, 2021-03-18)
src/PostgreSQL-AST-Builder-SmokeTests/PSQLASTBuilderUpdateSmokeTest.class.st (353, 2021-03-18)
src/PostgreSQL-AST-Builder-SmokeTests/PSQLTASTBuilderSanityChecker.trait.st (1634, 2021-03-18)
src/PostgreSQL-AST-Builder-SmokeTests/package.st (57, 2021-03-18)
src/PostgreSQL-AST-Builder-Tests/ (0, 2021-03-18)
src/PostgreSQL-AST-Builder-Tests/PSQLDeleteQueryASTBuilderTest.class.st (3066, 2021-03-18)
src/PostgreSQL-AST-Builder-Tests/PSQLExpressionASTBuilderTest.class.st (5173, 2021-03-18)
src/PostgreSQL-AST-Builder-Tests/PSQLFromClauseASTBuilderTest.class.st (7143, 2021-03-18)
src/PostgreSQL-AST-Builder-Tests/PSQLInsertQueryASTBuilderTest.class.st (3391, 2021-03-18)
src/PostgreSQL-AST-Builder-Tests/PSQLPlpgSQLASTBuilderTest.class.st (26034, 2021-03-18)
src/PostgreSQL-AST-Builder-Tests/PSQLSelectQueryASTBuilderTest.class.st (11935, 2021-03-18)
src/PostgreSQL-AST-Builder-Tests/PSQLSharedASTBuilderTest.class.st (5982, 2021-03-18)
src/PostgreSQL-AST-Builder-Tests/PSQLTokenASTBuilderTest.class.st (2689, 2021-03-18)
src/PostgreSQL-AST-Builder-Tests/PSQLUpdateQueryASTBuilderTest.class.st (1628, 2021-03-18)
src/PostgreSQL-AST-Builder-Tests/PSQLValuesASTBuilderTest.class.st (878, 2021-03-18)
src/PostgreSQL-AST-Builder-Tests/package.st (52, 2021-03-18)
src/PostgreSQL-AST-Builder/ (0, 2021-03-18)
src/PostgreSQL-AST-Builder/PPParser.extension.st (370, 2021-03-18)
src/PostgreSQL-AST-Builder/PSQLCRUDQueryASTBuilder.class.st (686, 2021-03-18)
src/PostgreSQL-AST-Builder/PSQLDeleteQueryASTBuilder.class.st (1378, 2021-03-18)
src/PostgreSQL-AST-Builder/PSQLExpressionASTBuilder.class.st (9846, 2021-03-18)
src/PostgreSQL-AST-Builder/PSQLFromClauseASTBuilder.class.st (5365, 2021-03-18)
src/PostgreSQL-AST-Builder/PSQLInsertQueryASTBuilder.class.st (2058, 2021-03-18)
... ...
# PostgreSQLParser [![Build Status](https://travis-ci.com/juliendelplanque/PostgreSQLParser.svg?branch=master)](https://travis-ci.com/juliendelplanque/PostgreSQLParser)
A parser for PostgreSQL written in Pharo using PetitParser.
For now, the focus is made on PL/pgSQL source code.
- [Install](#install)
- [Groups](#groups)
- [Use it as a dependency](#use-it-as-a-dependency)
- [Usage](#usage)
## Install
```
Metacello new
baseline: 'PostgreSQLParser';
repository: 'github://juliendelplanque/PostgreSQLParser/src';
load
```
### Groups
You can use the groups defined in the baseline to install only what you need. The following groups are available:
- `parser` : Only the tokenizer and the grammar.
- `parser-tests` : `parser` and its unit tests.
- `ast` : Only the Abstract Syntactic Tree model.
- `ast-builder` : `ast` + the object that builds the AST from the source code (also requires `parser`).
- `ast-builder-tests` : `ast-builder` + its unit tests.
- `visitors` : `ast` + default visitors of the AST.
- `core` : `parser` + `ast` + `ast-builder`.
- `core-tests` : `core` + all unit tests associated.
- `future` : Experimental code of this project, do not use this in production.
- `dev` : Everything you need to help in this project development loads `future` group as well.
Let's say you only need the `ast` group, the following code will load this specific group:
```
Metacello new
baseline: 'PostgreSQLParser';
repository: 'github://juliendelplanque/PostgreSQLParser/src';
load: 'ast'
```
### Use it as a dependency
To use this project as a dependency, add the following code in your baseline:
```
[...]
spec baseline: 'PostgreSQLParser' with: [
spec
repository: 'github://juliendelplanque/PostgreSQLParser/src' ]
[...]
```
# Usage
The complexity of the parsing process is hidden (for users) behind a [facade](https://en.wikipedia.org/wiki/Facade_pattern): `PostgreSQLParser` class. The class-side methods provide a simple API to parse SQL code and get an AST as return.
For example:
```
ast := PostgreSQLParser parseSelectQuery: 'SELECT person.id, person.name, person.city_id
FROM person, city
WHERE person.city_id = city.id
LIMIT 10'. "Mind that there is not trailing ';' because this is part of statement's grammar not query grammar."
"... process the AST... "
```
There other methods work similarly:
- `PostgreSQLParser class>>#parseUpdateQuery:`
- `PostgreSQLParser class>>#parseCRUDQuery:`
- `PostgreSQLParser class>>#parseDeleteQuery:`
- `PostgreSQLParser class>>#parseInsertQuery:`
- `PostgreSQLParser class>>#parseSelectQuery:`
- `PostgreSQLParser class>>#parseStoredProcedureBody:`
近期下载者:
相关文件:
收藏者: