aboutsummaryrefslogtreecommitdiff
path: root/src/lexer
diff options
context:
space:
mode:
Diffstat (limited to 'src/lexer')
-rw-r--r--src/lexer/Lexer.zig9
-rw-r--r--src/lexer/Token.zig11
2 files changed, 10 insertions, 10 deletions
diff --git a/src/lexer/Lexer.zig b/src/lexer/Lexer.zig
index 983aa23..4137b40 100644
--- a/src/lexer/Lexer.zig
+++ b/src/lexer/Lexer.zig
@@ -54,7 +54,7 @@ pub fn next(self: *Self) ?Token {
// conds here to avoid creating complex condition in while
const next_rune = self.iter.peek(1);
const next_kind = self.getCurrentKind(current_kind, next_rune, self.content[beg..end]).kind;
- if (requiresSpace(current_kind.?) and next_kind != current_kind.?) {
+ if (current_kind.?.requiresSpace() and next_kind != current_kind.?) {
if (eql(u8, next_rune, " ")) {
// consume next space
_ = self.iter.nextCodepoint();
@@ -166,13 +166,6 @@ fn isOneOrThree(op: []const u8, rune: []const u8, p: []const u8, one: Token.Kind
};
}
-fn requiresSpace(k: Token.Kind) bool {
- return switch (k) {
- .title, .list_ordored, .list_unordored => true,
- else => false,
- };
-}
-
fn doTest(l: *Self, k: Token.Kind, v: []const u8) !void {
var first = l.next().?;
std.testing.expect(first.equals(k, v)) catch |err| {
diff --git a/src/lexer/Token.zig b/src/lexer/Token.zig
index bd2a07b..bd0bdc2 100644
--- a/src/lexer/Token.zig
+++ b/src/lexer/Token.zig
@@ -21,19 +21,26 @@ pub const Kind = enum {
list_unordored,
tag,
- pub fn isDelimiter(self: @This()) bool {
+ pub inline fn isDelimiter(self: @This()) bool {
return switch (self) {
.weak_delimiter, .strong_delimiter => true,
else => false,
};
}
- pub fn isPar(self: @This()) bool {
+ pub inline fn isPar(self: @This()) bool {
return switch (self) {
.literal, .link, .code, .math, .bold, .italic, .ref => true,
else => false,
};
}
+
+ pub inline fn requiresSpace(self: @This()) bool {
+ return switch (self) {
+ .title, .list_ordored, .list_unordored => true,
+ else => false,
+ };
+ }
};
kind: Kind,