modulus operator
This commit is contained in:
6
lexer.v
6
lexer.v
@@ -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++
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user