summaryrefslogtreecommitdiff
path: root/src/reader.h
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2021-11-09 20:03:23 +0800
committerJSDurand <mmemmew@gmail.com>2021-11-09 20:03:23 +0800
commit53b8b6ffab5a968db75e9babddf4e2dbb2c688a3 (patch)
tree4ff55ae0027544b06702d24ec4840a2011f724e9 /src/reader.h
parent87b6bad500702b0fcd708ee5b1d99f61a29ec7e6 (diff)
save point: representation of grammar might be too rough.
The current representation of the grammar is the most primitive BNF. This is the simplest to implement, but is difficult to cope with user requirements. Moreover, I find another paper describing the GLR algorithm, so I need to think about the representation of the grammar more. In particular, I would like the generation of the grammar to be incremental, so per chance its data type should be adapted accordingly.
Diffstat (limited to 'src/reader.h')
-rw-r--r--src/reader.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/reader.h b/src/reader.h
index 16a4ca6..77e7b84 100644
--- a/src/reader.h
+++ b/src/reader.h
@@ -3,6 +3,32 @@
#include "grammar.h"
+/* The class of a general reader, which can read a grammar, either
+ from a file, or elsewhere, such as from an Emacs buffer, the
+ standard input, or even from some other places.
+
+ The only expectation, or requirement, of such a reader is to
+ provide a function with a variable number and type of arguments
+ which returns a grammar. Then the package provides a function to
+ properly read a grammar, according to the specifications of the
+ reader. */
+
+typedef Grammar *(*reader_func_t)(List *args);
+
+typedef struct Reader_s Reader;
+
+/* contructor */
+
+/* Build a reader and assign to *reader. It is expected to be
+ allocated before this function. */
+void build_reader(Reader *reader, reader_func_t func, List *args);
+
+/* destructor */
+
+/* Does not free READER.
+
+ FLAG is passed to destroy_list, which see. */
+void destroy_reader(Reader *reader, int flag);
#endif