wacc/lexer.h
2023-02-11 20:14:13 +01:00

77 lines
1.3 KiB
C

#ifndef LEXER_H
#define LEXER_H
#include <stddef.h>
typedef enum {
TokenTypeEof,
TokenTypeInvalidChar,
TokenTypeMalformedMultilineComment,
TokenTypeMalformedChar,
TokenTypeMalformedString,
TokenTypeId,
TokenTypeInt,
TokenTypeHex,
TokenTypeBinary,
TokenTypeFloat,
TokenTypeChar,
TokenTypeString,
TokenTypeIf,
TokenTypeElse,
TokenTypeWhile,
TokenTypeBreak,
TokenTypeLParen,
TokenTypeRParen,
TokenTypeLBrace,
TokenTypeRBrace,
TokenTypeLBracket,
TokenTypeRBracket,
TokenTypeDot,
TokenTypeComma,
TokenTypeColon,
TokenTypeSemicolon,
TokenTypePlusEqual,
TokenTypeMinusEqual,
TokenTypeAsteriskEqual,
TokenTypeSlashEqual,
TokenTypePercentEqual,
TokenTypeDoubleEqual,
TokenTypeExclamationEqual,
TokenTypeLtEqual,
TokenTypeGtEqual,
TokenTypePlus,
TokenTypeMinus,
TokenTypeAsterisk,
TokenTypeSlash,
TokenTypePercent,
TokenTypeEqual,
TokenTypeExclamation,
TokenTypeLt,
TokenTypeGt,
} TokenType;
typedef struct {
size_t index;
int line, column;
} Position;
typedef struct {
TokenType type;
Position position;
size_t length;
} Token;
typedef struct Lexer Lexer;
void lexer_create(Lexer* lexer, const char* text, size_t text_length);
Token lexer_next(Lexer* lexer);
#endif