Purple  0.1
Standard Language Specification
type.h
Go to the documentation of this file.
1
8#ifndef TYPE
9#define TYPE
10
11#include "scan.h"
12#include "types/function.h"
13#include "types/number.h"
14
18typedef struct Type {
24 union {
29
33#define TYPE_VOID \
34 (Type) \
35 { \
36 .token_type = T_VOID, .is_function = false \
37 }
38
42#define TYPE_NUMBER_FROM_NUMBERTYPE_FROM_TOKEN(ttype) \
43 (Type) \
44 { \
45 .token_type = ttype, \
46 .value.number = NUMBER_FROM_TYPE_VAL(token_type_to_number_type(ttype), 0), \
47 .is_function = false \
48 }
49
53#define TYPE_NUMBER_FROM_NUMBERTYPE_FROM_NUMBER(n) \
54 (Type) \
55 { \
56 .token_type = number_to_token_type(n), .value.number = n, .is_function = false \
57 }
58
62#define TYPE_NUMBER_FROM_NUMBERTYPE(nt) \
63 (Type) \
64 { \
65 .token_type = number_to_token_type((Number){.token_type = nt}), .is_function = false, \
66 .value.number = NUMBER_FROM_TYPE_VAL(nt, 0) \
67 }
68
69#define TYPE_FUNCTION(out, input_list, num_inputs) \
70 (Type) \
71 { \
72 .token_type = T_FUNCTION_DECLARATION, .is_function = true, \
73 .value.function = FUNCTION_FROM_OUT_IN(out, input_list, num_inputs) \
74 }
75
76#endif /* TYPE */
Struct definitions and macros for functions.
Definitions and function headers for the internal "Number" type.
Lexical Scanner function headers.
TokenType
Types of scannable tokens.
Definition: scan.h:20
Container for function information.
Definition: function.h:26
Container for various kinds of number data.
Definition: number.h:56
Container for type data.
Definition: type.h:18
Function function
Definition: type.h:26
bool is_function
Definition: type.h:22
Number number
Definition: type.h:25
union Type::@3 value
TokenType token_type
Definition: type.h:20
struct Type Type
Container for type data.