commit a525385a676bc22ee95671aa1809ad4ad6817aef
parent 36f5e4ad0c69fd28ed35b07b9f9f29dbac2e91b9
Author: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Date: Thu, 23 Jul 2026 21:23:13 -0300
lex: slight rename
_lexer_next -> lex_token
Diffstat:
| M | lex.odin | | | 42 | +++++++++++++++++++++--------------------- |
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/lex.odin b/lex.odin
@@ -55,12 +55,12 @@ lexer_next :: proc(l: ^Lexer) -> (t: Token, ok: bool) {
return t, false
}
- if t, ok := _lexer_next(l); ok {
+ if t, ok := lex_token(l); ok {
return t, true
}
// Advance until we find an interesting token.
- // The cursor is reset to undo the advancing that occurs within _lexer_next.
+ // The cursor is reset to undo the advancing that occurs within lex_token.
start := l.cursor
for {
if !lexer_advance(l) {
@@ -68,7 +68,7 @@ lexer_next :: proc(l: ^Lexer) -> (t: Token, ok: bool) {
}
start := l.cursor
- _, ok := _lexer_next(l)
+ _, ok := lex_token(l)
l.cursor = start
if ok {
@@ -81,7 +81,7 @@ lexer_next :: proc(l: ^Lexer) -> (t: Token, ok: bool) {
}
@(private = "file")
-_lexer_next :: proc(l: ^Lexer) -> (t: Token, ok: bool) {
+lex_token :: proc(l: ^Lexer) -> (t: Token, ok: bool) {
if peek := lexer_peek(l, 4); peek == "<!--" {
defer lexer_advance(l, 4)
return Token{kind = .Comment_Start, start = l.cursor, end = l.cursor + 3}, true
@@ -277,7 +277,7 @@ token_lookup :: proc(t: Token, text: string) -> string {
}
@(private = "file")
-_lexer_test :: proc(t: ^testing.T, source: string, want: []Token, loc := #caller_location) {
+check_tokens :: proc(t: ^testing.T, source: string, want: []Token, loc := #caller_location) {
defer free_all()
lexer: Lexer
@@ -326,7 +326,7 @@ test_lex_comment :: proc(t: ^testing.T) {
Token{kind = .Raw_Text, start = 4, end = 12},
Token{kind = .Comment_End, start = 13, end = 15},
}
- _lexer_test(t, source, want)
+ check_tokens(t, source, want)
}
@(test)
@@ -337,7 +337,7 @@ test_lex_comment_2 :: proc(t: ^testing.T) {
Token{kind = .Raw_Text, start = 4, end = 10},
Token{kind = .Comment_End, start = 11, end = 13},
}
- _lexer_test(t, source, want)
+ check_tokens(t, source, want)
}
@(test)
@@ -348,21 +348,21 @@ test_lex_comment_3 :: proc(t: ^testing.T) {
Token{kind = .Raw_Text, start = 4, end = 14},
Token{kind = .Comment_End, start = 15, end = 17},
}
- _lexer_test(t, source, want)
+ check_tokens(t, source, want)
}
@(test)
test_lex_doctype :: proc(t: ^testing.T) {
source := "<!DOCTYPE html>"
want := []Token{Token{kind = .Doctype, start = 0, end = 14}}
- _lexer_test(t, source, want)
+ check_tokens(t, source, want)
}
@(test)
test_lex_exotic_doctype :: proc(t: ^testing.T) {
source := "<!DOCTYPE foobar>"
want := []Token{Token{kind = .Doctype, start = 0, end = 16}}
- _lexer_test(t, source, want)
+ check_tokens(t, source, want)
}
@(test)
@@ -373,7 +373,7 @@ test_lex_self_closing_tag :: proc(t: ^testing.T) {
Token{kind = .Raw_Text, start = 4, end = 4},
Token{kind = .Self_Closing_Tag_End, start = 5, end = 6},
}
- _lexer_test(t, source, want)
+ check_tokens(t, source, want)
}
@(test)
@@ -383,7 +383,7 @@ test_lex_self_closing_tag_2 :: proc(t: ^testing.T) {
Token{kind = .Open_Tag_Start, start = 1, end = 3},
Token{kind = .Self_Closing_Tag_End, start = 4, end = 5},
}
- _lexer_test(t, source, want)
+ check_tokens(t, source, want)
}
@(test)
@@ -393,7 +393,7 @@ test_lex_open_tag :: proc(t: ^testing.T) {
Token{kind = .Open_Tag_Start, start = 1, end = 3},
Token{kind = .Tag_End, start = 4, end = 4},
}
- _lexer_test(t, source, want)
+ check_tokens(t, source, want)
}
@(test)
@@ -403,7 +403,7 @@ test_lex_close_tag :: proc(t: ^testing.T) {
Token{kind = .Close_Tag_Start, start = 2, end = 4},
Token{kind = .Tag_End, start = 5, end = 5},
}
- _lexer_test(t, source, want)
+ check_tokens(t, source, want)
}
@(test)
@@ -415,7 +415,7 @@ test_lex_tag_pair :: proc(t: ^testing.T) {
Token{kind = .Close_Tag_Start, start = 7, end = 9},
Token{kind = .Tag_End, start = 10, end = 10},
}
- _lexer_test(t, source, want)
+ check_tokens(t, source, want)
}
@(test)
@@ -430,7 +430,7 @@ test_lex_tag_pair_with_comment :: proc(t: ^testing.T) {
Token{kind = .Close_Tag_Start, start = 21, end = 23},
Token{kind = .Tag_End, start = 24, end = 24},
}
- _lexer_test(t, source, want)
+ check_tokens(t, source, want)
}
@(test)
@@ -443,7 +443,7 @@ test_lex_open_tag_value_attribute :: proc(t: ^testing.T) {
Token{kind = .Double_Quote_String_Literal, start = 11, end = 18},
Token{kind = .Tag_End, start = 19, end = 19},
}
- _lexer_test(t, source, want)
+ check_tokens(t, source, want)
}
@(test)
@@ -457,7 +457,7 @@ test_lex_open_tag_naked_attribute :: proc(t: ^testing.T) {
Token{kind = .Raw_Text, start = 19, end = 25},
Token{kind = .Tag_End, start = 26, end = 26},
}
- _lexer_test(t, source, want)
+ check_tokens(t, source, want)
}
@(test)
@@ -483,7 +483,7 @@ test_lex_nested_tags :: proc(t: ^testing.T) {
Token{kind = .Close_Tag_Start, start = 40, end = 42},
Token{kind = .Tag_End, start = 43, end = 43},
}
- _lexer_test(t, source, want)
+ check_tokens(t, source, want)
}
@(test)
@@ -496,7 +496,7 @@ test_lex_raw_text_less_than :: proc(t: ^testing.T) {
Token{kind = .Close_Tag_Start, start = 14, end = 16},
Token{kind = .Tag_End, start = 17, end = 17},
}
- _lexer_test(t, source, want)
+ check_tokens(t, source, want)
}
@(test)
@@ -511,7 +511,7 @@ test_lex_invalid_tag :: proc(t: ^testing.T) {
Token{kind = .Close_Tag_Start, start = 23, end = 25},
Token{kind = .Tag_End, start = 26, end = 26},
}
- _lexer_test(t, source, want)
+ check_tokens(t, source, want)
}
FUZZ_ENABLED :: #config(FUZZ, false)