Compare commits
No commits in common. "2531524ffd3b4ee382fdee5204f5ae79a1287080" and "32463ad6aa309b62cbb145c147a61c619af0e5f3" have entirely different histories.
2531524ffd
...
32463ad6aa
|
@ -28,7 +28,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "daisycalc"
|
name = "daisycalc"
|
||||||
version = "1.1.4"
|
version = "1.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"num",
|
"num",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "daisycalc"
|
name = "daisycalc"
|
||||||
version = "1.1.4"
|
version = "1.1.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
build = "buildscript/main.rs"
|
build = "buildscript/main.rs"
|
||||||
license = "GPL-3.0-only"
|
license = "GPL-3.0-only"
|
||||||
|
|
19
Makefile
|
@ -1,19 +0,0 @@
|
||||||
release:
|
|
||||||
cargo build --release
|
|
||||||
|
|
||||||
test:
|
|
||||||
cargo test
|
|
||||||
|
|
||||||
run:
|
|
||||||
cargo run
|
|
||||||
|
|
||||||
wasm:
|
|
||||||
wasm-pack build --release --target web --out-dir server/pkg
|
|
||||||
|
|
||||||
publish:
|
|
||||||
cargo test
|
|
||||||
cargo publish
|
|
||||||
|
|
||||||
docker: wasm
|
|
||||||
docker build ./server -t git.betalupi.com/mark/daisy --no-cache
|
|
||||||
docker push git.betalupi.com/mark/daisy
|
|
|
@ -1,4 +1,4 @@
|
||||||
![](./server/site/resources/readme-banner.png)
|
![](./site/misc/readme-banner.png)
|
||||||
|
|
||||||
A high-precision scientific calculator with support for units, derivatives, and more.
|
A high-precision scientific calculator with support for units, derivatives, and more.
|
||||||
|
|
||||||
|
|
18
TODO.md
|
@ -1,34 +1,47 @@
|
||||||
## Version Bump checklist
|
## Version Bump checklist
|
||||||
|
- TODO: build and publish script
|
||||||
- update Cargo.toml
|
- update Cargo.toml
|
||||||
- run cargo test
|
- run cargo test
|
||||||
- commit
|
- commit
|
||||||
- push
|
- push
|
||||||
- merge
|
- merge
|
||||||
- git tag -a v1.0.0 -m "Version 1.0.0" on merge commit
|
- git tag -a v1.0.0 -m "Version 1.0.0" on merge commit
|
||||||
|
- delete branch?
|
||||||
- cargo publish
|
- cargo publish
|
||||||
|
- Update packages
|
||||||
- Build wasm & push changes
|
- Build wasm & push changes
|
||||||
|
- Squash merge
|
||||||
- Update AUR package
|
- Update AUR package
|
||||||
|
|
||||||
|
|
||||||
## Pre-release
|
## Pre-release
|
||||||
- Tuple operations
|
- Tuple operations
|
||||||
- we don't need vectors as arguments to operators
|
- we don't need vectors as arguments to operators
|
||||||
|
- Fix linelocation when evaluating functions
|
||||||
|
|
||||||
## Parser
|
## Parser
|
||||||
- Should functions be operators?
|
- Should functions be operators?
|
||||||
- Binary, hex, octal numbers
|
- Binary, hex, octal numbers
|
||||||
|
|
||||||
|
|
||||||
## General
|
## General
|
||||||
- Better tests (assignment, many expressions in one context)
|
- Better tests (assignment, many expressions in one context)
|
||||||
- Optional config file
|
- Optional config file
|
||||||
- Optional history file
|
- Optional history file
|
||||||
|
- evaluate straight from command line
|
||||||
- Package for debian, nix
|
- Package for debian, nix
|
||||||
|
|
||||||
|
|
||||||
|
## Internals
|
||||||
- Non-recursive treeify
|
- Non-recursive treeify
|
||||||
- Faster factorial function. Maybe use gamma instead?
|
- Faster factorial function. Maybe use gamma instead?
|
||||||
- Arbitrary precision floats
|
- Arbitrary precision float (rug doesn't offer arbitrary exponents)
|
||||||
|
|
||||||
## Math Features
|
## Math Features
|
||||||
- Mean, Median, Min
|
- Mean, Median, Min
|
||||||
- Arbitrary base logarithm
|
- Arbitrary base logarithm
|
||||||
|
- Derivatives
|
||||||
|
- CAS features (trig, roots and powers)
|
||||||
- Complex numbers
|
- Complex numbers
|
||||||
- acot/acoth functions
|
- acot/acoth functions
|
||||||
- Sums and products with functional arguments
|
- Sums and products with functional arguments
|
||||||
|
@ -38,7 +51,8 @@
|
||||||
- Fix terminal color detection
|
- Fix terminal color detection
|
||||||
- Live syntax/output (like firefox js terminal)
|
- Live syntax/output (like firefox js terminal)
|
||||||
- Syntax highlighting
|
- Syntax highlighting
|
||||||
- Numbered history recall
|
- fish-style tab completion
|
||||||
|
- Numbered expressions, history recall
|
||||||
- Enable/disable unit sets (defaults?)
|
- Enable/disable unit sets (defaults?)
|
||||||
- Consistent unit ordering
|
- Consistent unit ordering
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ networks:
|
||||||
|
|
||||||
services:
|
services:
|
||||||
daisy:
|
daisy:
|
||||||
build: .
|
build: ./.
|
||||||
container_name: daisy
|
container_name: daisy
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
/site/node_modules
|
|
||||||
/pkg
|
|
|
@ -1,17 +0,0 @@
|
||||||
{
|
|
||||||
"name": "site",
|
|
||||||
"lockfileVersion": 3,
|
|
||||||
"requires": true,
|
|
||||||
"packages": {
|
|
||||||
"": {
|
|
||||||
"dependencies": {
|
|
||||||
"xterm": "^5.3.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/xterm": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/xterm/-/xterm-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-8QqjlekLUFTrU6x7xck1MsPzPA571K5zNqWm0M0oroYEWVOptZ0+ubQSkQ3uxIEhcIHRujJy6emDWX4A7qyFzg=="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
/node_modules
|
||||||
|
/package-lock.json
|
||||||
|
/pkg
|
|
@ -100,11 +100,6 @@
|
||||||
<a href="https://aur.archlinux.org/packages/daisy" target="_blank" rel="noopener noreferrer">AUR</a>
|
<a href="https://aur.archlinux.org/packages/daisy" target="_blank" rel="noopener noreferrer">AUR</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
|
||||||
var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
|
|
||||||
if (mobile) { alert("This site may not work on mobile."); }
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
// See wasm-pack docs
|
// See wasm-pack docs
|
||||||
// Build with `wasm-pack build --release --target web --out-dir pkg`
|
// Build with `wasm-pack build --release --target web --out-dir pkg`
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 92 KiB |
|
@ -19,7 +19,6 @@ pub fn eval_operator(context: &mut Context, g: &Expression) -> Result<Option<Exp
|
||||||
|
|
||||||
if args.len() != 1 {panic!()};
|
if args.len() != 1 {panic!()};
|
||||||
let a = &args[0];
|
let a = &args[0];
|
||||||
let mut args_ll = op_loc.clone();
|
|
||||||
|
|
||||||
if sh_vars.len() == 1 {
|
if sh_vars.len() == 1 {
|
||||||
if let Expression::Tuple(l, v) = a {
|
if let Expression::Tuple(l, v) = a {
|
||||||
|
@ -29,7 +28,6 @@ pub fn eval_operator(context: &mut Context, g: &Expression) -> Result<Option<Exp
|
||||||
))
|
))
|
||||||
};
|
};
|
||||||
|
|
||||||
args_ll += a.get_linelocation();
|
|
||||||
context.add_shadow(sh_vars[0].clone(), Some(a.clone()));
|
context.add_shadow(sh_vars[0].clone(), Some(a.clone()));
|
||||||
} else {
|
} else {
|
||||||
let Expression::Tuple(l, v) = a else {
|
let Expression::Tuple(l, v) = a else {
|
||||||
|
@ -48,28 +46,18 @@ pub fn eval_operator(context: &mut Context, g: &Expression) -> Result<Option<Exp
|
||||||
|
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
while i < sh_vars.len() {
|
while i < sh_vars.len() {
|
||||||
args_ll += v[i].get_linelocation();
|
|
||||||
context.add_shadow(sh_vars[i].clone(), Some(v[i].clone()));
|
context.add_shadow(sh_vars[i].clone(), Some(v[i].clone()));
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let r = evaluate(context, &exp);
|
let r = evaluate(context, &exp)?;
|
||||||
context.clear_shadow();
|
context.clear_shadow();
|
||||||
|
|
||||||
match r {
|
|
||||||
Ok(mut r) => {
|
|
||||||
r.set_linelocation(&args_ll);
|
|
||||||
return Ok(Some(r));
|
return Ok(Some(r));
|
||||||
},
|
},
|
||||||
|
|
||||||
Err( (_, err) ) => {
|
|
||||||
return Err((args_ll, err));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
Operator::Negative => {
|
Operator::Negative => {
|
||||||
if args.len() != 1 { panic!() };
|
if args.len() != 1 { panic!() };
|
||||||
let args = &args[0];
|
let args = &args[0];
|
||||||
|
|
20
src/lib.rs
|
@ -68,7 +68,9 @@ cfg_if::cfg_if! {
|
||||||
return format!("\r\n{}", daisy_prompt(state));
|
return format!("\r\n{}", daisy_prompt(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if in_str.trim() == "quit" {
|
||||||
|
return "[quit]".to_string();
|
||||||
|
} else {
|
||||||
let r = crate::do_string( unsafe { &mut (*state).context }, &in_str);
|
let r = crate::do_string( unsafe { &mut (*state).context }, &in_str);
|
||||||
|
|
||||||
match r {
|
match r {
|
||||||
|
@ -76,6 +78,7 @@ cfg_if::cfg_if! {
|
||||||
out += t;
|
out += t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"\x7F" => { unsafe { (*state).promptbuffer.backspace(); } },
|
"\x7F" => { unsafe { (*state).promptbuffer.backspace(); } },
|
||||||
|
@ -88,20 +91,7 @@ cfg_if::cfg_if! {
|
||||||
//'\x04' | '\x03'
|
//'\x04' | '\x03'
|
||||||
//=> { break 'outer; },
|
//=> { break 'outer; },
|
||||||
|
|
||||||
// Only process sane characters
|
_ => { unsafe { (*state).promptbuffer.add_char(s.chars().next().unwrap()); } },
|
||||||
|
|
||||||
_ => {
|
|
||||||
let c = s.chars().next().unwrap();
|
|
||||||
match c {
|
|
||||||
'a'..='z' | 'A'..='Z' | '0'..='9'
|
|
||||||
|'!'|'@'|'#'|'$'|'%'|'^'|'&'|'*'|'('|')'
|
|
||||||
|'?'|'~'|','|'.'|'['|']'|' '
|
|
||||||
|'<'|'>'|'/'|'_'|'-'|':'|'|'|'='|'+'|';'
|
|
||||||
=> { unsafe { (*state).promptbuffer.add_char(c); } },
|
|
||||||
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let t = unsafe { (*state).promptbuffer.write_prompt(&mut (*state).context) };
|
let t = unsafe { (*state).promptbuffer.write_prompt(&mut (*state).context) };
|
||||||
|
|
|
@ -120,7 +120,7 @@ pub fn main() -> Result<(), std::io::Error> {
|
||||||
// Only process sane characters
|
// Only process sane characters
|
||||||
'a'..='z' | 'A'..='Z' | '0'..='9'
|
'a'..='z' | 'A'..='Z' | '0'..='9'
|
||||||
|'!'|'@'|'#'|'$'|'%'|'^'|'&'|'*'|'('|')'
|
|'!'|'@'|'#'|'$'|'%'|'^'|'&'|'*'|'('|')'
|
||||||
|'?'|'~'|','|'.'|'['|']'|' '
|
|'?'|'~'|','|'.'|'['|']'
|
||||||
|'<'|'>'|'/'|'_'|'-'|':'|'|'|'='|'+'|';'
|
|'<'|'>'|'/'|'_'|'-'|':'|'|'|'='|'+'|';'
|
||||||
=> { pb.add_char(*q); },
|
=> { pb.add_char(*q); },
|
||||||
|
|
||||||
|
|