Compare commits
	
		
			34 Commits
		
	
	
		
			v1.1.1
			...
			a75f6197cd
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| a75f6197cd | |||
| 
						
						
							
						
						2f2c005c86
	
				 | 
					
					
						|||
| 
						
						
							
						
						ffebcf2e15
	
				 | 
					
					
						|||
| 4e1df2399b | |||
| 5a921cfc7b | |||
| 
						
						
							
						
						2531524ffd
	
				 | 
					
					
						|||
| 
						
						
							
						
						e5525adcca
	
				 | 
					
					
						|||
| 
						
						
							
						
						a61cbf29e5
	
				 | 
					
					
						|||
| 39ab47530e | |||
| 
						
						
							
						
						be28669416
	
				 | 
					
					
						|||
| 
						
						
							
						
						7658ff76ef
	
				 | 
					
					
						|||
| 
						
						
							
						
						e9d392b80b
	
				 | 
					
					
						|||
| 63d4a01095 | |||
| 
						
						
							
						
						6a025cbf1a
	
				 | 
					
					
						|||
| 
						
						
							
						
						8a6c623ef2
	
				 | 
					
					
						|||
| 
						
						
							
						
						a1db2b6bb0
	
				 | 
					
					
						|||
| 
						
						
							
						
						c2d3e613d4
	
				 | 
					
					
						|||
| 
						
						
							
						
						96a34dc05d
	
				 | 
					
					
						|||
| 
						
						
							
						
						42fdcd5853
	
				 | 
					
					
						|||
| 
						
						
							
						
						cffb3726cc
	
				 | 
					
					
						|||
| 
						
						
							
						
						ef74b67f90
	
				 | 
					
					
						|||
| 32463ad6aa | |||
| 413c34c440 | |||
| 
						
						
							
						
						a1d190b06e
	
				 | 
					
					
						|||
| 
						
						
							
						
						178708a4ac
	
				 | 
					
					
						|||
| 5bb8e2c4ce | |||
| 
						
						
							
						
						49b88af2bb
	
				 | 
					
					
						|||
| 
						
						
							
						
						a0fe0a9385
	
				 | 
					
					
						|||
| 
						
						
							
						
						7215afcc7e
	
				 | 
					
					
						|||
| 
						
						
							
						
						3ab559b240
	
				 | 
					
					
						|||
| 
						
						
							
						
						810e2a1267
	
				 | 
					
					
						|||
| 798c9ceae9 | |||
| bab305e11d | |||
| a6c3ffa68d | 
							
								
								
									
										2
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						@ -28,7 +28,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "daisycalc"
 | 
			
		||||
version = "1.1.1"
 | 
			
		||||
version = "1.1.5"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "cfg-if",
 | 
			
		||||
 "num",
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
[package]
 | 
			
		||||
name = "daisycalc"
 | 
			
		||||
version = "1.1.1"
 | 
			
		||||
version = "1.1.5"
 | 
			
		||||
edition = "2021"
 | 
			
		||||
build = "buildscript/main.rs"
 | 
			
		||||
license = "GPL-3.0-only"
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										19
									
								
								Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						@ -0,0 +1,19 @@
 | 
			
		||||
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,10 +1,10 @@
 | 
			
		||||

 | 
			
		||||

 | 
			
		||||
 | 
			
		||||
A high-precision scientific calculator with support for units, derivatives, and more.
 | 
			
		||||
 | 
			
		||||
Many features are missing, this is still under development.
 | 
			
		||||
 | 
			
		||||
**Web demo: [here](daisy.betalupi.com)**
 | 
			
		||||
**Web demo: [here](https://daisy.betalupi.com) (won't work on mobile)**
 | 
			
		||||
 | 
			
		||||
# 📦 Installation
 | 
			
		||||
 - **Cargo:** `cargo install daisycalc`
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										17
									
								
								TODO.md
									
									
									
									
									
								
							
							
						
						@ -1,5 +1,4 @@
 | 
			
		||||
## Version Bump checklist
 | 
			
		||||
 - TODO: build and publish script
 | 
			
		||||
 - update Cargo.toml
 | 
			
		||||
 - run cargo test
 | 
			
		||||
 - commit
 | 
			
		||||
@ -7,38 +6,29 @@
 | 
			
		||||
 - merge
 | 
			
		||||
 - git tag -a v1.0.0 -m "Version 1.0.0" on merge commit
 | 
			
		||||
 - cargo publish
 | 
			
		||||
 - Update packages
 | 
			
		||||
 - Build wasm & push changes
 | 
			
		||||
 | 
			
		||||
 - Update AUR package
 | 
			
		||||
 | 
			
		||||
## Pre-release
 | 
			
		||||
 - Tuple operations
 | 
			
		||||
 - we don't need vectors as arguments to operators
 | 
			
		||||
 - Fix linelocation when evaluating functions
 | 
			
		||||
 | 
			
		||||
## Parser
 | 
			
		||||
 - Should functions be operators?
 | 
			
		||||
 - Binary, hex, octal numbers
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## General
 | 
			
		||||
 - Better tests (assignment, many expressions in one context)
 | 
			
		||||
 - Optional config file
 | 
			
		||||
 - Optional history file
 | 
			
		||||
 - evaluate straight from command line
 | 
			
		||||
 - Package for debian, nix
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## Internals
 | 
			
		||||
 - Non-recursive treeify
 | 
			
		||||
 - Faster factorial function. Maybe use gamma instead?
 | 
			
		||||
 - Arbitrary precision float (rug doesn't offer arbitrary exponents)
 | 
			
		||||
 - Arbitrary precision floats
 | 
			
		||||
 | 
			
		||||
## Math Features
 | 
			
		||||
 - Mean, Median, Min
 | 
			
		||||
 - Arbitrary base logarithm
 | 
			
		||||
 - Derivatives
 | 
			
		||||
 - CAS features (trig, roots and powers)
 | 
			
		||||
 - Complex numbers
 | 
			
		||||
 - acot/acoth functions
 | 
			
		||||
 - Sums and products with functional arguments
 | 
			
		||||
@ -48,8 +38,7 @@
 | 
			
		||||
 - Fix terminal color detection
 | 
			
		||||
 - Live syntax/output (like firefox js terminal)
 | 
			
		||||
 - Syntax highlighting
 | 
			
		||||
 - fish-style tab completion
 | 
			
		||||
 - Numbered expressions, history recall
 | 
			
		||||
 - Numbered history recall
 | 
			
		||||
 - Enable/disable unit sets (defaults?)
 | 
			
		||||
 - Consistent unit ordering
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -49,7 +49,7 @@ value = "1.602176634e-19 C"
 | 
			
		||||
enum_name = "ElectronMass"
 | 
			
		||||
pretty_name = "Electron mass"
 | 
			
		||||
strings = ["electronmass"]
 | 
			
		||||
value = "9.1093837015-31 kg"
 | 
			
		||||
value = "9.1093837015e-31 kg"
 | 
			
		||||
 | 
			
		||||
[[constant]]
 | 
			
		||||
enum_name = "ProtonMass"
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								server/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						@ -0,0 +1,2 @@
 | 
			
		||||
/site/node_modules
 | 
			
		||||
/pkg
 | 
			
		||||
@ -7,7 +7,7 @@ networks:
 | 
			
		||||
 | 
			
		||||
services:
 | 
			
		||||
  daisy:
 | 
			
		||||
    build: ./.
 | 
			
		||||
    build: .
 | 
			
		||||
    container_name: daisy
 | 
			
		||||
    restart: unless-stopped
 | 
			
		||||
 | 
			
		||||
@ -22,7 +22,6 @@
 | 
			
		||||
 | 
			
		||||
				margin: 0;
 | 
			
		||||
				padding: 0;
 | 
			
		||||
				overflow: hidden;
 | 
			
		||||
 | 
			
		||||
				height: 100vh;
 | 
			
		||||
			}
 | 
			
		||||
@ -101,6 +100,11 @@
 | 
			
		||||
			<a href="https://aur.archlinux.org/packages/daisy" target="_blank" rel="noopener noreferrer">AUR</a>
 | 
			
		||||
		</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">
 | 
			
		||||
			// See wasm-pack docs
 | 
			
		||||
			// Build with `wasm-pack build --release --target web --out-dir pkg`
 | 
			
		||||
							
								
								
									
										17
									
								
								server/site/package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						@ -0,0 +1,17 @@
 | 
			
		||||
{
 | 
			
		||||
  "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=="
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
		 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  | 
							
								
								
									
										15
									
								
								shell.nix
									
									
									
									
									
								
							
							
						
						@ -1,11 +1,22 @@
 | 
			
		||||
{ nixpkgs ? import <nixpkgs> { }}:
 | 
			
		||||
let
 | 
			
		||||
 pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/f155f0cf4ea43c4e3c8918d2d327d44777b6cad4.tar.gz") {};
 | 
			
		||||
  # If you set hash to an empty string, you'll get
 | 
			
		||||
  # an error with the correct hash.
 | 
			
		||||
  pinnedPkgs = nixpkgs.fetchFromGitHub {
 | 
			
		||||
    owner  = "NixOS";
 | 
			
		||||
    repo   = "nixpkgs";
 | 
			
		||||
    rev    = "4ecab3273592f27479a583fb6d975d4aba3486fe";
 | 
			
		||||
    sha256 = "btHN1czJ6rzteeCuE/PNrdssqYD2nIA4w48miQAFloM=";
 | 
			
		||||
  };
 | 
			
		||||
  pkgs = import pinnedPkgs {};
 | 
			
		||||
 | 
			
		||||
in pkgs.mkShell {
 | 
			
		||||
  buildInputs = with pkgs; [
 | 
			
		||||
    cargo
 | 
			
		||||
    rustc
 | 
			
		||||
    rustfmt
 | 
			
		||||
    m4
 | 
			
		||||
    rust-analyzer
 | 
			
		||||
    wasm-pack
 | 
			
		||||
   ];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										3
									
								
								site/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						@ -1,3 +0,0 @@
 | 
			
		||||
/node_modules
 | 
			
		||||
/package-lock.json
 | 
			
		||||
/pkg
 | 
			
		||||
@ -19,6 +19,7 @@ pub fn eval_operator(context: &mut Context, g: &Expression) -> Result<Option<Exp
 | 
			
		||||
 | 
			
		||||
			if args.len() != 1 {panic!()};
 | 
			
		||||
			let a = &args[0];
 | 
			
		||||
			let mut args_ll = op_loc.clone();
 | 
			
		||||
 | 
			
		||||
			if sh_vars.len() == 1 {
 | 
			
		||||
				if let Expression::Tuple(l, v) = a {
 | 
			
		||||
@ -28,6 +29,7 @@ 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()));
 | 
			
		||||
			} else {
 | 
			
		||||
				let Expression::Tuple(l, v) = a else {
 | 
			
		||||
@ -46,18 +48,28 @@ pub fn eval_operator(context: &mut Context, g: &Expression) -> Result<Option<Exp
 | 
			
		||||
 | 
			
		||||
				let mut i = 0;
 | 
			
		||||
				while i < sh_vars.len() {
 | 
			
		||||
					args_ll += v[i].get_linelocation();
 | 
			
		||||
					context.add_shadow(sh_vars[i].clone(), Some(v[i].clone()));
 | 
			
		||||
					i += 1;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
			let r = evaluate(context, &exp)?;
 | 
			
		||||
			let r = evaluate(context, &exp);
 | 
			
		||||
			context.clear_shadow();
 | 
			
		||||
 | 
			
		||||
			match r {
 | 
			
		||||
				Ok(mut r) => {
 | 
			
		||||
					r.set_linelocation(&args_ll);
 | 
			
		||||
					return Ok(Some(r));
 | 
			
		||||
				},
 | 
			
		||||
 | 
			
		||||
				Err( (_, err) ) => {
 | 
			
		||||
					return Err((args_ll, err));
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		Operator::Negative => {
 | 
			
		||||
			if args.len() != 1 { panic!() };
 | 
			
		||||
			let args = &args[0];
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										20
									
								
								src/lib.rs
									
									
									
									
									
								
							
							
						
						@ -68,9 +68,7 @@ cfg_if::cfg_if! {
 | 
			
		||||
						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);
 | 
			
		||||
 | 
			
		||||
					match r {
 | 
			
		||||
@ -78,7 +76,6 @@ cfg_if::cfg_if! {
 | 
			
		||||
							out += t;
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
					}
 | 
			
		||||
				},
 | 
			
		||||
 | 
			
		||||
				"\x7F" => { unsafe { (*state).promptbuffer.backspace(); } },
 | 
			
		||||
@ -91,7 +88,20 @@ cfg_if::cfg_if! {
 | 
			
		||||
				//'\x04' | '\x03'
 | 
			
		||||
				//=> { break 'outer; },
 | 
			
		||||
 | 
			
		||||
				_ => { unsafe { (*state).promptbuffer.add_char(s.chars().next().unwrap()); } },
 | 
			
		||||
				// Only process sane characters
 | 
			
		||||
 | 
			
		||||
				_ => {
 | 
			
		||||
					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) };
 | 
			
		||||
 | 
			
		||||
@ -120,7 +120,7 @@ pub fn main() -> Result<(), std::io::Error> {
 | 
			
		||||
					// Only process sane characters
 | 
			
		||||
					'a'..='z' | 'A'..='Z' | '0'..='9'
 | 
			
		||||
					|'!'|'@'|'#'|'$'|'%'|'^'|'&'|'*'|'('|')'
 | 
			
		||||
					|'?'|'~'|','|'.'|'['|']'
 | 
			
		||||
					|'?'|'~'|','|'.'|'['|']'|' '
 | 
			
		||||
					|'<'|'>'|'/'|'_'|'-'|':'|'|'|'='|'+'|';'
 | 
			
		||||
					=> { pb.add_char(*q); },
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||