summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--grammar1
-rw-r--r--oryxc/src/lexer.rs8
-rw-r--r--oryxc/src/parser.rs2
3 files changed, 11 insertions, 0 deletions
diff --git a/grammar b/grammar
index 5fa2e73..2042e97 100644
--- a/grammar
+++ b/grammar
@@ -48,6 +48,7 @@ binary-op
| "-"
| "*"
| "/"
+ | "/%" /* Divrem */
| "%" /* Remainder */
| "%%" /* Modulus */
| "~" /* XOR */
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();