diff --git a/src/schala_lang/builtin.rs b/src/schala_lang/builtin.rs index a7a539a..52b15b0 100644 --- a/src/schala_lang/builtin.rs +++ b/src/schala_lang/builtin.rs @@ -67,7 +67,7 @@ lazy_static! { "-" => (Func(bx!(Const(Int)), bx!(Func(bx!(Const(Int)), bx!(Const(Int))))), (), 10), "*" => (Func(bx!(Const(Int)), bx!(Func(bx!(Const(Int)), bx!(Const(Int))))), (), 20), "/" => (Func(bx!(Const(Int)), bx!(Func(bx!(Const(Int)), bx!(Const(Float))))), (), 20), - "//" => (Func(bx!(Const(Int)), bx!(Func(bx!(Const(Int)), bx!(Const(Int))))), (), 20), + "//" => (Func(bx!(Const(Int)), bx!(Func(bx!(Const(Int)), bx!(Const(Int))))), (), 20), //TODO change this to `quot` "%" => (Func(bx!(Const(Int)), bx!(Func(bx!(Const(Int)), bx!(Const(Int))))), (), 20), "++" => (Func(bx!(Const(StringT)), bx!(Func(bx!(Const(StringT)), bx!(Const(StringT))))), (), 30), "^" => (Func(bx!(Const(Int)), bx!(Func(bx!(Const(Int)), bx!(Const(Int))))), (), 20), diff --git a/src/schala_lang/parsing.rs b/src/schala_lang/parsing.rs index 1b53dd6..6c28a1c 100644 --- a/src/schala_lang/parsing.rs +++ b/src/schala_lang/parsing.rs @@ -550,6 +550,7 @@ impl Parser { Operator(op) => BinOp::get_precedence(&*op), Period => BinOp::get_precedence("."), Pipe => BinOp::get_precedence("|"), + Slash => BinOp::get_precedence("/"), _ => break, }; diff --git a/src/schala_lang/tokenizing.rs b/src/schala_lang/tokenizing.rs index ccaf3cb..38f9ded 100644 --- a/src/schala_lang/tokenizing.rs +++ b/src/schala_lang/tokenizing.rs @@ -15,6 +15,7 @@ pub enum TokenType { Pipe, Comma, Period, Colon, Underscore, + Slash, Operator(Rc), DigitGroup(Rc), HexLiteral(Rc), BinNumberSigil, @@ -99,7 +100,7 @@ impl Token { } } -const OPERATOR_CHARS: [char; 19] = ['!', '$', '%', '&', '*', '+', '-', '.', '/', ':', '<', '>', '=', '?', '@', '^', '|', '~', '`']; +const OPERATOR_CHARS: [char; 18] = ['!', '$', '%', '&', '*', '+', '-', '.', ':', '<', '>', '=', '?', '@', '^', '|', '~', '`']; fn is_operator(c: &char) -> bool { OPERATOR_CHARS.iter().any(|x| x == c) } @@ -116,16 +117,19 @@ pub fn tokenize(input: &str) -> Vec { while let Some((line_idx, ch_idx, c)) = input.next() { let cur_tok_type = match c { - '#' => { - if let Some(&(_, _, '{')) = input.peek() { - } else { + '/' => match input.peek() { + Some(&(_, _, '/')) => { while let Some((_, _, c)) = input.next() { if c == '\n' { break; } } - } - continue; + continue; + }, + Some(&(_, _, '*')) => { + continue + }, + _ => Slash }, c if c.is_whitespace() && c != '\n' => continue, '\n' => Newline, ';' => Semicolon,