Skip to content

Commit 3d06395

Browse files
committed
Release 0.2.0
1 parent 3461f06 commit 3d06395

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "val"
3-
version = "0.1.1"
3+
version = "0.2.0"
44
authors = ["Liam <[email protected]>"]
55
categories = ["science", "parser-implementations", "command-line-interface"]
66
description = "An arbitrary precision calculator language"

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,16 @@ val -e 'sin(2) * e ^ pi * cos(sum([1, 2, 3]))'
9595
**n.b.** The `--expression` option and `filename` argument are mutually
9696
exclusive.
9797

98+
## Features
99+
100+
This section describes some of the language features **val** implements in
101+
detail, and should serve as a guide to anyone wanting to write a **val**
102+
program.
103+
104+
### Statements
105+
106+
**val** supports a few statement constructs
107+
98108
## Prior Art
99109

100110
[bc(1)](https://linux.die.net/man/1/bc) - An arbitrary precision calculator

src/environment.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -925,15 +925,13 @@ impl<'src> Environment<'src> {
925925
}
926926

927927
pub fn resolve_symbol(&self, symbol: &str) -> Option<&Value<'src>> {
928-
if let Some(val) = self.variables.get(symbol) {
929-
Some(val)
928+
if let Some(value) = self.variables.get(symbol) {
929+
Some(value)
930930
} else if let Some(function) = self.functions.get(symbol) {
931931
match function {
932932
Function::UserDefined(value) => Some(value),
933-
_ => None, // We should support this at some point
933+
Function::Builtin(_) => None, // We should support this at some point
934934
}
935-
} else if let Some(value) = self.variables.get(symbol) {
936-
Some(value)
937935
} else if let Some(parent) = &self.parent {
938936
parent.resolve_symbol(symbol)
939937
} else {

src/evaluator.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ impl<'a> Evaluator<'a> {
131131

132132
Ok(EvalResult::Value(value))
133133
}
134-
135134
Statement::Block(statements) => {
136135
let mut result = Value::Null;
137136

@@ -159,7 +158,6 @@ impl<'a> Evaluator<'a> {
159158
}
160159
Ok(EvalResult::Break)
161160
}
162-
163161
Statement::Continue => {
164162
if !self.inside_loop {
165163
return Err(Error::new(
@@ -170,11 +168,9 @@ impl<'a> Evaluator<'a> {
170168

171169
Ok(EvalResult::Continue)
172170
}
173-
174171
Statement::Expression(expression) => {
175172
Ok(EvalResult::Value(self.eval_expression(expression)?))
176173
}
177-
178174
Statement::Function(name, params, body) => {
179175
let function = Value::Function(
180176
name,
@@ -189,7 +185,6 @@ impl<'a> Evaluator<'a> {
189185

190186
Ok(EvalResult::Value(function))
191187
}
192-
193188
Statement::If(condition, then_branch, else_branch) => {
194189
if self.eval_expression(condition)?.boolean(condition.1)? {
195190
let mut result = Value::Null;
@@ -262,7 +257,6 @@ impl<'a> Evaluator<'a> {
262257
None => Value::Null,
263258
}))
264259
}
265-
266260
Statement::While(condition, body) => {
267261
let mut result = Value::Null;
268262

0 commit comments

Comments
 (0)