Purple  0.1
Standard Language Specification
type.h
Go to the documentation of this file.
1
8#ifndef TYPE_H
9#define TYPE_H
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 .type = T_VOID, .is_function = false \
37 }
38
42#define TYPE_NUMBER_FROM_NUMBERTYPE_FROM_TOKEN(ttype) \
43 (Type) \
44 { \
45 .type = ttype, .value.number = NUMBER_FROM_TYPE_VAL(token_type_to_number_type(ttype), 0), \
46 .is_function = false \
47 }
48
52#define TYPE_NUMBER_FROM_NUMBERTYPE_FROM_NUMBER(n) \
53 (Type) \
54 { \
55 .type = number_to_token_type(n), .value.number = n, .is_function = false \
56 }
57
61#define TYPE_NUMBER_FROM_NUMBERTYPE(nt) \
62 (Type) \
63 { \
64 .type = number_to_token_type((Number){.type = nt}), .is_function = false, \
65 .value.number = NUMBER_FROM_TYPE_VAL(nt, 0) \
66 }
67
68#define TYPE_FUNCTION(out, input_list, num_inputs) \
69 (Type) \
70 { \
71 .type = T_FUNCTION_DECLARATION, .is_function = true, \
72 .value.function = FUNCTION_FROM_OUT_IN(out, input_list, num_inputs) \
73 }
74
75#endif /* TYPE_H */
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:27
Container for various kinds of number data.
Definition: number.h:51
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
TokenType type
Definition: type.h:20
union Type::@3 value
struct Type Type
Container for type data.