Skip to content

Commit fbb763e

Browse files
committed
Document context files and the way they work
Signed-off-by: William Desportes <williamdes@wdes.fr>
1 parent cddd0f1 commit fbb763e

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/Tools/ContextGenerator.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,16 @@ public static function buildAll($input, $output)
398398

399399
foreach ($files as $file) {
400400
// Skipping current and parent directories.
401+
// Skipping _functions* and _common.txt files
401402
if (($file[0] === '.') || ($file[0] === '_')) {
402403
continue;
403404
}
404405

406+
// Skipping README.md
407+
if ($file === 'README.md') {
408+
continue;
409+
}
410+
405411
// Building the context.
406412
echo sprintf("Building context for %s...\n", $file);
407413
static::build($input . '/' . $file, $output);

tools/contexts/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Context files
2+
3+
This files are used to generate `src/Contexts/*.php` files.
4+
You need to run `./tools/run_generators.sh` to generate/update them.
5+
The file `src/Tools/ContextGenerator.php` is responsible for building them.
6+
And the generated files are loaded and used by `src/Context.php`.
7+
8+
## Default contexts
9+
10+
- For MySQL: MySql50700
11+
- For MariaDB: MariaDb100300
12+
13+
### In tests
14+
15+
If you name your data files with `_mariadb_` it will automatically load the context for you.
16+
For example: `tests/data/parser/parseSelectOverAlias_mariadb_100600.in`.
17+
18+
## Files structure
19+
20+
The file `tools/contexts/_common.txt` contains all the data
21+
that exists in all of the MariaDB and MySQL versions currently supported.
22+
23+
Each `tools/contexts/_functions[MariaDb|MySql]<versionint>.txt` contains the functions supported in this version.
24+
25+
Each `tools/contexts/[MariaDb|MySql]<versionint>.txt` contains the keywords supported in this version.
26+
27+
## Data scheme
28+
29+
- `(R)` -> reserved, can be found on common and version files
30+
- `(D)` -> data type, can be found on `_common.txt`
31+
- `(K)` -> keyword, can be found on common and version files
32+
- `(F)` -> function name, can be found on `_functions[MariaDb|MySql]<versionint>.txt` files

0 commit comments

Comments
 (0)