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/>
19 * SPDX-License-Identifier: AGPL-3.0-or-later
25 element_t *create_atom(const char *name, int global)
27 element_t *element = (element_t*)malloc(sizeof(element_t));
28 if (element == NULL) return NULL;
30 element->type = TYPE_ATOM;
31 element->atom.name = name;
32 element->atom.global = global;
37 element_t *create_string(const char *value)
39 element_t *element = (element_t*)malloc(sizeof(element_t));
40 if (element == NULL) return NULL;
42 element->type = TYPE_STRING;
43 element->string.value = value;
48 element_t *create_number(double value)
50 element_t *element = (element_t*)malloc(sizeof(element_t));
51 if (element == NULL) return NULL;
53 element->type = TYPE_NUMBER;
54 element->number.value = value;
59 element_t *create_tuple(list_t *list)
61 element_t *element = (element_t*)malloc(sizeof(element_t));
62 if (element == NULL) return NULL;
64 element->type = TYPE_TUPLE;
65 element->tuple.list = *list;
70 element_t *create_statement(const char *name, list_t *parameters)
72 element_t *element = (element_t*)malloc(sizeof(element_t));
73 if (element == NULL) return NULL;
75 element->type = TYPE_STATEMENT;
76 element->statement.name = name;
77 element->statement.parameters = *parameters;