home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / interfaces / zephyr / lread.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-16  |  2.3 KB  |  65 lines

  1. /*
  2.    lread.h  Header file for elisp reader and destructurer
  3.    Copyright (C) 1992 Nick Thompson (nix@cs.cmu.edu)
  4.  
  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 2 of the License, or
  8.    (at your option) any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.    GNU General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19.    This code is useful for communicating with emacs, particularly in
  20.    subprocesses which are started by emacs.  It allows you to do structured
  21.    ipc by passing printed s-expressions between emacs and the subprocess -
  22.    strings are parsed into a union "Value" by this code and there is also a
  23.    fairly convenient way to extract data.
  24.    
  25.   */
  26.  
  27. enum Vtag { any, nil, cons, string, symbol, integer, var };
  28.  
  29. typedef struct Value Value;
  30. struct Value {
  31.    enum Vtag tag;
  32.    union {
  33.       /* tag nil has no data */
  34.       struct { Value *car, *cdr; } cons;
  35.       struct { int length; char *string; } s;    /* tag string or symbol */
  36.       struct { long i; } integer;
  37.       struct { enum Vtag tag; void **value; } var;
  38.    } value;
  39. };
  40.  
  41. #define ALLOC_VALUE()    ((Value *) malloc(sizeof(Value)))
  42.  
  43. #define VTAG(v) (v?((v)->tag):nil)
  44.  
  45. extern Value *vmake_cons(Value *car, Value *cdr);
  46. #define VCAR(v) ((v)->value.cons.car)
  47. #define VCDR(v) ((v)->value.cons.cdr)
  48.  
  49. extern Value *vmake_symbol(int length, char *data);
  50. extern Value *vmake_symbol_c(char *s);
  51. extern Value *vmake_string(int length, char *data);
  52. extern Value *vmake_string_c(char *s);
  53. extern char *vextract_string_c(Value *v);
  54. #define VSLENGTH(v) ((v)->value.s.length)
  55. #define VSDATA(v) ((v)->value.s.string)
  56.  
  57. extern Value *vmake_integer(int n);
  58. #define VINTEGER(v) ((v)->value.integer.i)
  59.  
  60. extern Value *vmake_var(enum Vtag tag, void **value);
  61. #define VVTAG(v) ((v)->value.var.tag)
  62. #define VVDATA(v) ((v)->value.var.value)
  63.  
  64. extern Value *assqv(Value *key, Value *assoc);
  65.