Hash :
37078995
Author :
Thomas de Grivel
Date :
2024-08-23T23:07:59
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
/* kc3
* Copyright 2022,2023,2024 kmx.io <contact@kmx.io>
*
* Permission is hereby granted to use this software granted the above
* copyright notice and this permission paragraph are included in all
* copies and substantial portions of this software.
*
* THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
* PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
/**
* @file sym.h
* @brief Symbol data structure.
*
* Structure to manipulate symbols.
* Symbols are strings that are deduplicated.
* They are allocated once and only free'd at the end of the program.
* Comparing symbols is fast : it's a pointer comparison.
*/
#ifndef LIBKC3_SYM_H
#define LIBKC3_SYM_H
#include "types.h"
#define SYM_MAX 1024
extern const s_sym g_sym___DIR__;
extern const s_sym g_sym___FILE__;
extern const s_sym g_sym__brackets;
extern const s_sym g_sym__equal;
extern const s_sym g_sym__paren;
extern const s_sym g_sym__plus;
extern const s_sym g_sym_Array;
extern const s_sym g_sym_Block;
extern const s_sym g_sym_Bool;
extern const s_sym g_sym_Buf;
extern const s_sym g_sym_Call;
extern const s_sym g_sym_Cfn;
extern const s_sym g_sym_Character;
extern const s_sym g_sym_Char__star;
extern const s_sym g_sym_Complex;
extern const s_sym g_sym_Cow;
extern const s_sym g_sym_F32;
extern const s_sym g_sym_F64;
extern const s_sym g_sym_F128;
extern const s_sym g_sym_Fact;
extern const s_sym g_sym_FactW;
extern const s_sym g_sym_Fn;
extern const s_sym g_sym_Ident;
extern const s_sym g_sym_Integer;
extern const s_sym g_sym_KC3;
extern const s_sym g_sym_KC3_Operator;
extern const s_sym g_sym_List;
extern const s_sym g_sym_Map;
extern const s_sym g_sym_Ptag;
extern const s_sym g_sym_Ptr;
extern const s_sym g_sym_PtrFree;
extern const s_sym g_sym_Quote;
extern const s_sym g_sym_Ratio;
extern const s_sym g_sym_Result;
extern const s_sym g_sym_S8;
extern const s_sym g_sym_S16;
extern const s_sym g_sym_S32;
extern const s_sym g_sym_S64;
extern const s_sym g_sym_Str;
extern const s_sym g_sym_Struct;
extern const s_sym g_sym_StructType;
extern const s_sym g_sym_Sw;
extern const s_sym g_sym_Sym;
extern const s_sym g_sym_Tag;
extern const s_sym g_sym_Time;
extern const s_sym g_sym_Tuple;
extern const s_sym g_sym_U8;
extern const s_sym g_sym_U16;
extern const s_sym g_sym_U32;
extern const s_sym g_sym_U64;
extern const s_sym g_sym_Unquote;
extern const s_sym g_sym_Uw;
extern const s_sym g_sym_Uw_brackets;
extern const s_sym g_sym_Var;
extern const s_sym g_sym_Void;
extern const s_sym g_sym_access;
extern const s_sym g_sym_arity;
extern const s_sym g_sym_cast;
extern const s_sym g_sym_clean;
extern const s_sym g_sym_defstruct;
extern const s_sym g_sym_directory;
extern const s_sym g_sym_do;
extern const s_sym g_sym_else;
extern const s_sym g_sym_end;
extern const s_sym g_sym_file;
extern const s_sym g_sym_fn;
extern const s_sym g_sym_if;
extern const s_sym g_sym_if_then_else;
extern const s_sym g_sym_is_a;
extern const s_sym g_sym_is_loading;
extern const s_sym g_sym_load_time;
extern const s_sym g_sym_macro;
extern const s_sym g_sym_module;
extern const s_sym g_sym_operator;
extern const s_sym g_sym_operator_associativity;
extern const s_sym g_sym_operator_equal;
extern const s_sym g_sym_operator_pin;
extern const s_sym g_sym_operator_precedence;
extern const s_sym g_sym_persist;
extern const s_sym g_sym_r;
extern const s_sym g_sym_read;
extern const s_sym g_sym_right;
extern const s_sym g_sym_rw;
extern const s_sym g_sym_rwx;
extern const s_sym g_sym_rx;
extern const s_sym g_sym_signal;
extern const s_sym g_sym_special_operator;
extern const s_sym g_sym_str;
extern const s_sym g_sym_struct_type;
extern const s_sym g_sym_sym;
extern const s_sym g_sym_symbol;
extern const s_sym g_sym_symbol_value;
extern const s_sym g_sym_then;
extern const s_sym g_sym_timeout;
extern const s_sym g_sym_w;
extern const s_sym g_sym_write;
extern const s_sym g_sym_wx;
extern const s_sym g_sym_x;
const s_sym * sym_1 (const char *p);
const s_sym ** sym_init_1 (const s_sym **sym, const char *p);
const s_sym ** sym_init_cast (const s_sym **sym,
const s_sym * const *type,
const s_tag *tag);
const s_sym ** sym_init_copy (const s_sym **sym,
const s_sym * const *src);
void sym_init_g_sym (void);
const s_sym ** sym_init_str (const s_sym **sym, const s_str *src);
bool sym_register (const s_sym *sym, s_sym *free_sym);
/* Heap-allocation functions, call sym_delete_all at exit. */
void sym_delete_all (void);
const s_sym * sym_new (const s_str *src);
/* Observers */
const s_sym * sym_array_type (const s_sym *sym);
bool sym_character_is_reserved (character c);
const s_sym * sym_find (const s_str *src);
s_tag * sym_find_to_tag (const s_str *src, s_tag *dest);
bool sym_has_ident_reserved_characters (const s_sym *sym);
bool sym_has_reserved_characters (const s_sym *sym);
bool sym_is_array_type (const s_sym *sym);
bool sym_is_module (const s_sym *sym);
bool * sym_must_clean (const s_sym *sym, bool *must_clean);
bool sym_search_modules (const s_sym *sym, const s_sym **dest);
bool sym_to_ffi_type (const s_sym *sym, ffi_type *result_type,
ffi_type **dest);
bool sym_to_tag_type (const s_sym *sym, e_tag_type *dest);
uw * sym_type_size (const s_sym * const *type, uw *size);
#endif /* LIBKC3_SYM_H */