Replace // with quot
This commit is contained in:
parent
479a098e0f
commit
a63dcf91b0
@ -75,7 +75,6 @@ impl BinOp {
|
||||
};
|
||||
let default = 10_000_000;
|
||||
Some(BINOPS.get(s).map(|x| x.2.clone()).unwrap_or_else(|| {
|
||||
println!("Warning: operator {} not defined", s);
|
||||
default
|
||||
}))
|
||||
}
|
||||
@ -84,7 +83,6 @@ impl BinOp {
|
||||
let s: &str = &self.sigil;
|
||||
let default = 10_000_000;
|
||||
BINOPS.get(s).map(|x| x.2.clone()).unwrap_or_else(|| {
|
||||
println!("Warning: operator {} not defined", s);
|
||||
default
|
||||
})
|
||||
}
|
||||
@ -130,7 +128,7 @@ lazy_static! {
|
||||
"-" => (Func(bx!(Const(Nat)), bx!(Func(bx!(Const(Nat)), bx!(Const(Nat))))), (), 10),
|
||||
"*" => (Func(bx!(Const(Nat)), bx!(Func(bx!(Const(Nat)), bx!(Const(Nat))))), (), 20),
|
||||
"/" => (Func(bx!(Const(Nat)), bx!(Func(bx!(Const(Nat)), bx!(Const(Float))))), (), 20),
|
||||
"//" => (Func(bx!(Const(Nat)), bx!(Func(bx!(Const(Nat)), bx!(Const(Nat))))), (), 20), //TODO change this to `quot`
|
||||
"quot" => (Func(bx!(Const(Nat)), bx!(Func(bx!(Const(Nat)), bx!(Const(Nat))))), (), 20),
|
||||
"%" => (Func(bx!(Const(Nat)), bx!(Func(bx!(Const(Nat)), bx!(Const(Nat))))), (), 20),
|
||||
"++" => (Func(bx!(Const(StringT)), bx!(Func(bx!(Const(StringT)), bx!(Const(StringT))))), (), 30),
|
||||
"^" => (Func(bx!(Const(Nat)), bx!(Func(bx!(Const(Nat)), bx!(Const(Nat))))), (), 20),
|
||||
|
@ -300,7 +300,7 @@ impl<'a> State<'a> {
|
||||
("-", &[Lit(Nat(l)), Lit(Nat(r))]) => Lit(Nat(l - r)),
|
||||
("*", &[Lit(Nat(l)), Lit(Nat(r))]) => Lit(Nat(l * r)),
|
||||
("/", &[Lit(Nat(l)), Lit(Nat(r))]) => Lit(Float((l as f64)/ (r as f64))),
|
||||
("//", &[Lit(Nat(l)), Lit(Nat(r))]) => if r == 0 {
|
||||
("quot", &[Lit(Nat(l)), Lit(Nat(r))]) => if r == 0 {
|
||||
return Err(format!("divide by zero"));
|
||||
} else {
|
||||
Lit(Nat(l / r))
|
||||
|
@ -45,7 +45,7 @@ mod eval;
|
||||
#[PipelineSteps(load_source, tokenizing, parsing(compact,expanded,trace), symbol_table, typechecking, ast_reducing, eval)]
|
||||
#[DocMethod = get_doc]
|
||||
#[HandleCustomInterpreterDirectives = handle_custom_interpreter_directives]
|
||||
/// All bits of state necessary to parse and execute a Schala program are stored in this struct
|
||||
/// All bits of state necessary to parse and execute a Schala program are stored in this struct.
|
||||
/// `state` represents the execution state for the AST-walking interpreter, the other fields
|
||||
/// should be self-explanatory.
|
||||
pub struct Schala {
|
||||
@ -193,6 +193,7 @@ fn eval(input: reduced_ast::ReducedAST, handle: &mut Schala, comp: Option<&mut U
|
||||
eval_output
|
||||
}
|
||||
|
||||
/// Represents lines of source code
|
||||
struct SourceReference {
|
||||
lines: Option<Vec<String>>
|
||||
}
|
||||
|
@ -213,7 +213,8 @@ expression := precedence_expr type_anno+
|
||||
precedence_expr := prefix_expr
|
||||
prefix_expr := prefix_op call_expr
|
||||
prefix_op := '+' | '-' | '!' | '~'
|
||||
call_expr := index_expr '(' ( expr_list )* ')'
|
||||
call_expr := index_expr ( '(' expr_list ')' )* | ε
|
||||
|
||||
expr_list := expression (',' expression)* | ε
|
||||
index_expr := primary ( '[' (expression (',' (expression)* | ε) ']' )*
|
||||
primary := literal | paren_expr | if_expr | for_expr | while_expr | identifier_expr | lambda_expr | anonymous_struct | list_expr
|
||||
|
Loading…
Reference in New Issue
Block a user