Skip to content

Commit fee8b1c

Browse files
#1552 Split off parser and query DSL code from SCRIPT into separate addons
* Split off script parser into separate addon * Rename parser types and functions * Split off query DSL parser into separate addon * Add build tests for QUERY_DSL/PARSER addons
1 parent 42144f4 commit fee8b1c

File tree

42 files changed

+15910
-15568
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+15910
-15568
lines changed

distr/flecs.c

Lines changed: 15302 additions & 15240 deletions
Large diffs are not rendered by default.

distr/flecs.h

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,17 +191,19 @@
191191
// #define FLECS_C /**< C API convenience macros, always enabled */
192192
#define FLECS_CPP /**< C++ API */
193193
#define FLECS_DOC /**< Document entities & components */
194-
// #define FLECS_JOURNAL /**< Journaling addon (disabled by default) */
194+
// #define FLECS_JOURNAL /**< Journaling addon */
195195
#define FLECS_JSON /**< Parsing JSON to/from component values */
196196
#define FLECS_HTTP /**< Tiny HTTP server for connecting to remote UI */
197197
#define FLECS_LOG /**< When enabled ECS provides more detailed logs */
198198
#define FLECS_META /**< Reflection support */
199199
#define FLECS_METRICS /**< Expose component data as statistics */
200200
#define FLECS_MODULE /**< Module support */
201201
#define FLECS_OS_API_IMPL /**< Default implementation for OS API */
202-
// #define FLECS_PERF_TRACE /**< Enable performance tracing (disabled by default) */
202+
// #define FLECS_PERF_TRACE /**< Enable performance tracing */
203203
#define FLECS_PIPELINE /**< Pipeline support */
204204
#define FLECS_REST /**< REST API for querying application data */
205+
#define FLECS_PARSER /**< Utilities for script and query DSL parsers */
206+
#define FLECS_QUERY_DSL /**< Flecs query DSL parser */
205207
#define FLECS_SCRIPT /**< Flecs entity notation language */
206208
// #define FLECS_SCRIPT_MATH /**< Math functions for flecs script (may require linking with libm) */
207209
#define FLECS_SYSTEM /**< System support */
@@ -10473,6 +10475,12 @@ int ecs_value_move_ctor(
1047310475
#ifdef FLECS_NO_SCRIPT
1047410476
#undef FLECS_SCRIPT
1047510477
#endif
10478+
#ifdef FLECS_NO_PARSER
10479+
#undef FLECS_PARSER
10480+
#endif
10481+
#ifdef FLECS_NO_QUERY_DSL
10482+
#undef FLECS_QUERY_DSL
10483+
#endif
1047610484
#ifdef FLECS_NO_SCRIPT_MATH
1047710485
#undef FLECS_SCRIPT_MATH
1047810486
#endif
@@ -13535,8 +13543,12 @@ void FlecsAlertsImport(
1353513543
#define FLECS_META
1353613544
#endif
1353713545

13538-
#ifndef FLECS_SCRIPT
13539-
#define FLECS_SCRIPT
13546+
#ifndef FLECS_DOC
13547+
#define FLECS_DOC
13548+
#endif
13549+
13550+
#ifndef FLECS_QUERY_DSL
13551+
#define FLECS_QUERY_DSL /* For parsing component id expressions */
1354013552
#endif
1354113553

1354213554
#ifndef FLECS_JSON_H
@@ -14377,6 +14389,21 @@ void FlecsScriptMathImport(
1437714389

1437814390
#endif
1437914391

14392+
#ifdef FLECS_PARSER
14393+
#ifdef FLECS_NO_PARSER
14394+
#error "FLECS_NO_PARSER failed: PARSER is required by other addons"
14395+
#endif
14396+
#endif
14397+
14398+
#ifdef FLECS_QUERY_DSL
14399+
#ifdef FLECS_NO_QUERY_DSL
14400+
#error "FLECS_NO_QUERY_DSL failed: QUERY_DSL is required by other addons"
14401+
#endif
14402+
#ifndef FLECS_PARSER
14403+
#define FLECS_PARSER
14404+
#endif
14405+
#endif
14406+
1438014407
#ifdef FLECS_SCRIPT
1438114408
#ifdef FLECS_NO_SCRIPT
1438214409
#error "FLECS_NO_SCRIPT failed: SCRIPT is required by other addons"
@@ -14406,6 +14433,9 @@ void FlecsScriptMathImport(
1440614433
#define FLECS_DOC
1440714434
#endif
1440814435

14436+
#ifndef FLECS_PARSER
14437+
#define FLECS_PARSER
14438+
#endif
1440914439

1441014440
#ifndef FLECS_SCRIPT_H
1441114441
#define FLECS_SCRIPT_H

docs/Quickstart.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ Addon | Description | Define
119119
[Doc](/flecs/group__c__addons__doc.html) | Add documentation to components, systems & more | FLECS_DOC |
120120
[Http](/flecs/group__c__addons__http.html) | Tiny HTTP server for processing simple requests | FLECS_HTTP |
121121
[Rest](/flecs/group__c__addons__rest.html) | REST API for showing entities in the browser | FLECS_REST |
122-
[Script](/flecs/group__c__addons__script.html) | DSL for assets, scenes and configuration | FLECS_SCRIPT |
122+
Parser | Parser utilities used by script & query DSL | FLECS_PARSER |
123+
[Query DSL](https://www.flecs.dev/flecs/md_docs_2FlecsQueryLanguage.html) | Query DSL parser | FLECS_QUERY_DSL |
124+
[Script](/flecs/group__c__addons__script.html) | DSL for scenes, assets and configuration | FLECS_SCRIPT |
123125
[Stats](/flecs/group__c__addons__stats.html) | Functions for collecting statistics | FLECS_STATS |
124126
[Metrics](/flecs/group__c__addons__metrics.html) | Create metrics from user-defined components | FLECS_METRICS |
125127
[Alerts](/flecs/group__c__addons__alerts.html) | Create alerts from user-defined queries | FLECS_ALERTS |

include/flecs.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,17 +189,19 @@
189189
// #define FLECS_C /**< C API convenience macros, always enabled */
190190
#define FLECS_CPP /**< C++ API */
191191
#define FLECS_DOC /**< Document entities & components */
192-
// #define FLECS_JOURNAL /**< Journaling addon (disabled by default) */
192+
// #define FLECS_JOURNAL /**< Journaling addon */
193193
#define FLECS_JSON /**< Parsing JSON to/from component values */
194194
#define FLECS_HTTP /**< Tiny HTTP server for connecting to remote UI */
195195
#define FLECS_LOG /**< When enabled ECS provides more detailed logs */
196196
#define FLECS_META /**< Reflection support */
197197
#define FLECS_METRICS /**< Expose component data as statistics */
198198
#define FLECS_MODULE /**< Module support */
199199
#define FLECS_OS_API_IMPL /**< Default implementation for OS API */
200-
// #define FLECS_PERF_TRACE /**< Enable performance tracing (disabled by default) */
200+
// #define FLECS_PERF_TRACE /**< Enable performance tracing */
201201
#define FLECS_PIPELINE /**< Pipeline support */
202202
#define FLECS_REST /**< REST API for querying application data */
203+
#define FLECS_PARSER /**< Utilities for script and query DSL parsers */
204+
#define FLECS_QUERY_DSL /**< Flecs query DSL parser */
203205
#define FLECS_SCRIPT /**< Flecs entity notation language */
204206
// #define FLECS_SCRIPT_MATH /**< Math functions for flecs script (may require linking with libm) */
205207
#define FLECS_SYSTEM /**< System support */

include/flecs/addons/json.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@
1414
#define FLECS_META
1515
#endif
1616

17-
#ifndef FLECS_SCRIPT
18-
#define FLECS_SCRIPT
17+
#ifndef FLECS_DOC
18+
#define FLECS_DOC
19+
#endif
20+
21+
#ifndef FLECS_QUERY_DSL
22+
#define FLECS_QUERY_DSL /* For parsing component id expressions */
1923
#endif
2024

2125
#ifndef FLECS_JSON_H

include/flecs/addons/script.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#define FLECS_DOC
2424
#endif
2525

26+
#ifndef FLECS_PARSER
27+
#define FLECS_PARSER
28+
#endif
2629

2730
#ifndef FLECS_SCRIPT_H
2831
#define FLECS_SCRIPT_H

include/flecs/private/addons.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
#ifdef FLECS_NO_SCRIPT
1919
#undef FLECS_SCRIPT
2020
#endif
21+
#ifdef FLECS_NO_PARSER
22+
#undef FLECS_PARSER
23+
#endif
24+
#ifdef FLECS_NO_QUERY_DSL
25+
#undef FLECS_QUERY_DSL
26+
#endif
2127
#ifdef FLECS_NO_SCRIPT_MATH
2228
#undef FLECS_SCRIPT_MATH
2329
#endif
@@ -171,6 +177,21 @@
171177
#include "../addons/script_math.h"
172178
#endif
173179

180+
#ifdef FLECS_PARSER
181+
#ifdef FLECS_NO_PARSER
182+
#error "FLECS_NO_PARSER failed: PARSER is required by other addons"
183+
#endif
184+
#endif
185+
186+
#ifdef FLECS_QUERY_DSL
187+
#ifdef FLECS_NO_QUERY_DSL
188+
#error "FLECS_NO_QUERY_DSL failed: QUERY_DSL is required by other addons"
189+
#endif
190+
#ifndef FLECS_PARSER
191+
#define FLECS_PARSER
192+
#endif
193+
#endif
194+
174195
#ifdef FLECS_SCRIPT
175196
#ifdef FLECS_NO_SCRIPT
176197
#error "FLECS_NO_SCRIPT failed: SCRIPT is required by other addons"

meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,19 @@ flecs_src = files(
5555
'src/addons/metrics.c',
5656
'src/addons/module.c',
5757
'src/addons/os_api_impl/os_api_impl.c',
58+
'src/addons/parser/tokenizer.c',
5859
'src/addons/pipeline/pipeline.c',
5960
'src/addons/pipeline/worker.c',
61+
'src/addons/query_dsl/parser.c',
6062
'src/addons/rest.c',
6163
'src/addons/script/template.c',
6264
'src/addons/script/ast.c',
6365
'src/addons/script/function.c',
6466
'src/addons/script/functions_builtin.c',
6567
'src/addons/script/functions_math.c',
6668
'src/addons/script/parser.c',
67-
'src/addons/script/query_parser.c',
6869
'src/addons/script/script.c',
6970
'src/addons/script/serialize.c',
70-
'src/addons/script/tokenizer.c',
7171
'src/addons/script/vars.c',
7272
'src/addons/script/visit_check.c',
7373
'src/addons/script/visit_eval.c',

src/addons/json/deserialize.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include "../../private_api.h"
77
#include "json.h"
8-
#include "../script/script.h"
8+
#include "../query_dsl/query_dsl.h"
99
#include <ctype.h>
1010

1111
#ifdef FLECS_JSON
@@ -377,7 +377,7 @@ const char* flecs_json_deser_components(
377377
} else {
378378
char token_buffer[256];
379379
ecs_term_t term = {0};
380-
if (!flecs_term_parse(world, NULL, token, &term, token_buffer)) {
380+
if (!flecs_term_parse(world, NULL, token, token_buffer, &term)) {
381381
goto error;
382382
}
383383

src/addons/meta/cursor.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#include <ctype.h>
99

1010
#ifdef FLECS_META
11-
#ifdef FLECS_SCRIPT
12-
#include "../script/script.h"
11+
#ifdef FLECS_QUERY_DSL
12+
#include "../query_dsl/query_dsl.h"
1313
#endif
1414

1515
static
@@ -1470,7 +1470,7 @@ int ecs_meta_set_string(
14701470
break;
14711471
}
14721472
case EcsOpId: {
1473-
#ifdef FLECS_SCRIPT
1473+
#ifdef FLECS_QUERY_DSL
14741474
ecs_id_t id = 0;
14751475
if (flecs_id_parse(cursor->world, NULL, value, &id) == NULL) {
14761476
goto error;

0 commit comments

Comments
 (0)