element.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. * SPDX-License-Identifier: AGPL-3.0-or-later
  20. */
  21. #ifndef __ELEMENT_H__
  22. #define __ELEMENT_H__
  23. #include "list.h"
  24. enum element_type
  25. {
  26. TYPE_ATOM,
  27. TYPE_STRING,
  28. TYPE_NUMBER,
  29. TYPE_TUPLE,
  30. TYPE_STATEMENT
  31. };
  32. typedef struct element
  33. {
  34. list_t link;
  35. int type;
  36. union
  37. {
  38. struct
  39. {
  40. const char *name;
  41. int global;
  42. } atom;
  43. struct
  44. {
  45. const char *value;
  46. } string;
  47. struct
  48. {
  49. double value;
  50. } number;
  51. struct
  52. {
  53. list_t list;
  54. } tuple;
  55. struct
  56. {
  57. const char *name;
  58. list_t parameters;
  59. } statement;
  60. };
  61. } element_t;
  62. element_t *create_atom(const char *name, int global);
  63. element_t *create_string(const char *value);
  64. element_t *create_number(double value);
  65. element_t *create_tuple(list_t *list);
  66. element_t *create_statement(const char *name, list_t *parameters);
  67. #endif