valhallac

Compiler for set-theoretic programming language.
git clone git://git.knutsen.co/valhallac
Log | Files | Refs | README | LICENSE

commit 80bc16ae93b4dcc0a1d25c8918adfd98091770b6
parent e898f61baff425c9d125fab09187649b69ed739a
Author: Demonstrandum <moi@knutsen.co>
Date:   Thu,  2 Jan 2020 20:27:31 +0000

Updating

Diffstat:
Acheck.vh | 3+++
Msrc/compiler/block.rs | 7+++----
Msrc/syntax/parser.rs | 16++++++++++------
3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/check.vh b/check.vh @@ -0,0 +1,3 @@ +(- a) +(+ a) +(* a) diff --git a/src/compiler/block.rs b/src/compiler/block.rs @@ -136,8 +136,8 @@ impl<'a> LocalBlock<'a> { self.emit(type_node); self.push_operator(Operators::CHECK_TYPE); } else { // Otherwise just pop, type was already checked statically so - // its of no use to include in the compiled program, - // as no dynamic checking is needed. + // its of no use to include in the compiled program, + // as no dynamic checking is needed. self.types_to_check.pop_front(); } self.push_operator(Operators::STORE_LOCAL); @@ -374,4 +374,4 @@ impl<'a> fmt::Display for LocalBlock<'a> { } write!(f, "") } -}- \ No newline at end of file +} diff --git a/src/syntax/parser.rs b/src/syntax/parser.rs @@ -88,10 +88,12 @@ impl<'a> ParseEnvironment<'a> { ast::IdentNode::new(&token.string, loc) }, _ => { - // If the operator is prefix: - // e.g. -a <=> ((-) a) + // If the operator is suffix: + // e.g. (a +) <=> ((+) a) // Otherwise it's a partial application: // e.g. (* a) <=> ((flip (*)) a) + // But, prefix operators don't get flipped: + // e.g. (- a) <=> ((-) a) <=> -a if prefix.is_none() { ast::CallNode::new( ast::CallNode::new( @@ -196,13 +198,16 @@ impl<'a> ParseEnvironment<'a> { if self.stream[0].class == TokenType::RParen { return first_apply; } - let right = self.expr(op.precedence - (if op.is_right() { 1 } else { 0 })); + let right = self.expr( + op.precedence - (if op.is_right() { 1 } else { 0 })); + ast::CallNode::new(first_apply, vec![right], self.location) } fn expect(&self, tt : TokenType, maybe_t : Option<&Token>) { if maybe_t.is_none() { - issue!(err::Types::ParseError, self.file, self.stream.iter().last().unwrap(), + issue!(err::Types::ParseError, self.file, + self.stream.iter().last().unwrap(), "Unexpected end of stream."); } let t = maybe_t.unwrap(); @@ -263,4 +268,4 @@ mod test { assert_eq!(num.num().unwrap().value, Numerics::Integer(-6000000000000)); } -}- \ No newline at end of file +}