|
Luma 0.1.0
A low-level compiled alternative to C, C++, and more!
|
Tokenizer (lexer) definitions and API for lexical analysis of source code. More...


Go to the source code of this file.
Classes | |
| struct | Lexer |
| Lexer state object for scanning source code. More... | |
| struct | Token |
| Represents a single token extracted by the lexer. More... | |
| struct | SymbolEntry |
| Maps symbol text to token type for quick lookup. More... | |
| struct | KeywordEntry |
| Maps keyword text to token type for quick lookup. More... | |
Functions | |
| void | report_lexer_error (Lexer *lx, const char *error_type, const char *file, const char *msg, const char *line_text, int line, int col, int tk_length) |
| Reports a lexer error by adding an error to the global error list. | |
| const char * | get_line_text_from_source (const char *source, int target_line) |
| Retrieves the text of a specific line from the source code. | |
| void | init_lexer (Lexer *lexer, const char *source, ArenaAllocator *arena) |
| Initializes the lexer with source code and memory arena. | |
| Token | next_token (Lexer *lexer) |
| Returns the next token parsed from the source code. | |
Tokenizer (lexer) definitions and API for lexical analysis of source code.
Provides token types, lexer state, token structure, and functions to initialize a lexer, retrieve tokens, and report lexer errors.
| enum LumaTokenType |
Enumeration of all possible token types recognized by the lexer.
| const char * get_line_text_from_source | ( | const char * | source, |
| int | target_line | ||
| ) |
Retrieves the text of a specific line from the source code.
| source | Full source code string |
| target_line | The 1-based line number to extract |
Retrieves the text of a specific line from the source code.
| source | Full source code string |
| target_line | Line number to extract (1-based) |
| void init_lexer | ( | Lexer * | lexer, |
| const char * | source, | ||
| ArenaAllocator * | arena | ||
| ) |
Initializes the lexer with source code and memory arena.
| lexer | Pointer to Lexer to initialize |
| source | Source code string |
| arena | Arena allocator to use for memory allocations |
Initializes the lexer with source code and memory arena.
| lexer | Pointer to Lexer struct to initialize |
| source | Source code string |
| arena | Arena allocator to allocate tokens and strings |
| void report_lexer_error | ( | Lexer * | lx, |
| const char * | error_type, | ||
| const char * | file, | ||
| const char * | msg, | ||
| const char * | line_text, | ||
| int | line, | ||
| int | col, | ||
| int | tk_length | ||
| ) |
Reports a lexer error by adding an error to the global error list.
| lx | Pointer to Lexer |
| error_type | String describing the type of error |
| file | File path of the source file |
| msg | Error message string |
| line_text | Source code line text where error occurred |
| line | Line number of error |
| col | Column number of error |
| tk_length | Length of the erroneous token |
Reports a lexer error by adding an error to the global error list.
| lx | Lexer instance pointer |
| error_type | Description of the error type |
| file | Source file path |
| msg | Error message |
| line_text | Source code line text where error occurred |
| line | Line number of the error |
| col | Column number of the error |
| tk_length | Length of the token causing the error |