4 * Copyright (C) 2015 Alexander Andrejevic <theflash AT sdf DOT lonestar DOT org>
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.
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.
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/>
23 element_t *create_atom(const char *name, int global)
25 element_t *element = (element_t*)malloc(sizeof(element_t));
26 if (element == NULL) return NULL;
28 element->type = TYPE_ATOM;
29 element->atom.name = name;
30 element->atom.global = global;
35 element_t *create_string(const char *value)
37 element_t *element = (element_t*)malloc(sizeof(element_t));
38 if (element == NULL) return NULL;
40 element->type = TYPE_STRING;
41 element->string.value = value;
46 element_t *create_number(double value)
48 element_t *element = (element_t*)malloc(sizeof(element_t));
49 if (element == NULL) return NULL;
51 element->type = TYPE_NUMBER;
52 element->number.value = value;
57 element_t *create_tuple(list_t *list)
59 element_t *element = (element_t*)malloc(sizeof(element_t));
60 if (element == NULL) return NULL;
62 element->type = TYPE_TUPLE;
63 element->tuple.list = *list;
68 element_t *create_statement(const char *name, list_t *parameters)
70 element_t *element = (element_t*)malloc(sizeof(element_t));
71 if (element == NULL) return NULL;
73 element->type = TYPE_STATEMENT;
74 element->statement.name = name;
75 element->statement.parameters = *parameters;