home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / unofficial-plug-ins / mathmap / lispreader.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-21  |  3.0 KB  |  115 lines

  1. /* $Id: lispreader.h,v 1.1 2000/04/03 02:18:26 schani Exp $ */
  2. /*
  3.  * lispreader.h
  4.  *
  5.  * Copyright (C) 1998-1999 Mark Probst
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Library General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2 of the License, or (at your option) any later version.
  11.  *
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Library General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU Library General Public
  18.  * License along with this library; if not, write to the
  19.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  20.  * Boston, MA 02111-1307, USA.
  21.  */
  22.  
  23. #ifndef __LISPREADER_H__
  24. #define __LISPREADER_H__
  25.  
  26. #include <stdio.h>
  27.  
  28. #define LISP_STREAM_FILE       1
  29. #define LISP_STREAM_STRING     2
  30.  
  31. #define LISP_TYPE_INTERNAL      -3
  32. #define LISP_TYPE_PARSE_ERROR   -2
  33. #define LISP_TYPE_EOF           -1
  34. #define LISP_TYPE_NIL           0
  35. #define LISP_TYPE_SYMBOL        1
  36. #define LISP_TYPE_INTEGER       2
  37. #define LISP_TYPE_STRING        3
  38. #define LISP_TYPE_CONS          4
  39. #define LISP_TYPE_PATTERN_CONS  5
  40. #define LISP_TYPE_BOOLEAN       6
  41. #define LISP_TYPE_PATTERN_VAR   7
  42.  
  43. #define LISP_PATTERN_ANY        1
  44. #define LISP_PATTERN_SYMBOL     2
  45. #define LISP_PATTERN_STRING     3
  46. #define LISP_PATTERN_INTEGER    4
  47. #define LISP_PATTERN_BOOLEAN    5
  48. #define LISP_PATTERN_LIST       6
  49. #define LISP_PATTERN_OR         7
  50.  
  51. typedef struct
  52. {
  53.     int type;
  54.  
  55.     union
  56.     {
  57.     FILE *file;
  58.     struct
  59.     {
  60.         char *buf;
  61.         int pos;
  62.     } string;
  63.     } v;
  64. } lisp_stream_t;
  65.  
  66. typedef struct _lisp_object_t lisp_object_t;
  67. struct _lisp_object_t
  68. {
  69.     int type;
  70.  
  71.     union
  72.     {
  73.     struct
  74.     {
  75.         struct _lisp_object_t *car;
  76.         struct _lisp_object_t *cdr;
  77.     } cons;
  78.  
  79.     char *string;
  80.     int integer;
  81.  
  82.     struct
  83.     {
  84.         int type;
  85.         int index;
  86.         struct _lisp_object_t *sub;
  87.     } pattern;
  88.     } v;
  89. };
  90.  
  91. lisp_stream_t* lisp_stream_init_file (lisp_stream_t *stream, FILE *file);
  92. lisp_stream_t* lisp_stream_init_string (lisp_stream_t *stream, char *buf);
  93.  
  94. lisp_object_t* lisp_read (lisp_stream_t *in);
  95. void lisp_free (lisp_object_t *obj);
  96.  
  97. lisp_object_t* lisp_read_from_string (const char *buf);
  98.  
  99. int lisp_compile_pattern (lisp_object_t **obj, int *num_subs);
  100. int lisp_match_pattern (lisp_object_t *pattern, lisp_object_t *obj, lisp_object_t **vars, int num_subs);
  101. int lisp_match_string (const char *pattern_string, lisp_object_t *obj, lisp_object_t **vars);
  102.  
  103. int lisp_type (lisp_object_t *obj);
  104. int lisp_integer (lisp_object_t *obj);
  105. char* lisp_symbol (lisp_object_t *obj);
  106. char* lisp_string (lisp_object_t *obj);
  107. int lisp_boolean (lisp_object_t *obj);
  108. lisp_object_t* lisp_car (lisp_object_t *obj);
  109. lisp_object_t* lisp_cdr (lisp_object_t *obj);
  110. int lisp_list_length (lisp_object_t *obj);
  111. lisp_object_t* lisp_list_nth (lisp_object_t *obj, int index);
  112. void lisp_dump (lisp_object_t *obj, FILE *out);
  113.  
  114. #endif
  115.