summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/parser.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/core/parser.c b/core/parser.c
index 6cf0a4e..a92c6cb 100644
--- a/core/parser.c
+++ b/core/parser.c
@@ -32,11 +32,30 @@ static const char *toktab[] = {
[TT_COMMA] = LITTOK(",")
};
+/*
+ * Parse a specific token
+ *
+ * @state: Assembler state machine
+ * @tok: Token to parse at
+ *
+ * Returns zero on success
+ */
+static int
+parse_token(struct atas_state *state, struct atas_token *tok)
+{
+ if (state == NULL) {
+ return -1;
+ }
+
+ printf("got token %s\n", TOK_STR(tok->type));
+ return 0;
+}
+
int
atas_parse(struct atas_state *state)
{
- int error;
struct atas_token tok;
+ int error;
if (state == NULL) {
return -1;
@@ -48,7 +67,10 @@ atas_parse(struct atas_state *state)
break;
}
- printf("got token %s\n", TOK_STR(tok.type));
+ error = parse_token(state, &tok);
+ if (error < 0) {
+ return -1;
+ }
}
return 0;