summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorIan Moffett <ian@mirocom.org>2026-05-23 02:21:09 -0400
committerIan Moffett <ian@mirocom.org>2026-05-23 02:21:09 -0400
commit74e2e8c772d0f88da6684918f782b37156f10fb3 (patch)
treefa5d9431e7e3f8df98f1d7f8e5dc9f8c02d09002 /include
parent659dd389326f73e6bcbce5311088c182d7cb580e (diff)
core: Add lexer + parser groundwork
Signed-off-by: Ian Moffett <ian@mirocom.org>
Diffstat (limited to 'include')
-rw-r--r--include/cescal/lexer.h24
-rw-r--r--include/cescal/parser.h20
-rw-r--r--include/cescal/token.h38
3 files changed, 82 insertions, 0 deletions
diff --git a/include/cescal/lexer.h b/include/cescal/lexer.h
new file mode 100644
index 0000000..7d4a9b4
--- /dev/null
+++ b/include/cescal/lexer.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2026, Chloe M.
+ * Provided under the BSD-3 clause
+ */
+
+#ifndef CESCAL_LEXER_H
+#define CESCAL_LEXER_H 1
+
+#include <stdint.h>
+#include <stddef.h>
+#include "cescal/token.h"
+#include "cescal/state.h"
+
+/*
+ * Consume a single token from the input source file
+ *
+ * @state: Compiler state
+ * @res: Token result is written here
+ *
+ * Returns zero on success
+ */
+int lexer_nom(struct cescal_state *state, struct token *res);
+
+#endif /* !CESCAL_LEXER_H */
diff --git a/include/cescal/parser.h b/include/cescal/parser.h
new file mode 100644
index 0000000..c97006b
--- /dev/null
+++ b/include/cescal/parser.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2026, Chloe M.
+ * Provided under the BSD-3 clause
+ */
+
+#ifndef CESCAL_PARSER_H
+#define CESCAL_PARSER_H 1
+
+#include "cescal/state.h"
+
+/*
+ * Begin parsing the input source file
+ *
+ * @state: Compiler state
+ *
+ * Returns zero on success
+ */
+int parser_parse(struct cescal_state *state);
+
+#endif /* !CESCAL_PARSER_H */
diff --git a/include/cescal/token.h b/include/cescal/token.h
new file mode 100644
index 0000000..0be8ff0
--- /dev/null
+++ b/include/cescal/token.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2026, Chloe M.
+ * Provided under the BSD-3 clause
+ */
+
+#ifndef CESCAL_TOKEN_H
+#define CESCAL_TOKEN_H 1
+
+/*
+ * Represents valid source file token types
+ */
+typedef enum {
+ TT_NONE, /* [none] */
+ TT_IDENT, /* [identifier] */
+ TT_INTLIT, /* [0-9]+ */
+ TT_LPAREN, /* '(' */
+ TT_RPAREN, /* '( */
+ TT_COMMA, /* ',' */
+ TT_RETURN, /* 'return' */
+ TT_PUB, /* 'pub' */
+ TT_PROC, /* 'proc' */
+ TT_BEGIN, /* 'begin' */
+ TT_END, /* 'end' */
+} tt_t;
+
+/*
+ * Represents a source file token
+ *
+ * @type: Token type
+ */
+struct token {
+ tt_t type;
+ union {
+ char c;
+ };
+};
+
+#endif /* !CESCAL_TOKEN_H */