modulus operator

This commit is contained in:
uan
2026-02-07 15:32:52 +01:00
parent 7fddf9ab30
commit 58f0dfa969
3 changed files with 19 additions and 5 deletions

View File

@@ -25,6 +25,7 @@ enum TokenType as u8 {
minus
star
slash
percent
equals
less
greater
@@ -36,6 +37,7 @@ enum TokenType as u8 {
minus_eq
star_eq
slash_eq
percent_eq
increment
decrement
lparen
@@ -73,6 +75,7 @@ fn toktype_from_delimiter(delimiter string) TokenType {
'-' {.minus}
'*' {.star}
'/' {.slash}
'%' {.percent}
'=' {.equals}
'<' {.less}
'>' {.greater}
@@ -88,6 +91,7 @@ fn toktype_from_delimiter(delimiter string) TokenType {
'-=' {.minus_eq}
'*=' {.star_eq}
'/=' {.slash_eq}
'%=' {.percent_eq}
'++' {.increment}
'--' {.decrement}
else {.unknown}
@@ -186,7 +190,7 @@ fn lex(input string) ?[]Token {
mut tok_str := input[right].ascii_str()
if right + 1 < input.len {
combined := input.substr(right, right + 2)
if combined in ['==', '>=', '<=', '!=', '+=', '-=', '*=', '/=', '++', '--'] {
if combined in ['==', '>=', '<=', '!=', '+=', '-=', '*=', '/=', '%=', '++', '--'] {
tok_str = combined
right++
}