1 /** 2 * @file lispreader.h 3 * @brief Parse configuration file 4 * @created 2007-06-15 5 * @date 2015-01-10 6 * @author Mark Probst 7 * @author Ingo Ruhnke <grumbel@gmx.de> 8 * @author Bruno Ethvignot 9 */ 10 /* 11 * copyright (c) 1998-2000 Mark Probst 12 * copyright (c) 2002 Ingo Ruhnke <grumbel@gmx.de> 13 * copyright (c) 2007-2015 TLK Games all rights reserved 14 * $Id: lispreader.h,v 1.4 2012/08/26 17:09:14 gurumeditation Exp $ 15 * 16 * Powermanga is free software; you can redistribute it and/or modify 17 * it under the terms of the GNU General Public License as published by 18 * the Free Software Foundation; either version 3 of the License, or 19 * (at your option) any later version. 20 * 21 * Powermanga is distributed in the hope that it will be useful, but 22 * WITHOUT ANY WARRANTY; without even the implied warranty of 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 * GNU General Public License for more details. 25 * 26 * You should have received a copy of the GNU General Public License 27 * along with this program; if not, write to the Free Software 28 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 29 * MA 02110-1301, USA. 30 */ 31 #ifndef __LISPREADER__ 32 #define __LISPREADER__ 33 34 #ifdef __cplusplus 35 extern "C" 36 { 37 #endif 38 39 typedef enum 40 { 41 LISP_TYPE_INTERNAL = -3, 42 LISP_TYPE_PARSE_ERROR = -2, 43 LISP_TYPE_EOF = -1, 44 LISP_TYPE_NIL = 0, 45 LISP_TYPE_SYMBOL, 46 LISP_TYPE_INTEGER, 47 LISP_TYPE_STRING, 48 LISP_TYPE_REAL, 49 LISP_TYPE_CONS, 50 LISP_TYPE_PATTERN_CONS, 51 LISP_TYPE_BOOLEAN, 52 LISP_TYPE_PATTERN_VAR 53 } LISP_TYPE_ENUM; 54 55 typedef struct 56 { 57 Sint32 type; 58 union 59 { 60 FILE *file; 61 struct 62 { 63 char *buf; 64 Sint32 pos; 65 } 66 string; 67 struct 68 { 69 void *data; 70 Sint32 (*next_char) (void *data); 71 void (*unget_char) (char c, void *data); 72 } 73 any; 74 } v; 75 } 76 lisp_stream_t; 77 78 typedef struct _lisp_object_t lisp_object_t; 79 struct _lisp_object_t 80 { 81 Sint32 type; 82 union 83 { 84 struct 85 { 86 struct _lisp_object_t *car; 87 struct _lisp_object_t *cdr; 88 } 89 cons; 90 char *string; 91 Sint32 integer; 92 float real; 93 struct 94 { 95 Sint32 type; 96 Sint32 index; 97 struct _lisp_object_t *sub; 98 } 99 pattern; 100 } v; 101 }; 102 103 lisp_object_t *search_for (lisp_object_t * lst, const char *name); 104 lisp_object_t *lisp_car_int (lisp_object_t * lst, Sint32 * i); 105 bool lisp_read_int (lisp_object_t * lst, const char *name, Sint32 * i); 106 bool lisp_read_bool (lisp_object_t * lst, const char *name, bool * b); 107 bool lisp_read_string (lisp_object_t * lst, const char *name, char **str); 108 lisp_object_t *lisp_read_file (char *filename); 109 char *lisp_symbol (lisp_object_t * obj); 110 lisp_object_t *lisp_car (lisp_object_t * obj); 111 lisp_object_t *lisp_cdr (lisp_object_t * obj); 112 void lisp_free (lisp_object_t * obj); 113 114 #ifdef __cplusplus 115 } 116 #endif 117 #endif 118