cusel/compiler/tokenizer_internal.h
2026-11-26 15:05:22 +02:00

67 lines
938 B
C

// This file includes the type definitions for tokens and is meant to be
// included by other headers.
#ifndef CUSEL_TOKENIZER_INTERNAL_H
#define CUSEL_TOKENIZER_INTERNAL_H
#include "vector_internal.h"
struct source_location {
size_t offset;
size_t line;
size_t column;
};
enum token_id : int {
// Pseudotoken used by the parser to avoid constantly having to
// check for `index < LENGTH(tokens)`
TOK_EOF = 256,
// Pseudotoken used to mark tokenization errors
TOK_ERROR,
TOK_IDENTIFIER,
TOK_NATURAL,
TOK_FN,
TOK_TYPE,
TOK_BREAK,
TOK_CONTINUE,
TOK_DO,
TOK_ELIF,
TOK_ELSE,
TOK_END,
TOK_FOR,
TOK_IF,
TOK_IN,
TOK_MATCH,
TOK_OF,
TOK_RETURN,
TOK_THEN,
TOK_WHILE,
TOK_AND,
TOK_OR,
TOK_NOT,
TOK_ROL,
TOK_ROR,
TOK_SHL,
TOK_SHR,
TOK_LTE,
TOK_GTE,
TOK_EQ,
TOK_NEQ,
};
typedef struct {
struct source_location at;
size_t length;
enum token_id id;
} token;
DECL_VEC(token);
DECL_SPAN(token);
#endif