File: lispish.h

package info (click to toggle)
gsumi 0.8-2
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 344 kB
  • ctags: 421
  • sloc: ansic: 5,088; makefile: 58; sh: 17
file content (42 lines) | stat: -rw-r--r-- 1,049 bytes parent folder | download | duplicates (6)
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
/* "lispish" nested lists of strings.
 *
 * gsumi version 0.5
 *
 * Copyright 1997 Owen Taylor <owt1@cornell.edu>
*/

/* The two possibilities for a node */
typedef enum {
  NODE_STRING,
  NODE_LIST
} NodeType;

/* the basic structure which comprises a tree */
typedef struct _Node Node;

struct _Node {
  NodeType type;
  union {
    char *s;
    Node *l;
  } c;
  Node *next;
};

void node_free(Node *node);
Node *node_string_from_file(FILE *file);
Node *node_list_from_file(FILE *file, int is_toplevel);
void node_string_to_file(Node *node,FILE *file);
void node_list_to_file(Node *node, FILE *file, int level);
Node *node_list_new();
Node *node_string_new(char *str);
void node_list_append(Node *list, Node *new);

Node *node_pair_double(char *key, double val);
Node *node_pair_string(char *key, char *val);
Node *node_list_remove_pair(Node *list, char *key);
char *node_list_lookup_pair(Node *list, char *key);

int node_list_matches(Node *node, ...);
Node *node_list_remove_match(Node *list, ...);
Node *node_list_find_match(Node *list, ...);