From 5600abbcec09c3ab2cfbda60bb1ba924ff5cecb3 Mon Sep 17 00:00:00 2001 From: bakk Date: Sun, 16 Jan 2022 15:44:32 +0100 Subject: [PATCH] Added 'mod' keyword --- cli/src/repl.rs | 2 +- kalk/src/lexer.rs | 1 + web/src/KalkCalculator.svelte | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cli/src/repl.rs b/cli/src/repl.rs index 3c4e0f8..719ff4d 100644 --- a/cli/src/repl.rs +++ b/cli/src/repl.rs @@ -106,7 +106,7 @@ impl Highlighter for LineHighlighter { let reg = Regex::new( r"(?x) - (?P([+\-/*%^!×÷⋅∧∨]|if|otherwise|\sand|\sor|load|exit|clear|help)) | + (?P([+\-/*%^!×÷⋅∧∨]|if|otherwise|\sand|\sor|\smod|load|exit|clear|help)) | (?P0[box][a-zA-Z0-9]+) | (?P[^!-@\s_|^⌊⌋⌈⌉\[\]\{\}⟦⟧≠≥≤⁰¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁼⁽⁾₀₁₂₃₄₅₆₇₈₉₊₋₌₍₎]+(_\d+)?)", ) diff --git a/kalk/src/lexer.rs b/kalk/src/lexer.rs index 407324a..242211c 100644 --- a/kalk/src/lexer.rs +++ b/kalk/src/lexer.rs @@ -324,6 +324,7 @@ impl<'a> Lexer<'a> { let kind = match value.as_ref() { "and" => TokenKind::And, "or" => TokenKind::Or, + "mod" => TokenKind::Percent, "unit" => TokenKind::UnitKeyword, "to" => TokenKind::ToKeyword, "if" => TokenKind::IfKeyword, diff --git a/web/src/KalkCalculator.svelte b/web/src/KalkCalculator.svelte index a4971f8..c77d485 100644 --- a/web/src/KalkCalculator.svelte +++ b/web/src/KalkCalculator.svelte @@ -306,7 +306,7 @@ let result = input; let offset = 0; result = result.replace( - /(?\[\[)|(?0[box][a-zA-Z0-9]+)|(?(!=|[<>]=?))|(?[<>&]|(\n\s*\}?|\s+))|(?([+\-/*%^!≈×÷⋅∧∨]|if|otherwise|and|or)|(?[^!-@\s_|^⌊⌋⌈⌉≈\[\]\{\}⟦⟧≠≥≤⁰¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁼⁽⁾₀₁₂₃₄₅₆₇₈₉₊₋₌₍₎]+(_\d+)?)\(?)/g, + /(?\[\[)|(?0[box][a-zA-Z0-9]+)|(?(!=|[<>]=?))|(?[<>&]|(\n\s*\}?|\s+))|(?([+\-/*%^!≈×÷⋅∧∨]|if|otherwise|and|or|mod)|(?[^!-@\s_|^⌊⌋⌈⌉≈\[\]\{\}⟦⟧≠≥≤⁰¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁼⁽⁾₀₁₂₃₄₅₆₇₈₉₊₋₌₍₎]+(_\d+)?)\(?)/g, ( substring, brackets,