Add ## operator to core:odin

This commit is contained in:
gingerBill
2025-04-01 10:12:57 +01:00
parent c1333d75ef
commit b54659ac7c
3 changed files with 21 additions and 2 deletions

View File

@@ -1627,7 +1627,8 @@ token_precedence :: proc(p: ^Parser, kind: tokenizer.Token_Kind) -> int {
case .Mul, .Quo,
.Mod, .Mod_Mod,
.And, .And_Not,
.Shl, .Shr:
.Shl, .Shr,
.Concat:
return 7
}
return 0

View File

@@ -64,6 +64,8 @@ Token_Kind :: enum u32 {
Shl, // <<
Shr, // >>
Concat, // ##
Cmp_And, // &&
Cmp_Or, // ||
@@ -80,6 +82,9 @@ Token_Kind :: enum u32 {
And_Not_Eq, // &~=
Shl_Eq, // <<=
Shr_Eq, // >>=
Concat_Eq, // ##=
Cmp_And_Eq, // &&=
Cmp_Or_Eq, // ||=
B_Assign_Op_End,
@@ -199,6 +204,8 @@ tokens := [Token_Kind.COUNT]string {
"<<",
">>",
"##",
"&&",
"||",
@@ -215,6 +222,9 @@ tokens := [Token_Kind.COUNT]string {
"&~=",
"<<=",
">>=",
"##=",
"&&=",
"||=",
"",

View File

@@ -650,7 +650,15 @@ scan :: proc(t: ^Tokenizer) -> Token {
}
case '#':
kind = .Hash
if t.ch == '!' {
if t.ch == '#' {
advance_rune(t)
kind = .Concat
if t.ch == '=' {
advance_rune(t)
kind = .Concat_Eq
}
} else if t.ch == '!' {
kind = .Comment
lit = scan_comment(t)
} else if t.ch == '+' {