From a63dcf91b09dcdd07dc0b98162e75590535c35b1 Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 10 Jan 2019 00:31:37 -0800 Subject: [PATCH] Replace // with `quot` --- schala-lang/language/src/builtin.rs | 4 +--- schala-lang/language/src/eval.rs | 2 +- schala-lang/language/src/lib.rs | 3 ++- schala-lang/language/src/parsing.rs | 3 ++- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/schala-lang/language/src/builtin.rs b/schala-lang/language/src/builtin.rs index cfc6405..e309c15 100644 --- a/schala-lang/language/src/builtin.rs +++ b/schala-lang/language/src/builtin.rs @@ -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), diff --git a/schala-lang/language/src/eval.rs b/schala-lang/language/src/eval.rs index f79a40b..6a629fc 100644 --- a/schala-lang/language/src/eval.rs +++ b/schala-lang/language/src/eval.rs @@ -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)) diff --git a/schala-lang/language/src/lib.rs b/schala-lang/language/src/lib.rs index 8e860cf..99ffa71 100644 --- a/schala-lang/language/src/lib.rs +++ b/schala-lang/language/src/lib.rs @@ -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> } diff --git a/schala-lang/language/src/parsing.rs b/schala-lang/language/src/parsing.rs index f9a8c95..99133c7 100644 --- a/schala-lang/language/src/parsing.rs +++ b/schala-lang/language/src/parsing.rs @@ -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