diff options
author | Bad Diode <bd@badd10de.dev> | 2021-10-22 09:59:31 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-10-22 09:59:31 +0200 |
commit | eeff5e273f22aa28e81ab080e9ffdce85ac394b8 (patch) | |
tree | 71d11c76be7c0bb649099bb55e6181f9b7c6c8a8 /src/bytecode/string_view.h | |
parent | 5bd694fc7071bfb76b9f65c89d253b2b4e18cf63 (diff) | |
download | bdl-eeff5e273f22aa28e81ab080e9ffdce85ac394b8.tar.gz bdl-eeff5e273f22aa28e81ab080e9ffdce85ac394b8.zip |
Prepare skeleton for bytecode interpreter
Diffstat (limited to 'src/bytecode/string_view.h')
-rw-r--r-- | src/bytecode/string_view.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/bytecode/string_view.h b/src/bytecode/string_view.h new file mode 100644 index 0000000..42273ab --- /dev/null +++ b/src/bytecode/string_view.h | |||
@@ -0,0 +1,21 @@ | |||
1 | #ifndef BDL_STRINGVIEW_H | ||
2 | #define BDL_STRINGVIEW_H | ||
3 | |||
4 | typedef struct StringView { | ||
5 | char *start; | ||
6 | size_t n; | ||
7 | } StringView; | ||
8 | |||
9 | // Consume a character in the stream. | ||
10 | char sv_next(StringView *sv); | ||
11 | |||
12 | // Check what is the current character in the stream. | ||
13 | char sv_peek(const StringView *sv); | ||
14 | |||
15 | // Compare if the arguments are the same. | ||
16 | bool sv_equal(const StringView *a, const StringView *b); | ||
17 | |||
18 | // Write a character to the given output stream. | ||
19 | void sv_write(const StringView *sv, FILE *file); | ||
20 | |||
21 | #endif // BDL_STRINGVIEW_H | ||