From eeff5e273f22aa28e81ab080e9ffdce85ac394b8 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Fri, 22 Oct 2021 09:59:31 +0200 Subject: Prepare skeleton for bytecode interpreter --- src/bytecode/string_view.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/bytecode/string_view.h (limited to 'src/bytecode/string_view.h') 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 @@ +#ifndef BDL_STRINGVIEW_H +#define BDL_STRINGVIEW_H + +typedef struct StringView { + char *start; + size_t n; +} StringView; + +// Consume a character in the stream. +char sv_next(StringView *sv); + +// Check what is the current character in the stream. +char sv_peek(const StringView *sv); + +// Compare if the arguments are the same. +bool sv_equal(const StringView *a, const StringView *b); + +// Write a character to the given output stream. +void sv_write(const StringView *sv, FILE *file); + +#endif // BDL_STRINGVIEW_H -- cgit v1.2.1