summaryrefslogtreecommitdiff
path: root/igen/lexer.c
diff options
context:
space:
mode:
Diffstat (limited to 'igen/lexer.c')
-rw-r--r--igen/lexer.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/igen/lexer.c b/igen/lexer.c
index 03f7e87..1d3268e 100644
--- a/igen/lexer.c
+++ b/igen/lexer.c
@@ -4,12 +4,13 @@
#include <string.h>
#include "lexer.h"
#include "misc.h"
+#include "preprocessor.h"
-cond_stmt *lex_cond_stmt(char **str, int dbg) {
+cond_stmt *lex_cond_stmt(source *src, int dbg) {
}
-stmt *lex_comp_stmt(char **str, int dbg) {
+stmt *lex_comp_stmt(source *src, int dbg) {
char *tmp = *str;
if (*tmp++ == '{') {
stmt *s = lex_stmt(&tmp, dbg);
@@ -17,13 +18,13 @@ stmt *lex_comp_stmt(char **str, int dbg) {
*str = tmp;
return s;
} else {
- throw_error("Missing \'}\' in stmt.");
+ throw_error(src, 1, "Missing \'}\' in compound statement.");
}
}
return NULL;
}
-stmt *lex_stmt(char **str, int dbg) {
+stmt *lex_stmt(source *src, int dbg) {
const alt_stmt alts[] = {
{STMT_DIR, offsetof(stmt, dir), lex_dir},
{STMT_FUNC, offsetof(stmt, func), lex_func},
@@ -45,7 +46,7 @@ stmt *lex_stmt(char **str, int dbg) {
return NULL;
}
-stmt *lex_library(char **str, stmt **end, int dbg) {
+stmt *lex_library(source *src, stmt **end, int dbg) {
stmt *start = lex_stmt(str, dbg);
end = (end != NULL) ? end : &start;
for (stmt *s = start; s != NULL; s = lex_stmt(str, dbg)) {
@@ -59,6 +60,8 @@ int lex(char *str, int dbg) {
stmt *start = NULL;
stmt *end = NULL;
+ source *src = preprocess(str, dbg);
start = library(&str, &end, dbg);
+
return (start != NULL && end != NULL);
}