Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Files | Data Structures | Macros | Enumerations | Functions

Files

file  afw_compile_internal.h
 Adaptive Framework Compiler Internal.
 

Data Structures

struct  afw_compile_internal_shared_s
 Resources that can be shared by multiple compiles. More...
 
struct  afw_compile_internal_token_s
 
struct  afw_compile_internal_value_contextual_s
 Contextual information provided in some values. More...
 
struct  afw_compile_internal_parser_s
 
struct  afw_compile_internal_assignment_target_s
 
struct  afw_compile_internal_list_destructure_s
 
struct  afw_compile_assignment_element_s
 
struct  afw_compile_internal_assignment_property_s
 
struct  afw_compile_internal_object_destructure_s
 

Macros

#define AFW_COMPILE_MAX_TOKENS   5
 
#define AFW_COMPILE_INTERNAL_ASSIGNMENT_TYPE_MAP(XX)
 Assignment type Map. More...
 
#define AFW_COMPILE_INTERNAL_ASSIGNMENT_TARGET_TYPE_MAP(XX)
 Assignment target type Map. More...
 
#define afw_value_contextual_resolve_value_source(value_source, contextual)
 
#define afw_compile_token_is(token_type)    (parser->token->type == afw_compile_token_type_##token_type)
 
#define afw_compile_token_is_unqualified_identifier()
 
#define afw_compile_token_is_name(string)
 
#define afw_compile_token_is_name_z(string_z)
 
#define afw_compile_is_at_eof()    (parser->last_octet_eof)
 
#define afw_compile_next_is_at_eof()
 
#define afw_compile_peek_next_token()    afw_compile_peek_next_token_impl(parser)
 
#define afw_compile_peek_next_token_is(token_type)
 
#define afw_compile_set_contextual()
 
#define AFW_COMPILE_THROW_ERROR_Z(message_z)
 
#define AFW_COMPILE_THROW_ERROR_FZ(format_z, ...)
 
#define AFW_COMPILE_EOF_IS_ERROR()
 
#define afw_compile_get_code_point()    afw_compile_get_code_point_impl(parser)
 
#define afw_compile_get_unescaped_code_point()    afw_compile_get_unescaped_code_point_impl(parser)
 
#define afw_compile_next_raw_starts_with(s)    afw_compile_next_raw_starts_with_impl(parser, s)
 
#define afw_compile_next_raw_starts_with_z(s_z)    afw_compile_next_raw_starts_with_z_impl(parser, s_z)
 
#define afw_compile_get_raw_line(line)    afw_compile_get_raw_line_impl(parser, line)
 
#define afw_compile_get_token()    afw_compile_get_token_impl(parser)
 
#define afw_compile_get_token_before_eol()
 
#define afw_compile_save_offset(save)    save = parser->token->token_source_offset
 
#define afw_compile_get_token_and_save_offset(save)
 
#define afw_compile_next_can_be_operator()    parser->next_can_be_nonunary_operator = true
 
#define afw_compile_next_can_be_template_string()    parser->next_can_be_template_string = true
 
#define afw_compile_next_identifier_is_not_special_literal()    parser->next_identifier_is_not_special_literal = true
 
#define afw_compile_reuse_token()    afw_compile_reuse_token_impl(parser)
 
#define afw_compile_save_cursor(save)    save = parser->cursor
 
#define afw_compile_restore_cursor(save)
 
#define afw_compile_cursor_equal(save)    (parser->cursor == save)
 
#define afw_compile_source_buffer_at(save)    (parser->full_source->s + save)
 
#define afw_compile_source_buffer_length_from(save)    (parser->cursor - save)
 
#define afw_compile_create_contextual_to_cursor(start_offset)
 
#define afw_compile_create_source_location(start_offset)
 
#define afw_compile_parse_pop_value_block(parser)
 
#define afw_compile_args_create(parser)
 
#define afw_compile_args_add_value(args, value)   afw_stack_push(args, (parser)->xctx) = value
 
#define afw_compile_args_finalize(args, argc, argv)
 
#define AFW_COMPILE_THROW_EXPECTING_SEMICOLON    AFW_COMPILE_THROW_ERROR_Z("Expecting statement terminator ';'")
 
#define AFW_COMPILE_ASSERT_TOKEN_IS_SEMICOLON
 
#define AFW_COMPILE_ASSERT_NEXT_TOKEN_IS_SEMICOLON
 

Enumerations

enum  afw_compile_internal_token_type_t {
  afw_compile_token_type_invalid , afw_compile_token_type_end , afw_compile_token_type_raw_line , afw_compile_token_type_eol ,
  afw_compile_token_type_boolean , afw_compile_token_type_identifier , afw_compile_token_type_integer , afw_compile_token_type_number ,
  afw_compile_token_type_binary_string , afw_compile_token_type_utf8_string , afw_compile_token_type_template_string , afw_compile_token_type_null ,
  afw_compile_token_type_undefined , afw_compile_token_type_ampersand , afw_compile_token_type_back_slash , afw_compile_token_type_caret ,
  afw_compile_token_type_colon , afw_compile_token_type_comma , afw_compile_token_type_dollar_sign , afw_compile_token_type_ellipsis ,
  afw_compile_token_type_fat_arrow , afw_compile_token_type_grave , afw_compile_token_type_nullish_coalescing , afw_compile_token_type_optional_chaining ,
  afw_compile_token_type_optional_chaining_thin_arrow , afw_compile_token_type_percent , afw_compile_token_type_period , afw_compile_token_type_question_mark ,
  afw_compile_token_type_semicolon , afw_compile_token_type_slash , afw_compile_token_type_thin_arrow , afw_compile_token_type_tilde ,
  afw_compile_token_type_substitute_start , afw_compile_token_type_vertical_bar , afw_compile_token_type_unary_plus , afw_compile_token_type_unary_minus ,
  afw_compile_token_type_unary_not , afw_compile_token_type_open_brace , afw_compile_token_type_close_brace , afw_compile_token_type_open_parenthesis ,
  afw_compile_token_type_close_parenthesis , afw_compile_token_type_open_bracket , afw_compile_token_type_close_bracket , afw_compile_token_type_open_angle_bracket ,
  afw_compile_token_type_close_angle_bracket , afw_compile_token_type_add , afw_compile_token_type_subtract , afw_compile_token_type_multiply ,
  afw_compile_token_type_divide , afw_compile_token_type_modulus , afw_compile_token_type_exponentiation , afw_compile_token_type_increment ,
  afw_compile_token_type_decrement , afw_compile_token_type_and , afw_compile_token_type_or , afw_compile_token_type_equal ,
  afw_compile_token_type_plus_equal , afw_compile_token_type_minus_equal , afw_compile_token_type_multiply_equal , afw_compile_token_type_divide_equal ,
  afw_compile_token_type_modulus_equal , afw_compile_token_type_exponentiation_equal , afw_compile_token_type_and_equal , afw_compile_token_type_or_equal ,
  afw_compile_token_type_nullish_equal , afw_compile_token_type_equal_to , afw_compile_token_type_equal_value_and_type , afw_compile_token_type_not_equal_to ,
  afw_compile_token_type_not_equal_value_and_type , afw_compile_token_type_less_than , afw_compile_token_type_less_than_or_equal_to , afw_compile_token_type_greater_than ,
  afw_compile_token_type_greater_than_or_equal_to
}
 
enum  afw_compile_internal_assignment_type_t { afw_compile_assignment_type_max_type }
 Enum for assignment types.
 
enum  afw_compile_assignment_target_type_t { afw_compile_assignment_target_type_max_type }
 Enum for assignment target types.
 

Functions

afw_compile_internal_token_type_t afw_compile_peek_next_token_impl (afw_compile_parser_t *parser)
 
 afw_compile_get_code_point_impl (afw_compile_parser_t *parser)
 
 afw_compile_get_unescaped_code_point_impl (afw_compile_parser_t *parser)
 
 afw_compile_is_reserved_word (afw_compile_parser_t *parser, const afw_utf8_t *s)
 
 afw_compile_next_raw_starts_with_impl (afw_compile_parser_t *parser, const afw_utf8_t *s)
 
 afw_compile_next_raw_starts_with_z_impl (afw_compile_parser_t *parser, const afw_utf8_z_t *s_z)
 
 afw_compile_parse_list_of_statements (afw_compile_parser_t *parser, afw_boolean_t end_is_close_brace, afw_boolean_t can_be_single_return_expression)
 
 afw_compile_get_raw_line_impl (afw_compile_parser_t *parser, afw_utf8_t *line)
 
 afw_compile_current_raw_token (afw_compile_parser_t *parser)
 
 afw_compile_get_string_literal (afw_compile_parser_t *parser, const afw_utf8_octet_t *s, afw_size_t len)
 
 afw_compile_get_token_impl (afw_compile_parser_t *parser)
 
void afw_compile_reuse_token_impl (afw_compile_parser_t *parser)
 
 afw_compile_create_contextual (afw_compile_parser_t *parser, afw_size_t start_offset, afw_size_t size)
 
 afw_compile_create_source_location_impl (afw_compile_parser_t *parser, afw_size_t start_offset)
 
afw_code_point_t afw_compile_peek_code_point (afw_compile_parser_t *parser)
 
 afw_compile_internal_s_push_code_point (afw_compile_parser_t *parser, afw_code_point_t cp)
 
 afw_compile_parse_set_error_z (afw_compile_parser_t *parser, const afw_utf8_z_t *source_z, const afw_utf8_z_t *message_z)
 
 afw_compile_parse_set_error_fz (afw_compile_parser_t *parser, const afw_utf8_z_t *source_z, const afw_utf8_z_t *format_z,...)
 
 afw_compile_parse_get_symbol_entry (afw_compile_parser_t *parser, const afw_utf8_t *name)
 
 afw_compile_parse_get_local_symbol_entry (afw_compile_parser_t *parser, const afw_utf8_t *name)
 
 afw_compile_parse_add_symbol_entry (afw_compile_parser_t *parser, const afw_utf8_t *name)
 
 afw_compile_parse_link_new_value_block (afw_compile_parser_t *parser, afw_size_t start_offset)
 
 afw_compile_parse_reference_create (afw_compile_parser_t *parser, const afw_compile_value_contextual_t *contextual, const afw_utf8_t *identifier)
 
 afw_compile_parse_check_symbol (afw_compile_parser_t *parser, const afw_utf8_t *name, const afw_value_t *value, afw_compile_internal_assignment_type_t assignment_type, afw_size_t symbol_cursor)
 
 afw_compile_parse_Assignment (afw_compile_parser_t *parser, afw_boolean_t *was_expression)
 
 afw_compile_parse_AssignmentBindingTarget (afw_compile_parser_t *parser, afw_compile_internal_assignment_type_t assignment_type, const afw_value_type_t **type, const afw_value_t **value)
 
 afw_compile_parse_AssignmentListDestructureTarget (afw_compile_parser_t *parser, afw_compile_internal_assignment_type_t assignment_type)
 
 afw_compile_parse_AssignmentElement (afw_compile_parser_t *parser, afw_compile_internal_assignment_type_t assignment_type)
 
 afw_compile_parse_AssignmentExpression (afw_compile_parser_t *parser)
 
 afw_compile_parse_AssignmentObjectDestructureTarget (afw_compile_parser_t *parser, afw_compile_internal_assignment_type_t assignment_type)
 
 afw_compile_parse_AssignmentProperty (afw_compile_parser_t *parser, afw_compile_internal_assignment_type_t assignment_type)
 
 afw_compile_parse_AssignmentStatement (afw_compile_parser_t *parser, afw_boolean_t *was_expression)
 
 afw_compile_parse_AssignmentTarget (afw_compile_parser_t *parser, afw_compile_internal_assignment_type_t assignment_type)
 
 afw_compile_parse_Comparison (afw_compile_parser_t *parser)
 
 afw_compile_parse_EntryFunctionLambdaOrVariableReference (afw_compile_parser_t *parser)
 
 afw_compile_parse_Equality (afw_compile_parser_t *parser)
 
 afw_compile_parse_Exponentiation (afw_compile_parser_t *parser)
 
 afw_compile_parse_Evaluation (afw_compile_parser_t *parser)
 
 afw_compile_parse_Expression (afw_compile_parser_t *parser)
 
 afw_compile_parse_ExpressionTuple (afw_compile_parser_t *parser)
 
 afw_compile_parse_ExpressionTupleAnnotation (afw_compile_parser_t *parser)
 
 afw_compile_parse_ExpressionTupleOperation (afw_compile_parser_t *parser)
 
 afw_compile_parse_ExpressionTupleParameter (afw_compile_parser_t *parser)
 
 afw_compile_parse_Factor (afw_compile_parser_t *parser)
 
 afw_compile_parse_FunctionSignature (afw_compile_parser_t *parser, const afw_value_block_t **block)
 
 afw_compile_parse_FunctionSignatureAndBody (afw_compile_parser_t *parser)
 
 afw_compile_parse_Json (afw_compile_parser_t *parser)
 
 afw_compile_parse_Literal (afw_compile_parser_t *parser, afw_boolean_t *is_Literal, afw_boolean_t must_be_literal, afw_boolean_t scalar_only)
 
 afw_compile_parse_Lambda (afw_compile_parser_t *parser)
 
 afw_compile_parse_List (afw_compile_parser_t *parser, afw_boolean_t allow_expression, afw_boolean_t allow_enhanced_literals)
 
 afw_compile_parse_LogicalExpression (afw_compile_parser_t *parser)
 
 afw_compile_parse_LogicalAnd (afw_compile_parser_t *parser)
 
 afw_compile_parse_NullishCoalescing (afw_compile_parser_t *parser)
 
 afw_compile_parse_Object (afw_compile_parser_t *parser, afw_boolean_t allow_expression, afw_boolean_t allow_enhanced_literals)
 
 afw_compile_parse_OptionalDefineAssignment (afw_compile_parser_t *parser)
 
 afw_compile_parse_OptionalDefineTarget (afw_compile_parser_t *parser)
 
 afw_compile_parse_OptionalType (afw_compile_parser_t *parser, afw_boolean_t is_return)
 
 afw_compile_parse_Parameters (afw_compile_parser_t *parser, afw_compile_args_t *args)
 
 afw_compile_parse_ParenthesizedExpression (afw_compile_parser_t *parser)
 
 afw_compile_parse_Prefixed (afw_compile_parser_t *parser)
 
 afw_compile_parse_Reference (afw_compile_parser_t *parser)
 
 afw_compile_parse_Script (afw_compile_parser_t *parser)
 
 afw_compile_parse_Statement (afw_compile_parser_t *parser, afw_boolean_t *was_expression)
 
 afw_compile_parse_Substitution (afw_compile_parser_t *parser)
 
 afw_compile_parse_Template (afw_compile_parser_t *parser)
 
 afw_compile_parse_TemplateString (afw_compile_parser_t *parser)
 
 afw_compile_parse_Term (afw_compile_parser_t *parser)
 
 afw_compile_parse_TestScript (afw_compile_parser_t *parser)
 
 afw_compile_parse_Type (afw_compile_parser_t *parser)
 
 afw_compile_parse_Value (afw_compile_parser_t *parser)
 
 afw_compile_parse_Hybrid (afw_compile_parser_t *parser)
 
 afw_compile_parse_variable_reference_create (afw_compile_parser_t *parser, const afw_compile_value_contextual_t *contextual, afw_compile_internal_assignment_type_t assignment_type, const afw_utf8_t *identifier)
 
 afw_compile_skip_ws (afw_compile_parser_t *parser)
 
 afw_compile_check_for_residual (afw_compile_parser_t *parser)
 
 AFW_STACK_STRUCT (afw_compile_internal_args_s, const afw_value_t *)
 
 afw_compile_lexical_parser_create (const afw_utf8_t *source, afw_utf8_octet_get_cb_t callback, void *callback_data, const afw_utf8_t *source_location, afw_compile_type_t compile_type, afw_compile_residual_check_t residual_check, afw_boolean_t cede_p, const afw_value_compiled_value_t *parent, const afw_compile_shared_t *shared, const afw_pool_t *p, afw_xctx_t *xctx)
 
 afw_compile_lexical_parser_finish_and_release (afw_compile_parser_t *parser, afw_xctx_t *xctx)
 

Detailed Description

Internal compile API.

Macro Definition Documentation

◆ afw_compile_args_create

#define afw_compile_args_create (   parser)
Value:
(parser)->p, (parser)->xctx)
struct afw_compile_internal_args_s afw_compile_args_t
#define afw_stack_create(typedef_name, initial_count, maximum_count, create_subpool_pool, p, xctx)
Create a stack for the specified typedef.
Definition: afw_stack.h:40

Definition at line 1228 of file afw_compile_internal.h.

◆ afw_compile_args_finalize

#define afw_compile_args_finalize (   args,
  argc,
  argv 
)
Value:
afw_stack_copy_and_release((args), (argc), (argv), \
(parser)->p, (parser)->xctx)
#define afw_stack_copy_and_release(instance, count, ptr, p, xctx)
Copy and release stack.
Definition: afw_stack.h:131

Definition at line 1241 of file afw_compile_internal.h.

◆ AFW_COMPILE_ASSERT_NEXT_TOKEN_IS_SEMICOLON

#define AFW_COMPILE_ASSERT_NEXT_TOKEN_IS_SEMICOLON
Value:
afw_compile_get_token(); \
AFW_COMPILE_ASSERT_TOKEN_IS_SEMICOLON

Definition at line 1287 of file afw_compile_internal.h.

◆ AFW_COMPILE_ASSERT_TOKEN_IS_SEMICOLON

#define AFW_COMPILE_ASSERT_TOKEN_IS_SEMICOLON
Value:
if (!afw_compile_token_is(semicolon)) \
AFW_COMPILE_THROW_EXPECTING_SEMICOLON

Definition at line 1281 of file afw_compile_internal.h.

◆ afw_compile_create_contextual_to_cursor

#define afw_compile_create_contextual_to_cursor (   start_offset)
Value:
afw_compile_create_contextual(parser, start_offset, \
parser->cursor - start_offset)

Definition at line 818 of file afw_compile_internal.h.

◆ afw_compile_create_source_location

#define afw_compile_create_source_location (   start_offset)
Value:
afw_compile_create_source_location_impl(parser, \
start_offset)

Definition at line 831 of file afw_compile_internal.h.

◆ AFW_COMPILE_EOF_IS_ERROR

#define AFW_COMPILE_EOF_IS_ERROR ( )
Value:
if (afw_compile_is_at_eof()) \
AFW_COMPILE_THROW_ERROR_Z("Unexpected end")

Definition at line 631 of file afw_compile_internal.h.

◆ afw_compile_get_token_and_save_offset

#define afw_compile_get_token_and_save_offset (   save)
Value:
afw_compile_get_token_impl(parser); \
save = parser->token->token_source_offset

Definition at line 738 of file afw_compile_internal.h.

◆ afw_compile_get_token_before_eol

#define afw_compile_get_token_before_eol ( )
Value:
parser->get_token_before_eol = true; \
afw_compile_get_token_impl(parser)

Definition at line 727 of file afw_compile_internal.h.

◆ AFW_COMPILE_INTERNAL_ASSIGNMENT_TARGET_TYPE_MAP

#define AFW_COMPILE_INTERNAL_ASSIGNMENT_TARGET_TYPE_MAP (   XX)
Value:
\
XX(list_destructure, \
"This is a list destructure.") \
\
XX(object_destructure, \
"This is a object destructure.") \
\
XX(variable_reference, \
"This is a variable reference.") \

Assignment target type Map.

Parameters
idof assignment target type
descriptionof this assignment target type

Definition at line 443 of file afw_compile_internal.h.

◆ AFW_COMPILE_INTERNAL_ASSIGNMENT_TYPE_MAP

#define AFW_COMPILE_INTERNAL_ASSIGNMENT_TYPE_MAP (   XX)
Value:
\
XX(assign_only, \
"This is an assignment to an existing variable.") \
\
XX(const, \
"This is an assignment to a new const variable.") \
\
XX(declare_only, \
"This is a declare of a new variable without assignment.") \
\
XX(define_loc_if_needed, \
"This is an assignment to a new or existing local variable. ") \
\
XX(loc, \
"This is an assignment to a new local variable. ") \
\
XX(reference_only, \
"No assignment, just reference.") \
\
XX(use_assignment_targets, \
"Use the assignment type from assignment target.") \
\

Assignment type Map.

Parameters
idof assignment type
descriptionof this assignment type

Definition at line 404 of file afw_compile_internal.h.

◆ afw_compile_next_is_at_eof

#define afw_compile_next_is_at_eof ( )
Value:
(parser->last_octet_eof || \
(parser->all_eof && (parser->cursor == parser->cursor_eof)) )

Definition at line 584 of file afw_compile_internal.h.

◆ afw_compile_parse_pop_value_block

#define afw_compile_parse_pop_value_block (   parser)
Value:
(parser)->compiled_value->current_block = \
(parser)->compiled_value->current_block->parent_block

Definition at line 903 of file afw_compile_internal.h.

◆ afw_compile_peek_next_token_is

#define afw_compile_peek_next_token_is (   token_type)
Value:
(afw_compile_peek_next_token_impl(parser) == \
afw_compile_token_type_##token_type)

Definition at line 595 of file afw_compile_internal.h.

◆ afw_compile_restore_cursor

#define afw_compile_restore_cursor (   save)
Value:
do { \
parser->last_octet_eof = false; \
parser->cursor = save; \
} while (0)

Definition at line 788 of file afw_compile_internal.h.

◆ afw_compile_set_contextual

#define afw_compile_set_contextual ( )
Value:
parser->xctx->error->contextual = &parser->contextual; \
parser->xctx->error->parser_cursor = parser->cursor

Definition at line 601 of file afw_compile_internal.h.

◆ AFW_COMPILE_THROW_ERROR_FZ

#define AFW_COMPILE_THROW_ERROR_FZ (   format_z,
  ... 
)
Value:
do { \
afw_compile_parse_set_error_fz(parser, \
AFW__FILE_LINE__, format_z, __VA_ARGS__); \
longjmp(((parser->xctx)->current_try->throw_jmp_buf), \
(afw_error_code_syntax)); \
} while (0)
#define AFW__FILE_LINE__
file:line
Definition: afw_common.h:148

Definition at line 620 of file afw_compile_internal.h.

◆ AFW_COMPILE_THROW_ERROR_Z

#define AFW_COMPILE_THROW_ERROR_Z (   message_z)
Value:
do { \
afw_compile_parse_set_error_z(parser, \
AFW__FILE_LINE__, message_z); \
longjmp(((parser->xctx)->current_try->throw_jmp_buf), \
(afw_error_code_syntax)); \
} while (0)
Todo:

FIXME: parser->contextual.value_source.s = parser->c;

FIXME: parser->contextual.value_source.len = 0;

Definition at line 610 of file afw_compile_internal.h.

◆ afw_compile_token_is_name

#define afw_compile_token_is_name (   string)
Value:
(afw_compile_token_is_unqualified_identifier() && \
afw_utf8_equal(parser->token->identifier_name, (string)))

Definition at line 563 of file afw_compile_internal.h.

◆ afw_compile_token_is_name_z

#define afw_compile_token_is_name_z (   string_z)
Value:
(afw_compile_token_is_unqualified_identifier() && \
afw_utf8_equal_utf8_z(parser->token->identifier_name, (string_z)))

Definition at line 569 of file afw_compile_internal.h.

◆ afw_compile_token_is_unqualified_identifier

#define afw_compile_token_is_unqualified_identifier ( )
Value:
(parser->token->type == afw_compile_token_type_identifier && \
!parser->token->identifier_qualifier)

Definition at line 557 of file afw_compile_internal.h.

◆ afw_value_contextual_resolve_value_source

#define afw_value_contextual_resolve_value_source (   value_source,
  contextual 
)
Value:
do { \
if ((contextual)->compiled_value && \
(contextual)->compiled_value->full_source) \
{ \
(value_source)->s = (((contextual)->compiled_value->full_source)->s) + \
(contextual)->value_offset; \
(value_source)->len = (contextual)->value_size; \
} \
else { \
memset((value_source), 0, sizeof(afw_utf8_t)); \
} \
} while (0)
NFC normalized UTF-8 string.
Definition: afw_common.h:545

Definition at line 535 of file afw_compile_internal.h.

Function Documentation

◆ afw_compile_parse_OptionalType()

afw_compile_parse_OptionalType ( afw_compile_parser_t parser,
afw_boolean_t  is_return 
)
Todo:
use defined constant

Definition at line 929 of file afw_compile_parse_expression.c.