diff options
| author | Thomas Voss <mail@thomasvoss.com> | 2026-03-10 17:29:33 +0100 |
|---|---|---|
| committer | Thomas Voss <mail@thomasvoss.com> | 2026-03-10 17:29:33 +0100 |
| commit | 57e3f53598059dd4553ee0f5933ca60a11ad6d91 (patch) | |
| tree | b8fef6589ce66c80631a977cfe3fbe88069a10fe /oryxc | |
| parent | f7b9ea9ccfd8be8c2633b4d02dbc3207c2e3d354 (diff) | |
Add the divrem (/%) operator
Diffstat (limited to 'oryxc')
| -rw-r--r-- | oryxc/src/lexer.rs | 8 | ||||
| -rw-r--r-- | oryxc/src/parser.rs | 2 |
2 files changed, 10 insertions, 0 deletions
diff --git a/oryxc/src/lexer.rs b/oryxc/src/lexer.rs index ace0a83..2dace02 100644 --- a/oryxc/src/lexer.rs +++ b/oryxc/src/lexer.rs @@ -60,6 +60,7 @@ pub enum TokenType { KeywordReturn, Number, Percent2, + SlashPercent, String, } @@ -220,6 +221,13 @@ pub fn tokenize(s: &str) -> Result<Soa<Token>, OryxError> { view: (i, j + 1), }) }, + '/' if ctx.peek().is_some_and(|c| c == '%') => { + ctx.next(); /* Consume ‘/’ */ + Some(Token { + kind: TokenType::SlashPercent, + view: (i, j + 1), + }) + }, '!' | '&' | '(' | ')' | '*' | '+' | ',' | '-' | '/' | ';' | '<' | '=' | '>' | '[' | ']' | '^' | '{' | '|' | '}' | '~' | '…' | '%' => Some(Token { diff --git a/oryxc/src/parser.rs b/oryxc/src/parser.rs index 89e2769..70b530f 100644 --- a/oryxc/src/parser.rs +++ b/oryxc/src/parser.rs @@ -686,6 +686,7 @@ impl<'a> Parser<'a> { | TokenType::Asterisk | TokenType::Percent | TokenType::Percent2 + | TokenType::SlashPercent | TokenType::Slash => 5, TokenType::Bar | TokenType::Minus @@ -817,6 +818,7 @@ impl<'a> Parser<'a> { | TokenType::Percent2 | TokenType::Plus | TokenType::Slash + | TokenType::SlashPercent | TokenType::Tilde => { let i = self.cursor; self.next(); |