2026-05-23 02:21:09 -04:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2026, Chloe M.
|
|
|
|
|
* Provided under the BSD-3 clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef CESCAL_TOKEN_H
|
|
|
|
|
#define CESCAL_TOKEN_H 1
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Represents valid source file token types
|
|
|
|
|
*/
|
|
|
|
|
typedef enum {
|
|
|
|
|
TT_NONE, /* [none] */
|
|
|
|
|
TT_IDENT, /* [identifier] */
|
2026-05-23 08:09:05 -04:00
|
|
|
TT_COMMENT, /* [comment : ignored] */
|
2026-05-23 02:21:09 -04:00
|
|
|
TT_INTLIT, /* [0-9]+ */
|
|
|
|
|
TT_LPAREN, /* '(' */
|
|
|
|
|
TT_RPAREN, /* '( */
|
|
|
|
|
TT_COMMA, /* ',' */
|
2026-05-23 08:10:57 -04:00
|
|
|
TT_ARROW, /* '->' */
|
2026-05-23 08:49:17 -04:00
|
|
|
TT_DEFINE, /* '#define' */
|
|
|
|
|
TT_IFNDEF, /* '#ifndef' */
|
|
|
|
|
TT_IFDEF, /* '#ifdef' */
|
2026-05-23 02:21:09 -04:00
|
|
|
TT_RETURN, /* 'return' */
|
|
|
|
|
TT_PUB, /* 'pub' */
|
|
|
|
|
TT_PROC, /* 'proc' */
|
|
|
|
|
TT_BEGIN, /* 'begin' */
|
|
|
|
|
TT_END, /* 'end' */
|
2026-05-23 08:52:56 -04:00
|
|
|
TT_U8, /* 'u8' */
|
|
|
|
|
TT_U16, /* 'u16' */
|
|
|
|
|
TT_U32, /* 'u32' */
|
|
|
|
|
TT_U64, /* 'u64' */
|
2026-05-23 02:21:09 -04:00
|
|
|
} tt_t;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Represents a source file token
|
|
|
|
|
*
|
|
|
|
|
* @type: Token type
|
|
|
|
|
*/
|
|
|
|
|
struct token {
|
|
|
|
|
tt_t type;
|
|
|
|
|
union {
|
|
|
|
|
char c;
|
2026-05-23 10:53:41 +00:00
|
|
|
char *s;
|
2026-05-23 02:21:09 -04:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif /* !CESCAL_TOKEN_H */
|