-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sync documents of godel-script project
- Loading branch information
1 parent
952b99c
commit f82f3f8
Showing
11 changed files
with
1,418 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# GödelScript | ||
|
||
## Content | ||
|
||
* 简介 | [Introduction](#introduction) | ||
* 文档 | [Documents](#documents) | ||
* 编译 | [Compilation](#compilation) | ||
* 用法 | [Usage](#usage) | ||
|
||
## Introduction | ||
|
||
GödelScript is designed for creating code analysis libraries and programs, | ||
and compiling them to soufflé more easily. With it's Object-Oriented features, | ||
it has great maintainability and readability. | ||
|
||
```rust | ||
@output | ||
pub fn hello() -> string { | ||
return "Hello World!" | ||
} | ||
``` | ||
|
||
## Documents | ||
|
||
* GödelScript Language Reference | ||
* GödelScript [Program](./docs/language-reference/program.md) | ||
* GödelScript [Type](./docs/language-reference/type.md) | ||
* GödelScript [Schema](./docs/language-reference/schemas.md) | ||
* GödelScript [Database](./docs/language-reference/databases.md) | ||
* GödelScript [Enum](./docs/language-reference/enums.md) | ||
* GödelScript [Impl](./docs/language-reference/impl.md) | ||
* GödelScript [Function](./docs/language-reference/functions.md) | ||
* GödelScript [Import](./docs/language-reference/import.md) | ||
* GödelScript [Query](./docs/language-reference/queries.md) | ||
* GödelScript [Statement](./docs/language-reference/functions.md#statement) | ||
* GödelScript [Expression](./docs/language-reference/functions.md#expression) | ||
* GödelScript [Query Example](./example) | ||
* GödelScript [Syntax Definition](./docs/syntax.md) | ||
|
||
## Compilation | ||
|
||
Structure of this project: | ||
|
||
``` | ||
. | ||
|-- dockerFile | ||
|-- docs godel-script documents | ||
|-- godel-backend godel-script backend | ||
| |-- extension godel-script souffle extension | ||
| |-- souffle souffle source code | ||
| +-- tools souffle build tools | ||
+-- godel-frontend godel-script frontend | ||
+-- src godel-frontend source code | ||
``` | ||
|
||
Need C++ standard at least `-std=c++17`. | ||
|
||
### Build Godel Script | ||
|
||
Use command below: | ||
|
||
```bash | ||
mkdir build | ||
cd build | ||
cmake .. | ||
make -j | ||
``` | ||
|
||
After building, you'll find `build/godel` in the `build` folder. | ||
|
||
## Usage | ||
|
||
Use this command for help: | ||
|
||
> ./build/godel -h | ||
### Compile Target Soufflé | ||
|
||
> ./build/godel -p {godel library directory} {input file} -s {soufflé output file} -Of | ||
`-Of` is an optimization for join order, we suggest to switch it on. | ||
|
||
### Directly Run Soufflé | ||
|
||
> ./build/godel -p {godel library directory} {input file} -r -Of -f {database directory} | ||
`-Of` is an optimization for join order, we suggest to switch it on. | ||
|
||
`-r` means directly run soufflé. | ||
|
||
`-v` could be used for getting verbose info. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# GödelScript Database | ||
|
||
Back to [README.md](../../README.md#documents) | ||
|
||
## Declaration | ||
|
||
```rust | ||
database School { | ||
student: *Student, | ||
classes: *Class as "class" | ||
... | ||
} | ||
``` | ||
|
||
Tables in databases should be set type, which uses `*` before the type name. | ||
And the table type must be `schema`. | ||
And for table name `student`, when running soufflé directly, we read sqlite database | ||
using the same table name. | ||
|
||
If the table name conflicts with a keyword, try using `as "real_table"`, and | ||
GödelScript will find the data from sqlite table `real_table`. | ||
|
||
## Initializing | ||
|
||
Database has a native method `fn load(dbname: string) -> Self`. | ||
The argument string must be a string literal. | ||
|
||
```rust | ||
fn default_db() -> School { | ||
return School::load("example_db_school.db") // must use string literal | ||
} | ||
``` | ||
|
||
Then GödelScript will give you the input database. | ||
|
||
## Get Schema From Database | ||
|
||
It's quite easy to fetch schema data from database. | ||
For example in `Student::__all__(db: School) -> *School`, | ||
we could fetch the data by directly using `db.student`. | ||
|
||
```rust | ||
impl Student { | ||
pub fn __all__(db: School) -> *Student { | ||
return db.student | ||
} | ||
} | ||
``` | ||
|
||
Back to [README.md](../../README.md#documents) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# GödelScript Enum | ||
|
||
Back to [README.md](../../README.md#documents) | ||
|
||
## Declaration | ||
|
||
```rust | ||
enum Status { | ||
exited, // 0 | ||
running, // 1 | ||
suspend // 2 | ||
} | ||
``` | ||
|
||
Usage: | ||
|
||
```rust | ||
fn example() -> Status { | ||
Status::exited | ||
Status::running | ||
Status::suspend | ||
} | ||
``` | ||
|
||
Back to [README.md](../../README.md#documents) |
Oops, something went wrong.