/* * Copyright (c) 2026, Mirocom Laboratories * Provided under the BSD-3 clause * * Abstract: * This file implements the parser. * Author: * Ian M. Moffett */ #include #include "frontend/parser.h" #include "frontend/lexer.h" #include "frontend/token.h" /* Symbolic token */ #define symtok(tokstr) \ "[" tokstr "]" /* Quoted string */ #define qtok(tokstr) \ "'" tokstr "'" /* Convert token to string */ #define tokstr1(tt) \ toktab[(tt)] /* Convert token to string */ #define tokstr(tok) \ tokstr1((tok)->type) /* * Table used to convert token constants into human * readable strings for debugging */ static const char *toktab[] = { [TT_NONE] = symtok("none"), [TT_NAME] = symtok("name"), [TT_NEWLINE] = symtok("newline"), [TT_SHELLBLOCK] = symtok("shellblock"), [TT_COMMENT] = symtok("comment"), [TT_CC] = qtok(".cc"), [TT_LD] = qtok(".ld"), [TT_COLON] = qtok(":") }; int parser_parse(struct quip_state *state) { struct token token; if (state == NULL) { return -1; } while (lexer_scan(state, &token) == 0) { printf("got token %s\n", tokstr(&token)); } return 0; }