quip: Add initial lexer sources + example ref

Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
2026-03-21 07:15:54 -04:00
parent 0fa8ad12ca
commit 6f7b4b5e31
6 changed files with 214 additions and 2 deletions

19
include/frontend/lexer.h Normal file
View File

@@ -0,0 +1,19 @@
#ifndef FRONTEND_LEXER_H
#define FRONTEND_LEXER_H 1
#include <stdint.h>
#include <stddef.h>
#include "frontend/token.h"
#include "common/state.h"
/*
* Scan for a single token within the source file
*
* @state: Quip state
* @tokres: Token result is written here
*
* Returns zero on success
*/
int lexer_scan(struct quip_state *state, struct token *tokres);
#endif /* !FRONTEND_LEXER_H */

36
include/frontend/token.h Normal file
View File

@@ -0,0 +1,36 @@
/*
* Copyright (c) 2026, Mirocom Laboratories
* Provided under the BSD-3 clause
*
* Abstract:
* This file defines the list of valid tokens.
* Author:
* Ian M. Moffett <ian@mirocom.org>
*/
#ifndef FRONTEND_TOKEN_H
#define FRONTEND_TOKEN_H 1
/*
* Represents valid token types
*/
typedef enum {
TT_NONE, /* [none] */
TT_NAME, /* [name] */
TT_NEWLINE, /* [newline] */
TT_COLON, /* ':' */
} tt_t;
/*
* Represents a lexical token
*
* @type: Token type
*/
struct token {
tt_t type;
union {
char c;
};
};
#endif /* !FRONTEND_TOKEN_H */