Root/eeshow/kicad/sexpr.h

1/*
2 * kicad/sexpr.h - S-expression parser
3 *
4 * Written 2016 by Werner Almesberger
5 * Copyright 2016 by Werner Almesberger
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13
14#ifndef KICAD_SEXPR_H
15#define KICAD_SEXPR_H
16
17#include <stdbool.h>
18
19
20/*
21 * Expression type:
22 *
23 * s e Meaning
24 * ------------ -------- ----------
25 * NULL NULL "" or ()
26 * non-NULL NULL foo or "foo"
27 * NULL non-NULL (...)
28 * non-NULL non-NULL trouble
29 */
30
31struct expr {
32    char *s; /* string or NULL */
33    struct expr *e; /* sub-sexpr or NULL*/
34    struct expr *next;
35};
36
37struct sexpr_ctx;
38
39
40void dump_expr(const struct expr *e);
41void free_expr(struct expr *e);
42
43struct sexpr_ctx *sexpr_new(void);
44bool sexpr_parse(struct sexpr_ctx *ctx, const char *s);
45void sexpr_abort(struct sexpr_ctx *ctx);
46bool sexpr_finish(struct sexpr_ctx *ctx, struct expr **res);
47
48#endif /* !KICAD_SEXPR_H */
49

Archive Download this file

Branches:
master



interactive