aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-06-11 00:18:25 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-06-11 00:18:25 +0200
commit8782928ff807c49c921945109538e118e22e4590 (patch)
tree9a93e6b221a82733d34d7dfd5734bda66c886489 /src
parentb105dee61824f2848b2f199943b7689ece2158b9 (diff)
Formatting
Diffstat (limited to 'src')
-rw-r--r--src/lexer.c20
-rw-r--r--src/lexer.h36
2 files changed, 22 insertions, 34 deletions
diff --git a/src/lexer.c b/src/lexer.c
index 4df1e52..4a71746 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -44,21 +44,9 @@ lexstring(const uchar *code, size_t codesz)
switch (ch) {
/* Single-byte literals */
- case '&':
- case '(':
- case ')':
- case '*':
- case '+':
- case '-':
- case ':':
- case ';':
- case '=':
- case '[':
- case ']':
- case '{':
- case '|':
- case '}':
- case '~':
+ case '&': case '(': case ')': case '*': case '+':
+ case '-': case ':': case ';': case '=': case '[':
+ case ']': case '{': case '|': case '}': case '~':
data.kinds[data.len++] = ch;
break;
@@ -143,7 +131,7 @@ mk_lexemes_soa(void)
static_assert(offsetof(struct lexemes_soa, kinds)
< offsetof(struct lexemes_soa, strs),
"KINDS is not the first field before STRS");
- static_assert((LEXEMES_DFLT_CAP * sizeof(*soa.kinds) % alignof(*soa.strs))
+ static_assert(LEXEMES_DFLT_CAP * sizeof(*soa.kinds) % alignof(*soa.strs)
== 0,
"Additional padding is required to properly align STRS");
diff --git a/src/lexer.h b/src/lexer.h
index e2862bb..7fd8533 100644
--- a/src/lexer.h
+++ b/src/lexer.h
@@ -7,26 +7,26 @@
#include "types.h"
enum {
- LEXIDENT,
+ LEXIDENT, /* Identifier */
- LEXAMP = '&',
- LEXCOLON = ':',
- LEXEQ = '=',
- LEXLANGL = '<',
+ LEXAMP = '&',
+ LEXCOLON = ':',
+ LEXEQ = '=',
+ LEXLANGL = '<',
LEXLBRACE = '{',
- LEXLBRKT = '[',
- LEXLPAR = '(',
- LEXMINUS = '-',
- LEXPIPE = '|',
- LEXPLUS = '+',
- LEXRANGL = '>',
+ LEXLBRKT = '[',
+ LEXLPAR = '(',
+ LEXMINUS = '-',
+ LEXPIPE = '|',
+ LEXPLUS = '+',
+ LEXRANGL = '>',
LEXRBRACE = '}',
- LEXRBRKT = ']',
- LEXRPAR = ')',
- LEXSEMI = ';',
- LEXSLASH = '/',
- LEXSTAR = '*',
- LEXTILDE = '~',
+ LEXRBRKT = ']',
+ LEXRPAR = ')',
+ LEXSEMI = ';',
+ LEXSLASH = '/',
+ LEXSTAR = '*',
+ LEXTILDE = '~',
/* We keep these exactly 2 away from each other, because ‘<’ and ‘>’ are 2
away from each other in ASCII. This gives us a simple mapping from some
@@ -45,7 +45,7 @@ struct lexemes_soa {
size_t len, cap;
};
-#define lexemes_free(x) free(x.kinds)
+#define lexemes_free(x) free((x).kinds)
struct lexemes_soa lexstring(const uchar *, size_t);