interpret/src/lex.h

40 lines
947 B
C
Raw Normal View History

2022-02-13 23:45:38 -05:00
#include <stddef.h>
2022-02-13 01:35:02 -05:00
2022-02-13 23:45:38 -05: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-15 22:48:50 -05: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-07-06 13:02:28 -04:00
X(SIGNIFICANT), X(SIGNIFICANT_RECALL), X(EDITORIALIZING), \
2022-02-15 22:48:50 -05:00
\
/* Arguments. */ \
2022-07-05 22:21:56 -04: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-13 23:45:38 -05:00
struct lex {
2022-02-15 22:48:50 -05:00
#define X(n) n
2022-02-13 23:45:38 -05:00
enum lex_symbol { LEX_SYMBOL } symbol;
2022-02-15 22:48:50 -05:00
#undef X
2022-02-13 23:45:38 -05: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 *);