Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_function_regexp.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * afw_function_execute_* functions for regexp
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
14 #include "afw.h"
15 
16 
17 
18 /*
19  * Adaptive function: compile<regexp>
20  *
21  * afw_function_execute_compile_regexp
22  *
23  * See afw_function_bindings.h for more information.
24  *
25  * Compile regexp value and return either an unevaluated adaptive value or a
26  * string containing the compiler listing.
27  *
28  * This function is pure, so it will always return the same result
29  * given exactly the same parameters and has no side effects.
30  *
31  * Declaration:
32  *
33  * ```
34  * function compile<regexp>(
35  * source: regexp,
36  * listing?: any
37  * ): unevaluated;
38  * ```
39  *
40  * Parameters:
41  *
42  * source - (regexp) regexp string to compile.
43  *
44  * listing - (optional any dataType) If specified, a compiler listing is
45  * produced instead of an unevaluated expression value.
46  *
47  * This parameter can be an integer between 0 and 10 of a string that is
48  * used for indentation. If 0 is specified, no whitespace is added to the
49  * resulting string. If 1 through 10 is specified, that number of spaces
50  * is used.
51  *
52  * Returns:
53  *
54  * (unevaluated)
55  */
56 const afw_value_t *
59 {
60  const afw_value_string_t *source;
61  const afw_value_t *result;
62  const afw_utf8_t *listing;
63 
65 
66  result = afw_compile_to_value(
67  &source->internal, AFW_FUNCTION_SOURCE_LOCATION,
68  afw_compile_type_regexp,
69  NULL, NULL, x->p, x->xctx);
70 
72  listing = afw_function_evaluate_whitespace_parameter(x, 2);
73  result = afw_value_create_string(
75  x->p, x->xctx),
76  x->p, x->xctx);
77  }
78 
79  return result;
80 }
Adaptive Framework Core API.
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_compile_to_value(string, source_location, compile_type, parent, shared, p, xctx)
Compile string to adaptive value.
Definition: afw_compile.h:189
#define AFW_FUNCTION_SOURCE_LOCATION
Source location of a value.
Definition: afw_function.h:341
#define AFW_FUNCTION_EVALUATE_REQUIRED_DATA_TYPE_PARAMETER(A_RESULT, A_N, A_TYPE)
Evaluate an arg for a particular data type.
Definition: afw_function.h:328
#define AFW_FUNCTION_PARAMETER_IS_PRESENT(A_N)
Determine if a specific parameter value is present.
Definition: afw_function.h:242
const afw_value_t * afw_function_execute_compile_regexp(afw_function_execute_t *x)
Adaptive Function compile<regexp>
afw_value_compiler_listing_to_string(const afw_value_t *value, const afw_utf8_t *tab, const afw_pool_t *p, afw_xctx_t *xctx)
Decompile a value to a compiler listing string.
Function execute parameter.
Definition: afw_function.h:53
afw_xctx_t * xctx
The execution context (xctx) of caller.
Definition: afw_function.h:62
const afw_pool_t * p
Pool for result.
Definition: afw_function.h:59
NFC normalized UTF-8 string.
Definition: afw_common.h:545
Interface afw_value public struct.
struct for data type string values.