ded

Dramatic EDitor
Index Commits Files Refs README LICENSE
src/lexer.h (831B)
   1 #ifndef LEXER_H_
   2 #define LEXER_H_
   3 
   4 #include <stddef.h>
   5 #include "./la.h"
   6 #include "./free_glyph.h"
   7 
   8 typedef enum {
   9     TOKEN_END = 0,
  10     TOKEN_INVALID,
  11     TOKEN_PREPROC,
  12     TOKEN_SYMBOL,
  13     TOKEN_OPEN_PAREN,
  14     TOKEN_CLOSE_PAREN,
  15     TOKEN_OPEN_CURLY,
  16     TOKEN_CLOSE_CURLY,
  17     TOKEN_SEMICOLON,
  18     TOKEN_KEYWORD,
  19     TOKEN_COMMENT,
  20     TOKEN_STRING,
  21 } Token_Kind;
  22 
  23 const char *token_kind_name(Token_Kind kind);
  24 
  25 typedef struct {
  26     Token_Kind kind;
  27     const char *text;
  28     size_t text_len;
  29     Vec2f position;
  30 } Token;
  31 
  32 typedef struct {
  33     Free_Glyph_Atlas *atlas;
  34     const char *content;
  35     size_t content_len;
  36     size_t cursor;
  37     size_t line;
  38     size_t bol;
  39     float x;
  40 } Lexer;
  41 
  42 Lexer lexer_new(Free_Glyph_Atlas *atlas, const char *content, size_t content_len);
  43 Token lexer_next(Lexer *l);
  44 
  45 #endif // LEXER_H_