aboutsummaryrefslogtreecommitdiffstats
path: root/src/string_view.h
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-10-29 15:37:28 +0200
committerBad Diode <bd@badd10de.dev>2021-10-29 15:37:28 +0200
commite73a4c16a2269cdb2f5e7d66fb9839e4c44e14de (patch)
treec44721b005b7a0623e7acc7103ca8e21a25ff422 /src/string_view.h
parentfcc131afdd029c606ea39f3557bc3d33a075b1de (diff)
downloadbdl-e73a4c16a2269cdb2f5e7d66fb9839e4c44e14de.tar.gz
bdl-e73a4c16a2269cdb2f5e7d66fb9839e4c44e14de.zip
Prepare third compiler implementation
Diffstat (limited to 'src/string_view.h')
-rwxr-xr-xsrc/string_view.h25
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
6typedef struct StringView {
7 char *start;
8 size_t n;
9} StringView;
10
11// Consume a character in the stream.
12char sv_next(StringView *sv);
13
14// Check what is the current character in the stream.
15char sv_peek(const StringView *sv);
16
17// Compare if the arguments are the same.
18bool sv_equal(const StringView *a, const StringView *b);
19
20// Write a character to the given output stream.
21void sv_write(const StringView *sv);
22
23#define STRING(STR) (StringView){(STR), sizeof(STR) - 1}
24
25#endif // BDL_STRINGVIEW_H