mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Add keywords and identifiers Add comments Add number literals Add strings Add a lot of new tokens Add (and clean up) IF etc. Improve reporting of unexpected chars / garbage bytes Fix bug with and improved error messages when failing to open file Add verbose-level messages about how files are opened Enforce that files finish with a newline Fix chars returned not being cast to unsigned char (may conflict w/ EOF) Return null path when no file is open, rather than crash Unify and improve error printing slightly Known to be missing: macro expansion, REPT blocks, EQUS expansions
57 lines
1.2 KiB
C
57 lines
1.2 KiB
C
/*
|
|
* This file is part of RGBDS.
|
|
*
|
|
* Copyright (c) 1997-2018, Carsten Sorensen and RGBDS contributors.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#ifndef RGBDS_ASM_LEXER_H
|
|
#define RGBDS_ASM_LEXER_H
|
|
|
|
#define MAXSTRLEN 255
|
|
|
|
struct LexerState;
|
|
extern struct LexerState *lexerState;
|
|
extern struct LexerState *lexerStateEOL;
|
|
|
|
static inline struct LexerState *lexer_GetState(void)
|
|
{
|
|
return lexerState;
|
|
}
|
|
|
|
static inline void lexer_SetState(struct LexerState *state)
|
|
{
|
|
lexerState = state;
|
|
}
|
|
|
|
static inline void lexer_SetStateAtEOL(struct LexerState *state)
|
|
{
|
|
lexerStateEOL = state;
|
|
}
|
|
|
|
struct LexerState *lexer_OpenFile(char const *path);
|
|
struct LexerState *lexer_OpenFileView(void);
|
|
void lexer_DeleteState(struct LexerState *state);
|
|
void lexer_Init(void);
|
|
|
|
enum LexerMode {
|
|
LEXER_NORMAL,
|
|
LEXER_RAW,
|
|
LEXER_SKIP_TO_ELIF,
|
|
LEXER_SKIP_TO_ENDC
|
|
};
|
|
|
|
void lexer_SetMode(enum LexerMode mode);
|
|
void lexer_ToggleStringExpansion(bool enable);
|
|
|
|
char const *lexer_GetFileName(void);
|
|
uint32_t lexer_GetLineNo(void);
|
|
uint32_t lexer_GetColNo(void);
|
|
void lexer_DumpStringExpansions(void);
|
|
int yylex(void);
|
|
void lexer_CaptureBlock(int blockStartToken, int blockEndToken, char const **capture, size_t *size,
|
|
char const *name);
|
|
|
|
#endif /* RGBDS_ASM_LEXER_H */
|