c8f720871bc6ae28f1149d908b5e82ae660f2574
[zilutils.git] / zilc / element.h
1 /*
2  * element.h
3  *
4  * Copyright (C) 2015 Alexander Andrejevic <theflash AT sdf DOT lonestar DOT org>
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as
8  * published by the Free Software Foundation, either version 3 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>
18  */
19
20 #ifndef __ELEMENT_H__
21 #define __ELEMENT_H__
22
23 #include "list.h"
24
25 enum element_type
26 {
27     TYPE_ATOM,
28     TYPE_STRING,
29     TYPE_NUMBER,
30     TYPE_TUPLE,
31     TYPE_STATEMENT
32 };
33
34 typedef struct element
35 {
36     list_t link;
37     int type;
38
39     union
40     {
41         struct
42         {
43             const char *name;
44             int global;
45         } atom;
46
47         struct
48         {
49             const char *value;
50         } string;
51
52         struct
53         {
54             double value;
55         } number;
56
57         struct
58         {
59             list_t list;
60         } tuple;
61
62         struct
63         {
64             const char *name;
65             list_t parameters;
66         } statement;
67     };
68 } element_t;
69
70
71 element_t *create_atom(const char *name, int global);
72 element_t *create_string(const char *value);
73 element_t *create_number(double value);
74 element_t *create_tuple(list_t *list);
75 element_t *create_statement(const char *name, list_t *parameters);
76
77 #endif