94 result = afw_compile_parse_Evaluation(parser);
120 afw_compile_parse_EntryFunctionLambdaOrVariableReference(
127 const afw_utf8_t *type_id, *untyped_function_id;
129 afw_compile_save_offset(start_offset);
130 result = afw_compile_parse_Lambda(parser);
132 afw_compile_get_token();
133 if (afw_compile_token_is(identifier)) {
136 if (!parser->token->identifier_qualifier) {
137 symbol = afw_compile_parse_get_symbol_entry(parser,
138 parser->token->identifier_name);
141 afw_compile_create_contextual_to_cursor(start_offset),
142 symbol, parser->p, parser->xctx);
148 if (!parser->token->identifier_qualifier ||
152 untyped_function_id = parser->token->identifier_name;
157 if (
function && function->polymorphic) {
158 afw_compile_get_token();
159 if (afw_compile_token_is(open_angle_bracket)) {
160 afw_compile_get_token();
161 if (!afw_compile_token_is_unqualified_identifier())
165 type_id = parser->token->identifier;
166 afw_compile_get_token();
167 if (!afw_compile_token_is(close_angle_bracket)) {
171 type_id, untyped_function_id, parser->xctx);
173 AFW_COMPILE_THROW_ERROR_FZ(
181 afw_compile_reuse_token();
185 AFW_COMPILE_THROW_ERROR_FZ(
194 if (!parser->token->identifier_qualifier) {
195 AFW_COMPILE_THROW_ERROR_FZ(
201 afw_compile_create_contextual_to_cursor(start_offset),
202 parser->token->identifier_qualifier,
203 parser->token->identifier_name,
204 parser->p, parser->xctx);
209 afw_compile_reuse_token();
264 afw_compile_save_offset(start_offset);
265 result = afw_compile_parse_EntryFunctionLambdaOrVariableReference(parser);
271 for (use_function_self = NULL;;)
273 afw_compile_save_offset(start_offset);
274 afw_compile_get_token();
277 optional_chaining_arg0 = NULL;
278 if (afw_compile_token_is(optional_chaining)) {
279 optional_chaining_arg0 = result;
280 afw_compile_next_identifier_is_not_special_literal();
281 afw_compile_get_token();
285 if (afw_compile_token_is(open_parenthesis)) {
286 afw_compile_reuse_token();
287 args = afw_compile_args_create(parser);
288 afw_compile_args_add_value(args, result);
289 if (use_function_self) {
290 afw_compile_args_add_value(args, use_function_self);
292 afw_compile_parse_Parameters(parser, args);
293 afw_compile_args_finalize(args, &argc, &argv);
294 contextual = afw_compile_create_contextual_to_cursor(start_offset);
296 parser->p, parser->xctx);
297 use_function_self = NULL;
301 else if (use_function_self) {
306 else if (afw_compile_token_is(open_bracket)) {
307 key = afw_compile_parse_Expression(parser);
308 afw_compile_get_token();
309 if (!afw_compile_token_is(close_bracket)) {
313 afw_compile_create_contextual_to_cursor(start_offset),
314 result, key, parser->p, parser->xctx);
318 else if (optional_chaining_arg0 || afw_compile_token_is(period))
320 if (!optional_chaining_arg0) {
321 afw_compile_next_identifier_is_not_special_literal();
322 afw_compile_get_token();
324 if (afw_compile_token_is(identifier)) {
325 if (parser->token->identifier_qualifier) {
327 "Qualifier not allowed");
330 parser->token->identifier_name,
331 parser->p, parser->xctx);
333 afw_compile_create_contextual_to_cursor(start_offset),
334 result, key, parser->p, parser->xctx);
348 else if (afw_compile_token_is(thin_arrow) ||
349 afw_compile_token_is(optional_chaining_thin_arrow))
351 if (optional_chaining_arg0) {
357 use_function_self = result;
359 afw_compile_parse_EntryFunctionLambdaOrVariableReference(parser);
362 "Expecting FunctionName, Lambda, Property, or "
363 "VariableReference");
368 afw_compile_reuse_token();
373 if (optional_chaining_arg0) {
379 argv[1] = optional_chaining_arg0;
382 afw_compile_create_contextual_to_cursor(
383 parser->token->token_source_offset),
384 2, argv, parser->p, parser->xctx);
429 afw_compile_parse_FunctionSignature(
433 apr_array_header_t *params;
440 optional_encountered =
false;
444 afw_compile_save_offset(start_offset);
447 params = apr_array_make(parser->apr_p, 5,
450 afw_compile_get_token();
451 if (!afw_compile_token_is(open_parenthesis)) {
455 afw_compile_get_token();
456 if (!afw_compile_token_is(close_parenthesis)) {
457 afw_compile_reuse_token();
463 afw_compile_get_token();
464 if (afw_compile_token_is(ellipsis)) {
465 param->is_rest =
true;
468 afw_compile_reuse_token();
472 afw_compile_get_token();
473 if (!afw_compile_token_is_unqualified_identifier()) {
476 param->name = parser->token->identifier_name;
477 if (afw_compile_is_reserved_word(parser, param->name)) {
479 "Parameter name can not be a reserved word");
483 afw_compile_get_token();
484 if (afw_compile_token_is(question_mark)) {
485 question_this_time =
true;
486 param->is_optional =
true;
487 optional_encountered =
true;
490 question_this_time =
false;
491 afw_compile_reuse_token();
503 *block = afw_compile_parse_link_new_value_block(parser,
506 afw_compile_parse_add_symbol_entry(parser, param->name);
509 afw_compile_get_token();
512 if (param->is_rest) {
513 if (afw_compile_token_is(close_parenthesis)) {
520 else if (afw_compile_token_is(equal)) {
521 param->default_value = afw_compile_parse_Literal(parser,
523 optional_encountered =
true;
524 afw_compile_get_token();
527 else if (optional_encountered && !question_this_time) {
532 if (afw_compile_token_is(close_parenthesis)) {
537 if (!afw_compile_token_is(comma)) {
546 signature->count = params->nelts;
547 signature->parameters =
574 afw_compile_save_offset(start_offset);
577 signature = afw_compile_parse_FunctionSignature(parser, &block);
580 afw_compile_get_token();
581 if (afw_compile_token_is(open_brace)) {
582 body = afw_compile_parse_list_of_statements(parser,
true,
false);
585 afw_compile_reuse_token();
586 body = afw_compile_parse_Expression(parser);
591 afw_compile_parse_pop_value_block(parser);
596 afw_compile_create_contextual_to_cursor(start_offset),
597 signature->returns, signature->count, signature->parameters,
598 body, parser->p, parser->xctx);
621 afw_compile_get_token();
624 if (!afw_compile_token_is(identifier)) {
625 afw_compile_reuse_token();
628 if (
afw_utf8_equal(parser->token->identifier_qualifier, &afw_s_lambda)) {
629 if (!
afw_utf8_equal(parser->token->identifier_name, &afw_s_function))
634 else if (afw_compile_token_is_name(&afw_s_function)) {
635 afw_compile_get_token();
636 if (!afw_compile_token_is(open_parenthesis) &&
637 !afw_compile_token_is(identifier))
639 afw_compile_reuse_token();
642 afw_compile_reuse_token();
645 afw_compile_reuse_token();
650 return afw_compile_parse_FunctionSignatureAndBody(parser);
666 afw_compile_parse_Parameters(
674 afw_compile_get_token();
675 if (!afw_compile_token_is(open_parenthesis)) {
680 for (had_value =
false;;) {
681 afw_compile_get_token();
683 if (afw_compile_token_is(close_parenthesis)) {
687 if (afw_compile_token_is(comma)) {
689 afw_compile_args_add_value(args, NULL);
695 afw_compile_reuse_token();
697 value = afw_compile_parse_Expression(parser);
698 afw_compile_args_add_value(args, value);
716 afw_compile_get_token();
717 if (!afw_compile_token_is(open_parenthesis)) {
720 result = afw_compile_parse_Expression(parser);
721 afw_compile_get_token();
722 if (!afw_compile_token_is(close_parenthesis)) {
774 afw_size_t cursor_start_of_data_type_parameters;
777 afw_compile_get_token();
779 if (afw_compile_token_is(open_parenthesis)) {
781 afw_compile_get_token();
786 if (afw_compile_token_is_unqualified_identifier()) {
789 dataType = parser->token->identifier_name;
793 AFW_COMPILE_THROW_ERROR_FZ(
799 if (enclosed && !afw_compile_token_is(close_parenthesis)) {
800 afw_compile_get_token();
801 cursor_start_of_data_type_parameters =
802 parser->token->token_source_offset;
803 for (list_type = NULL;
804 !afw_compile_token_is(close_parenthesis);
805 afw_compile_get_token())
812 if (!afw_compile_token_is(utf8_string)) {
825 if (!afw_compile_token_is_name(&afw_s_void)) {
826 afw_compile_reuse_token();
827 type->
return_type = afw_compile_parse_Type(parser);
834 afw_compile_reuse_token();
836 afw_compile_parse_FunctionSignature(parser, NULL);
842 if (!afw_compile_token_is_name_z(
"of")) {
852 afw_compile_get_token();
853 if (!afw_compile_token_is_name(&afw_s_list)) {
859 "Only \"of list\" can be specified except for "
862 afw_compile_reuse_token();
863 list_type->
cell_type = afw_compile_parse_Type(parser);
871 if (!afw_compile_token_is(utf8_string)) {
880 afw_compile_reuse_token();
881 type->
type = afw_compile_parse_Type(parser);
887 "Parameters are not allowed for this data type");
893 afw_compile_create_contextual(parser,
894 cursor_start_of_data_type_parameters,
895 parser->token->token_source_offset -
896 cursor_start_of_data_type_parameters);
901 else if (afw_compile_token_is(open_brace)) {
902 afw_compile_reuse_token();
912 if (enclosed && !afw_compile_token_is(close_parenthesis)) {
936 afw_compile_get_token();
937 if (afw_compile_token_is(colon)) {
939 afw_compile_get_token();
940 if (afw_compile_token_is_name(&afw_s_void)) {
943 afw_compile_reuse_token();
945 return afw_compile_parse_Type(parser);
950 afw_compile_reuse_token();
973 start_offset = parser->token->token_source_offset;
974 result = afw_compile_parse_LogicalExpression(parser);
976 afw_compile_next_can_be_operator();
977 afw_compile_get_token_and_save_offset(start_offset);
978 if (!afw_compile_token_is(nullish_coalescing)) {
979 afw_compile_reuse_token();
983 args = afw_compile_args_create(parser);
984 afw_compile_args_add_value(args,
986 afw_compile_args_add_value(args, result);
990 result = afw_compile_parse_LogicalExpression(parser);
991 afw_compile_args_add_value(args, result);
992 afw_compile_next_can_be_operator();
993 afw_compile_get_token();
994 if (!afw_compile_token_is(nullish_coalescing)) {
995 afw_compile_reuse_token();
1000 afw_compile_args_finalize(args, &argc, &argv);
1002 afw_compile_create_contextual_to_cursor(start_offset),
1003 argc - 1, argv, parser->p, parser->xctx);
1024 result = afw_compile_parse_LogicalAnd(parser);
1026 afw_compile_next_can_be_operator();
1027 afw_compile_get_token_and_save_offset(start_offset);
1028 if (!afw_compile_token_is(or)) {
1029 afw_compile_reuse_token();
1033 args = afw_compile_args_create(parser);
1034 afw_compile_args_add_value(args,
1036 afw_compile_args_add_value(args, result);
1039 result = afw_compile_parse_LogicalAnd(parser);
1040 afw_compile_args_add_value(args, result);
1041 afw_compile_next_can_be_operator();
1042 afw_compile_get_token();
1043 if (!afw_compile_token_is(or)) {
1044 afw_compile_reuse_token();
1049 afw_compile_args_finalize(args, &argc, &argv);
1051 afw_compile_create_contextual_to_cursor(start_offset),
1052 argc - 1, argv, parser->p, parser->xctx);
1072 result = afw_compile_parse_Equality(parser);
1074 afw_compile_next_can_be_operator();
1075 afw_compile_get_token_and_save_offset(start_offset);
1076 if (!afw_compile_token_is(and )) {
1077 afw_compile_reuse_token();
1081 args = afw_compile_args_create(parser);
1082 afw_compile_args_add_value(args,
1084 afw_compile_args_add_value(args, result);
1087 result = afw_compile_parse_Equality(parser);
1088 afw_compile_args_add_value(args, result);
1089 afw_compile_next_can_be_operator();
1090 afw_compile_get_token();
1091 if (!afw_compile_token_is(and )) {
1092 afw_compile_reuse_token();
1097 afw_compile_args_finalize(args, &argc, &argv);
1099 afw_compile_create_contextual_to_cursor(start_offset),
1100 argc - 1, argv, parser->p, parser->xctx);
1120 result = afw_compile_parse_Comparison(parser);
1122 afw_compile_next_can_be_operator();
1123 afw_compile_get_token_and_save_offset(start_offset);
1126 switch (parser->token->type) {
1128 case afw_compile_token_type_equal_to:
1132 case afw_compile_token_type_equal_value_and_type:
1136 case afw_compile_token_type_not_equal_to:
1140 case afw_compile_token_type_not_equal_value_and_type:
1145 afw_compile_reuse_token();
1152 argv[2] = afw_compile_parse_Comparison(parser);;
1155 afw_compile_create_contextual_to_cursor(start_offset),
1156 2, argv, parser->p, parser->xctx);
1175 result = afw_compile_parse_Factor(parser);
1177 afw_compile_next_can_be_operator();
1178 afw_compile_get_token_and_save_offset(start_offset);
1180 switch (parser->token->type) {
1182 case afw_compile_token_type_less_than:
1186 case afw_compile_token_type_less_than_or_equal_to:
1190 case afw_compile_token_type_greater_than:
1194 case afw_compile_token_type_greater_than_or_equal_to:
1199 afw_compile_reuse_token();
1206 argv[2] = afw_compile_parse_Factor(parser);
1209 afw_compile_create_contextual_to_cursor(start_offset),
1210 2, argv, parser->p, parser->xctx);
1218 impl_parse_subtract(
1226 start_offset = parser->token->token_source_offset;
1230 argv[2] = afw_compile_parse_Term(parser);
1232 afw_compile_create_contextual_to_cursor(start_offset),
1233 2, argv, parser->p, parser->xctx);
1235 afw_compile_next_can_be_operator();
1236 afw_compile_get_token();
1237 if (afw_compile_token_is(subtract)) {
1238 result = impl_parse_subtract(parser, result);
1241 afw_compile_reuse_token();
1263 start_offset = parser->token->token_source_offset;
1264 result = afw_compile_parse_Term(parser);
1266 for (args = NULL;;) {
1268 afw_compile_next_can_be_operator();
1269 afw_compile_get_token();
1271 switch (parser->token->type) {
1273 case afw_compile_token_type_add:
1275 args = afw_compile_args_create(parser);
1276 afw_compile_args_add_value(args,
1278 afw_compile_args_add_value(args, result);
1280 value = afw_compile_parse_Term(parser);
1281 afw_compile_args_add_value(args, value);
1284 case afw_compile_token_type_subtract:
1286 afw_compile_args_finalize(args, &argc, &argv);
1289 afw_compile_create_contextual_to_cursor(start_offset),
1290 argc - 1, argv, parser->p, parser->xctx);
1291 start_offset = parser->token->token_source_offset;
1293 result = impl_parse_subtract(parser, result);
1297 afw_compile_reuse_token();
1299 afw_compile_args_finalize(args, &argc, &argv);
1301 afw_compile_create_contextual_to_cursor(start_offset),
1302 argc - 1, argv, parser->p, parser->xctx);
1312 impl_parse_divide_or_mod(
1321 function = (parser->token->type == afw_compile_token_type_divide)
1325 start_offset = parser->token->token_source_offset;
1329 argv[2] = afw_compile_parse_Exponentiation(parser);
1331 afw_compile_create_contextual_to_cursor(start_offset),
1332 2, argv, parser->p, parser->xctx);
1333 afw_compile_next_can_be_operator();
1334 afw_compile_get_token();
1335 if (afw_compile_token_is(divide) || afw_compile_token_is(modulus))
1337 result = impl_parse_divide_or_mod(parser, result);
1340 afw_compile_reuse_token();
1362 start_offset = parser->token->token_source_offset;
1363 result = afw_compile_parse_Exponentiation(parser);
1365 for (args = NULL;;) {
1367 afw_compile_next_can_be_operator();
1368 afw_compile_get_token();
1370 switch (parser->token->type) {
1372 case afw_compile_token_type_multiply:
1374 args = afw_compile_args_create(parser);
1375 afw_compile_args_add_value(args,
1377 afw_compile_args_add_value(args, result);
1379 value = afw_compile_parse_Exponentiation(parser);
1380 afw_compile_args_add_value(args, value);
1383 case afw_compile_token_type_divide:
1384 case afw_compile_token_type_modulus:
1386 afw_compile_args_finalize(args, &argc, &argv);
1389 afw_compile_create_contextual_to_cursor(start_offset),
1390 argc - 1, argv, parser->p, parser->xctx);
1391 start_offset = parser->token->token_source_offset;
1393 result = impl_parse_divide_or_mod(parser, result);
1397 afw_compile_reuse_token();
1399 afw_compile_args_finalize(args, &argc, &argv);
1401 afw_compile_create_contextual_to_cursor(start_offset),
1402 argc - 1, argv, parser->p, parser->xctx);
1425 start_offset = parser->token->token_source_offset;
1426 result = afw_compile_parse_Prefixed(parser);
1428 for (args = NULL;;) {
1429 afw_compile_next_can_be_operator();
1430 afw_compile_get_token();
1432 if (afw_compile_token_is(exponentiation)) {
1434 args = afw_compile_args_create(parser);
1435 afw_compile_args_add_value(args,
1437 afw_compile_args_add_value(args, result);
1439 value = afw_compile_parse_Prefixed(parser);
1440 afw_compile_args_add_value(args, value);
1443 afw_compile_reuse_token();
1445 afw_compile_args_finalize(args, &argc, &argv);
1447 afw_compile_create_contextual_to_cursor(start_offset),
1448 argc - 1, argv, parser->p, parser->xctx);
1471 afw_compile_get_token_and_save_offset(start_offset);
1473 switch (parser->token->type) {
1475 case afw_compile_token_type_unary_plus:
1476 result = afw_compile_parse_Value(parser);
1479 case afw_compile_token_type_unary_minus:
1483 argv[1] = afw_compile_parse_Value(parser);
1485 afw_compile_create_contextual_to_cursor(start_offset),
1486 1, argv, parser->p, parser->xctx);
1489 case afw_compile_token_type_unary_not:
1493 argv[1] = afw_compile_parse_Value(parser);
1495 afw_compile_create_contextual_to_cursor(start_offset),
1496 1, argv, parser->p, parser->xctx);
1500 afw_compile_reuse_token();
1501 result = afw_compile_parse_Value(parser);
1521 result = afw_compile_parse_NullishCoalescing(parser);
1522 afw_compile_get_token_and_save_offset(start_offset);
1524 if (afw_compile_token_is(question_mark)) {
1529 argv[2] = afw_compile_parse_Expression(parser);
1531 afw_compile_get_token();
1532 if (!afw_compile_token_is(colon)) {
1535 argv[3] = afw_compile_parse_Expression(parser);
1538 afw_compile_create_contextual_to_cursor(start_offset),
1539 3, argv, parser->p, parser->xctx);
1543 afw_compile_reuse_token();
#define AFW_DEFINE_INTERNAL(type)
Define an internal function for /src/afw/ source*.c files.
Adaptive Framework Core Internal.
afw_data_type_any
Data type struct for any.
afw_value_create_string(const afw_utf8_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type string value.
#define AFW_UTF8_FMT_ARG(A_STRING)
Convenience Macro for use with AFW_UTF8_FMT to specify arg.
#define AFW_UTF8_FMT
Format string specifier used for afw_utf8_t.
struct afw_compile_internal_args_s afw_compile_args_t
apr_size_t afw_size_t
size_t.
afw_compile_parse_OptionalType(afw_compile_parser_t *parser, afw_boolean_t is_return)
#define AFW_COMPILE_THROW_ERROR_Z(message_z)
afw_environment_get_qualified_function(const afw_utf8_t *qualifier, const afw_utf8_t *name, afw_xctx_t *xctx)
Get the qualified function instance.
const afw_data_type_t * afw_environment_get_data_type(const afw_utf8_t *type, afw_xctx_t *xctx)
Get the data_type associated with configuration entry type.
afw_function_definition_not
Function definition not.
afw_function_definition_and
Function definition and.
afw_function_definition_or
Function definition or.
afw_function_definition_nullish_coalescing
Function definition nullish_coalescing.
afw_function_definition_optional_chaining
Function definition optional_chaining.
afw_function_definition_pow
Adaptive Function one_and_only
afw_function_definition_multiply
Adaptive Function mod
afw_function_definition_divide
Adaptive Function decode_to_string
afw_function_definition_ge
Adaptive Function floor
afw_function_definition_le
Adaptive Function last_index_of
afw_function_definition_gt
Adaptive Function ge
afw_function_definition_lt
Adaptive Function length
afw_function_definition_nex
Adaptive Function negative
afw_function_definition_mod
Adaptive Function min
afw_function_definition_add
Adaptive Function abs
afw_function_definition_negative
Adaptive Function ne
afw_function_definition_eqx
Adaptive Function eq_ignore_case
afw_function_definition_eq
Adaptive Function ends_with
afw_function_definition_subtract
Adaptive Function substring
afw_function_definition_ne
Adaptive Function multiply
afw_function_definition_if
Adaptive Function gt<script>
#define afw_pool_malloc(instance, size, xctx)
Call method malloc of interface afw_pool.
#define afw_pool_calloc_type(instance, type, xctx)
Macro to allocate cleared memory to hold type in pool.
afw_boolean_t afw_utf8_equal(const afw_utf8_t *s1, const afw_utf8_t *s2)
Check to see if a string equals another string.
#define afw_value_is_variable_reference(A_VALUE)
Macro to determine if value is a variable reference.
#define afw_value_is_reference_by_key(A_VALUE)
Macro to determine if value is a access property by index.
const afw_value_t * afw_value_script_function_definition_create(const afw_compile_value_contextual_t *contextual, const afw_value_type_t *returns, afw_size_t count, const afw_value_script_function_parameter_t **parameters, const afw_value_t *body, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for lambda definition value.
const afw_value_t * afw_value_variable_reference_create(const afw_compile_value_contextual_t *contextual, const afw_value_block_symbol_t *symbol, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for variable reference value.
const afw_value_t * afw_value_call_create(const afw_compile_value_contextual_t *contextual, afw_size_t argc, const afw_value_t *const *argv, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for call value.
const afw_value_t * afw_value_call_built_in_function_create(const afw_compile_value_contextual_t *contextual, afw_size_t argc, const afw_value_t *const *argv, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for call_built_in_function value.
#define afw_value_is_qualified_variable_reference(A_VALUE)
Macro to determine if value is a qualified variable reference.
const afw_value_t * afw_value_reference_by_key_create(const afw_compile_value_contextual_t *contextual, const afw_value_t *aggregate_value, const afw_value_t *key, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for reference_by_key value.
const afw_value_t * afw_value_qualified_variable_reference_create(const afw_compile_value_contextual_t *contextual, const afw_utf8_t *qualifier, const afw_utf8_t *name, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for variable reference value.
Contextual information provided in some values.
NFC normalized UTF-8 string.
struct for afw_value_block_t
struct for afw_value_block_symbol_t
Struct for function value.
Interface afw_value public struct.
Struct for script function parameter.
Struct for lambda parameter.
afw_size_t dimension
Number of subscripts needed to access cell.
const afw_value_type_t * cell_type
Cell type. If NULL, cell is untyped.
Type meta (data type, data type parameters, and value meta object.
const afw_value_type_list_t * list_type
list type (If NULL, 1 dimension with untyped cells).
const afw_utf8_t * media_type
string, base64Binary, hexBinary.
const afw_utf8_t * object_type_id
object and objectId.
const afw_value_type_t * type
unevaluated.
const afw_data_type_t * data_type
data type or NULL.
const afw_value_type_t * return_type
expression, hybrid, script and template.
const afw_compile_value_contextual_t * data_type_parameter_contextual
contextual for data type parameter or NULL.
const afw_value_script_function_signature_t * function_signature
function.