Skip to content

Commit 8ef3e0a

Browse files
committed
Split off query DSL parser into separate addon
1 parent 769cd46 commit 8ef3e0a

File tree

19 files changed

+20739
-20618
lines changed

19 files changed

+20739
-20618
lines changed

distr/flecs.c

Lines changed: 20571 additions & 20537 deletions
Large diffs are not rendered by default.

distr/flecs.h

Lines changed: 30 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,8 @@ void FlecsAlertsImport(
1353513543
#define FLECS_META
1353613544
#endif
1353713545

13538-
#ifndef FLECS_SCRIPT
13539-
#define FLECS_SCRIPT
13546+
#ifndef FLECS_QUERY_DSL
13547+
#define FLECS_QUERY_DSL /* For parsing component id expressions */
1354013548
#endif
1354113549

1354213550
#ifndef FLECS_JSON_H
@@ -14377,6 +14385,21 @@ void FlecsScriptMathImport(
1437714385

1437814386
#endif
1437914387

14388+
#ifdef FLECS_PARSER
14389+
#ifdef FLECS_NO_PARSER
14390+
#error "FLECS_NO_PARSER failed: PARSER is required by other addons"
14391+
#endif
14392+
#endif
14393+
14394+
#ifdef FLECS_QUERY_DSL
14395+
#ifdef FLECS_NO_QUERY_DSL
14396+
#error "FLECS_NO_QUERY_DSL failed: QUERY_DSL is required by other addons"
14397+
#endif
14398+
#ifndef FLECS_PARSER
14399+
#define FLECS_PARSER
14400+
#endif
14401+
#endif
14402+
1438014403
#ifdef FLECS_SCRIPT
1438114404
#ifdef FLECS_NO_SCRIPT
1438214405
#error "FLECS_NO_SCRIPT failed: SCRIPT is required by other addons"
@@ -14406,6 +14429,9 @@ void FlecsScriptMathImport(
1440614429
#define FLECS_DOC
1440714430
#endif
1440814431

14432+
#ifndef FLECS_PARSER
14433+
#define FLECS_PARSER
14434+
#endif
1440914435

1441014436
#ifndef FLECS_SCRIPT_H
1441114437
#define FLECS_SCRIPT_H

docs/Quickstart.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ 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-
[Parser](/flecs/group__c__addons__parser.html) | Parser utilities used by script & query DSL | FLECS_PARSER |
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 |
123124
[Script](/flecs/group__c__addons__script.html) | DSL for scenes, assets and configuration | FLECS_SCRIPT |
124125
[Stats](/flecs/group__c__addons__stats.html) | Functions for collecting statistics | FLECS_STATS |
125126
[Metrics](/flecs/group__c__addons__metrics.html) | Create metrics from user-defined components | FLECS_METRICS |

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#define FLECS_META
1515
#endif
1616

17-
#ifndef FLECS_SCRIPT
18-
#define FLECS_SCRIPT
17+
#ifndef FLECS_QUERY_DSL
18+
#define FLECS_QUERY_DSL /* For parsing component id expressions */
1919
#endif
2020

2121
#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"

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;

src/addons/parser/grammar.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#ifndef FLECS_PARSER_GRAMMAR_H
99
#define FLECS_PARSER_GRAMMAR_H
1010

11+
#include "parser.h"
12+
1113
#if defined(ECS_TARGET_CLANG)
1214
/* Ignore unused enum constants in switch as it would blow up the parser code */
1315
#pragma clang diagnostic ignored "-Wswitch-enum"

0 commit comments

Comments
 (0)