summaryrefslogtreecommitdiff
path: root/kicad/sexpr.h
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-22 01:10:55 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-22 01:12:05 -0300
commit5dcb2ebc6dd87d1088f5276f271f12faae0e5990 (patch)
treefa3b17a95c2a01431e5e7eeab81f39f43d9898a4 /kicad/sexpr.h
parent810869362ff13d5eaec4c9104b77308a83d8687a (diff)
downloadeeshow-5dcb2ebc6dd87d1088f5276f271f12faae0e5990.tar.gz
eeshow-5dcb2ebc6dd87d1088f5276f271f12faae0e5990.tar.bz2
eeshow-5dcb2ebc6dd87d1088f5276f271f12faae0e5990.zip
eeshow/kicad/sexpr.c, sexpr.h: simple parser for S-expressions
Diffstat (limited to 'kicad/sexpr.h')
-rw-r--r--kicad/sexpr.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/kicad/sexpr.h b/kicad/sexpr.h
new file mode 100644
index 0000000..8c47f28
--- /dev/null
+++ b/kicad/sexpr.h
@@ -0,0 +1,47 @@
+/*
+ * kicad/sexpr.h - S-expression parser
+ *
+ * Written 2016 by Werner Almesberger
+ * Copyright 2016 by Werner Almesberger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+
+#ifndef KICAD_SEXPR_H
+#define KICAD_SEXPR_H
+
+#include <stdbool.h>
+
+
+/*
+ * Expression type:
+ *
+ * s e Meaning
+ * ------------ -------- ----------
+ * NULL NULL "" or ()
+ * non-NULL NULL foo or "foo"
+ * NULL non-NULL (...)
+ * non-NULL non-NULL trouble
+ */
+
+struct expr {
+ char *s; /* string or NULL */
+ struct expr *e; /* sub-sexpr or NULL*/
+ struct expr *next;
+};
+
+struct sexpr_ctx;
+
+
+void dump_expr(const struct expr *e);
+void free_expr(struct expr *e);
+
+struct sexpr_ctx *sexpr_new(void);
+bool sexpr_parse(struct sexpr_ctx *ctx, const char *s);
+bool sexpr_finish(struct sexpr_ctx *ctx, struct expr **res);
+
+#endif /* !KICAD_SEXPR_H */