Skip to content

Commit 80bc16a

Browse files
committed
Updating
1 parent e898f61 commit 80bc16a

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

check.vh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(- a)
2+
(+ a)
3+
(* a)

src/compiler/block.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ impl<'a> LocalBlock<'a> {
136136
self.emit(type_node);
137137
self.push_operator(Operators::CHECK_TYPE);
138138
} else { // Otherwise just pop, type was already checked statically so
139-
// its of no use to include in the compiled program,
140-
// as no dynamic checking is needed.
139+
// its of no use to include in the compiled program,
140+
// as no dynamic checking is needed.
141141
self.types_to_check.pop_front();
142142
}
143143
self.push_operator(Operators::STORE_LOCAL);
@@ -374,4 +374,4 @@ impl<'a> fmt::Display for LocalBlock<'a> {
374374
}
375375
write!(f, "")
376376
}
377-
}
377+
}

src/syntax/parser.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,12 @@ impl<'a> ParseEnvironment<'a> {
8888
ast::IdentNode::new(&token.string, loc)
8989
},
9090
_ => {
91-
// If the operator is prefix:
92-
// e.g. -a <=> ((-) a)
91+
// If the operator is suffix:
92+
// e.g. (a +) <=> ((+) a)
9393
// Otherwise it's a partial application:
9494
// e.g. (* a) <=> ((flip (*)) a)
95+
// But, prefix operators don't get flipped:
96+
// e.g. (- a) <=> ((-) a) <=> -a
9597
if prefix.is_none() {
9698
ast::CallNode::new(
9799
ast::CallNode::new(
@@ -196,13 +198,16 @@ impl<'a> ParseEnvironment<'a> {
196198
if self.stream[0].class == TokenType::RParen {
197199
return first_apply;
198200
}
199-
let right = self.expr(op.precedence - (if op.is_right() { 1 } else { 0 }));
201+
let right = self.expr(
202+
op.precedence - (if op.is_right() { 1 } else { 0 }));
203+
200204
ast::CallNode::new(first_apply, vec![right], self.location)
201205
}
202206

203207
fn expect(&self, tt : TokenType, maybe_t : Option<&Token>) {
204208
if maybe_t.is_none() {
205-
issue!(err::Types::ParseError, self.file, self.stream.iter().last().unwrap(),
209+
issue!(err::Types::ParseError, self.file,
210+
self.stream.iter().last().unwrap(),
206211
"Unexpected end of stream.");
207212
}
208213
let t = maybe_t.unwrap();
@@ -263,4 +268,4 @@ mod test {
263268

264269
assert_eq!(num.num().unwrap().value, Numerics::Integer(-6000000000000));
265270
}
266-
}
271+
}

0 commit comments

Comments
 (0)