2022-09-07 20:42:37 -07:00
|
|
|
#ifndef IO_H
|
|
|
|
#define IO_H
|
2022-09-05 23:48:56 -07:00
|
|
|
|
2022-09-07 20:42:37 -07:00
|
|
|
#include <stddef.h>
|
2022-09-05 23:48:56 -07:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
void open_files(const char* infile_name, const char* outfile_name);
|
|
|
|
void close_files(void);
|
|
|
|
|
2022-09-06 23:16:23 -07:00
|
|
|
void reserve(size_t len);
|
2022-09-05 23:48:56 -07:00
|
|
|
void emit(const void* ptr, size_t count);
|
|
|
|
void emit_u8(uint8_t x);
|
|
|
|
void emit_u32(uint32_t x);
|
|
|
|
void emit_u64(uint64_t x);
|
|
|
|
|
|
|
|
void patch(size_t off, const void* ptr, size_t count);
|
|
|
|
void patch_u32(size_t off, uint32_t x);
|
|
|
|
void patch_i32(size_t off, int32_t x);
|
|
|
|
|
Greatly simplify lexer thanks to new knowledge of lookahead.
Now I know that the parser is LL(1) and the lexer also only
needs one-character lookahead, which allows me to dramatically
simplify the interface for IO input, and improve the interface
to the lexer. Even if I did want unbounded peek, I'd want
the interface to be `peek(off)`, not that awful buffer.
I intend to use the new lexer interface to make the parser
states more stateful, and potentially read multiple tokens
in a row. Then, states would only be needed for recursive
structures, without the awkward intermediate states like
ST_LABEL which exists only to let me burn a token.
I also removed the nonsense related to base 64 parsing,
because it was unclear how to handle it, and the advantages
of having it weren't clear. I kept up to base 36, but honestly
I might want to consider getting rid of everything but decimal,
hex, and binary anyway. I'm not sure if I'd want to keep using
the current syntax for the radix either.
2022-09-07 23:02:15 -07:00
|
|
|
char nextc(void);
|
|
|
|
void unnextc(char c);
|
|
|
|
char peekc(void);
|
2022-09-07 10:22:38 -07:00
|
|
|
|
2022-09-05 23:48:56 -07:00
|
|
|
#endif
|