diff options
author | Bad Diode <bd@badd10de.dev> | 2021-10-29 15:37:28 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-10-29 15:37:28 +0200 |
commit | e73a4c16a2269cdb2f5e7d66fb9839e4c44e14de (patch) | |
tree | c44721b005b7a0623e7acc7103ca8e21a25ff422 /src/string_view.h | |
parent | fcc131afdd029c606ea39f3557bc3d33a075b1de (diff) | |
download | bdl-e73a4c16a2269cdb2f5e7d66fb9839e4c44e14de.tar.gz bdl-e73a4c16a2269cdb2f5e7d66fb9839e4c44e14de.zip |
Prepare third compiler implementation
Diffstat (limited to 'src/string_view.h')
-rwxr-xr-x | src/string_view.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/string_view.h b/src/string_view.h new file mode 100755 index 0000000..4dbbaaf --- /dev/null +++ b/src/string_view.h | |||
@@ -0,0 +1,25 @@ | |||
1 | #ifndef BDL_STRINGVIEW_H | ||
2 | #define BDL_STRINGVIEW_H | ||
3 | |||
4 | #include "common.h" | ||
5 | |||
6 | typedef struct StringView { | ||
7 | char *start; | ||
8 | size_t n; | ||
9 | } StringView; | ||
10 | |||
11 | // Consume a character in the stream. | ||
12 | char sv_next(StringView *sv); | ||
13 | |||
14 | // Check what is the current character in the stream. | ||
15 | char sv_peek(const StringView *sv); | ||
16 | |||
17 | // Compare if the arguments are the same. | ||
18 | bool sv_equal(const StringView *a, const StringView *b); | ||
19 | |||
20 | // Write a character to the given output stream. | ||
21 | void sv_write(const StringView *sv); | ||
22 | |||
23 | #define STRING(STR) (StringView){(STR), sizeof(STR) - 1} | ||
24 | |||
25 | #endif // BDL_STRINGVIEW_H | ||