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,