interpret/src/lex.h

40 lines
928 B
C
Raw Normal View History

2022-02-14 04:45:38 +00:00
#include <stddef.h>
2022-02-13 06:35:02 +00:00
2022-02-14 04:45:38 +00:00
int lex_looks_like_year(const char *, int *);
int lex_looks_like_month(const char *);
int lex_looks_like_day(const char *);
#define LEX_SYMBOL \
2022-02-16 03:48:50 +00:00
\
/* Results. */ \
X(END), X(SYNTAX), X(ILLEGAL), X(NOT_FOUND), \
\
/* Text. */ \
X(PARAGRAPH), X(TEXT), X(CAPTION), \
\
/* Edicts. */ \
X(SOURCE), X(DEFAULT), X(SOURCE_RECALL), \
X(LOCATION), X(LOCATION_SAVE), X(LOCATION_RECALL), \
2022-02-16 03:48:50 +00:00
X(SIGNIFICANT), X(SIGNIFICANT_RECALL), \
\
/* Arguments. */ \
2022-07-06 02:21:56 +00:00
X(ARG_KEYWORD), X(ARG_DATE), X(ARG_NATURAL), X(ARG_FREEFORM), \
\
/* Bible */ \
X(BIBLE_BOOK), X(BIBLE_CHAPTER_VERSE), X(BIBLE_TEXT), X(BIBLE_NEXT)
2022-02-14 04:45:38 +00:00
struct lex {
2022-02-16 03:48:50 +00:00
#define X(n) n
2022-02-14 04:45:38 +00:00
enum lex_symbol { LEX_SYMBOL } symbol;
2022-02-16 03:48:50 +00:00
#undef X
2022-02-14 04:45:38 +00:00
int ws_before, new_paragraph;
const char *s0, *s1;
size_t line;
};
#define X(n) #n
static const char *const lex_symbols[] = { LEX_SYMBOL };
#undef X
void lex_reset(const char *const buffer);
int lex_next(struct lex *);