File: sexp.h

package info (click to toggle)
vflib3 3.6.14.dfsg-3+nmu3
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 11,536 kB
  • ctags: 3,710
  • sloc: ansic: 35,811; sh: 10,357; asm: 3,290; makefile: 962; lisp: 123; perl: 109; awk: 43
file content (107 lines) | stat: -rw-r--r-- 3,590 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* sexp.h - a header for vfsexp.c
 *
 *  Programmmed by Hirotsugu Kakugawa
 *  E-Mail:  h.kakugawa@computer.org
 *
 *  Edition History
 *  7 Jan 1998  First implementation
 */

/*
 * Copyright (C) 1997-1998 Hirotsugu Kakugawa. 
 * All rights reserved.
 *
 * This file is part of the VFlib Library.  This library is free
 * software; you can redistribute it and/or modify it under the terms of
 * the GNU Library General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your
 * option) any later version.  This library is distributed in the hope
 * that it will be useful, but WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU Library General Public License for more details.
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef __VFLIB_SEXP_H__
#define __VFLIB_SEXP_H__

typedef struct  s_sexp   *SEXP;

struct s_sexp_cons {
  SEXP   car;
  SEXP   cdr;
};

struct s_sexp {
  int    tag;                  /* data type */
  union {
    struct s_sexp_cons  cons;  /* cons */
    char                *str;  /* string or symbol */
  } t;
};


/* Data type.
 * String and Symbol are the same type except 
 * they are printed different ways by pretty-printer. */
#define VF_SEXP_TAG_NIL        0
#define VF_SEXP_TAG_CONS       1
#define VF_SEXP_TAG_STRING     2
#define VF_SEXP_TAG_SYMBOL     3
#define VF_SEXP_TAG_RELEASED 255

#define SEXP_LIST     SEXP
#define SEXP_ALIST    SEXP
#define SEXP_STRING   SEXP


extern SEXP   vf_sexp_cons(SEXP s1, SEXP s2);
extern SEXP   vf_sexp_car(SEXP s);
extern SEXP   vf_sexp_cdr(SEXP s);
extern SEXP   vf_sexp_caar(SEXP s);
extern SEXP   vf_sexp_cadr(SEXP s);
extern SEXP   vf_sexp_cdar(SEXP s);
extern SEXP   vf_sexp_cddr(SEXP s);
extern SEXP   vf_sexp_caddr(SEXP s);
extern void   vf_sexp_rplaca(SEXP s, SEXP val);
extern void   vf_sexp_rplacd(SEXP s, SEXP val);
extern int    vf_sexp_atom(SEXP s);
extern int    vf_sexp_null(SEXP s);
extern int    vf_sexp_consp(SEXP s);
extern int    vf_sexp_stringp(SEXP s);
extern char*  vf_sexp_get_cstring(SEXP s);
extern int    vf_sexp_listp(SEXP s);
extern int    vf_sexp_alistp(SEXP s);
extern int    vf_sexp_length(SEXP s);
extern int    vf_sexp_member(char *key, SEXP s);
extern SEXP   vf_sexp_assoc(char *key, SEXP s);
extern SEXP   vf_sexp_alist_put(char *key, char *val, SEXP_ALIST alist);
extern SEXP   vf_sexp_copy(SEXP s);
extern SEXP   vf_sexp_list1(SEXP s);
extern SEXP   vf_sexp_list2(SEXP s1, SEXP s2);
extern void   vf_sexp_nconc(SEXP s1, SEXP s2);
extern SEXP   vf_sexp_empty_list(void);
extern SEXP   vf_sexp_getf(SEXP s, char *key); 

extern SEXP   vf_sexp_cstring2string(char *str);
extern SEXP   vf_sexp_cstring2list(char *str);
extern SEXP   vf_sexp_cstring2alist(char *str);

extern SEXP   vf_sexp_read(FILE *fp);
extern SEXP   vf_sexp_read_from_file_stream(FILE *fp);
extern SEXP   vf_sexp_read_from_string_stream(char *str);

extern void   vf_sexp_pp(SEXP s);
extern void   vf_sexp_pp_fp(SEXP s, FILE* fp);
extern void   vf_sexp_pp_entry(SEXP s);
extern void   vf_sexp_pp_entry_fp(SEXP s, FILE* fp);

extern void   vf_sexp_free(SEXP *s);
extern void   vf_sexp_free1(SEXP *s1);
extern void   vf_sexp_free2(SEXP *s1, SEXP *s2);
extern void   vf_sexp_free3(SEXP *s1, SEXP *s2, SEXP *s3);
extern void   vf_sexp_free4(SEXP *s1, SEXP *s2, SEXP *s3, SEXP *s4);

#endif /*__VFLIB_SEXP_H__*/