19 Commits

Author SHA1 Message Date
27ea64e172 Merge branch 'dev' 2023-10-14 09:37:06 -07:00
b7a6378589 Fixed default.nix 2023-10-14 09:36:25 -07:00
d6f1ce0442 Merge minor chagnes from 'dev' 2023-10-14 09:21:01 -07:00
5e34017225 Added nix package 2023-10-14 09:13:54 -07:00
d9730fd699 Added contrib guide 2023-09-29 10:18:10 -07:00
5788ffa085 Updated TODO 2023-09-29 10:17:54 -07:00
a75f6197cd Merge pull request #11 from rm-dr/dev
Version bump to v1.1.5
2023-09-28 13:38:21 -07:00
2f2c005c86 Version bump 2023-09-28 13:32:34 -07:00
ffebcf2e15 Merge branch 'master' into dev 2023-09-28 13:30:08 -07:00
4e1df2399b Merge pull request #10 from bojohnson5/testing
fix electron mass
2023-09-28 13:29:23 -07:00
5a921cfc7b fix electron mass 2023-09-28 14:35:16 -04:00
2531524ffd Updated makefile 2023-09-22 11:22:36 -07:00
e5525adcca Updated todo 2023-09-22 11:05:58 -07:00
a61cbf29e5 Makefile edits 2023-09-22 11:05:30 -07:00
39ab47530e Merge pull request #9 from rm-dr/dev
Merge v1.1.4
2023-09-22 11:01:55 -07:00
be28669416 Sync with master 2023-09-22 11:00:28 -07:00
7658ff76ef Version bump 2023-09-22 10:59:35 -07:00
e9d392b80b Fixed linelocation inside user functions 2023-09-22 10:58:51 -07:00
63d4a01095 Merge pull request #8 from rm-dr/dev
Merge v1.1.3
2023-09-22 10:48:59 -07:00
9 changed files with 76 additions and 26 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/target /target
/src/target /src/target
/pkg /pkg
/result

31
CONTRIBUTING.MD Normal file
View File

@ -0,0 +1,31 @@
# Contribution guidelines for Daisy
## Pull requests
All PRs should merge to `dev`. See "branching" below.
## Versioning
Daisy uses [semantic versioning](https://semver.org/), which looks like `maj.min.patch`. In short:
- `maj`: Incremented on large, incompatible changes
- `min`: Incremented on new features
- `patch`: Incremented on bugfixes
Whenever one of the above fields is incremented, all sub-fields are reset to zero. When `min` is incremented, `patch` is set to zero.
## Branching
Daisy uses a branch model much like the one described [here](https://nvie.com/posts/a-successful-git-branching-model).
- `master`: 1 commit = 1 release. This is always a merge comit from `dev`, and is always tagged with a version.
- `dev`: main development branch. Never deleted. Most work happens here.
- `features`: temporary branches pulled from `dev` and merged to `dev` for larger features.
- Always merge with git's `--no-ff` option for a more detailed history.
## Releases
What to do
- Merge into `master` (`git merge --no-ff dev`)
- Tag merge commit on `master` (`git tag -a v1.0.0 -m "Version 1.0.0"`)
- `cargo publish`
- Update web demo & pull server (`make docker`)
- Update aur package

2
Cargo.lock generated
View File

@ -28,7 +28,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "daisycalc" name = "daisycalc"
version = "1.1.3" version = "1.1.5"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"num", "num",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "daisycalc" name = "daisycalc"
version = "1.1.3" version = "1.1.5"
edition = "2021" edition = "2021"
build = "buildscript/main.rs" build = "buildscript/main.rs"
license = "GPL-3.0-only" license = "GPL-3.0-only"

View File

@ -14,5 +14,6 @@ publish:
cargo test cargo test
cargo publish cargo publish
docker: docker: wasm
docker build ./server -t git.betalupi.com/mark/daisy docker build ./server -t git.betalupi.com/mark/daisy --no-cache
docker push git.betalupi.com/mark/daisy

20
TODO.md
View File

@ -1,19 +1,3 @@
## Version Bump checklist
- update Cargo.toml
- run cargo test
- commit
- push
- merge
- git tag -a v1.0.0 -m "Version 1.0.0" on merge commit
- cargo publish
- 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 ## Parser
- Should functions be operators? - Should functions be operators?
- Binary, hex, octal numbers - Binary, hex, octal numbers
@ -26,6 +10,7 @@
- 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 floats
- we don't need vectors as arguments to operators
## Math Features ## Math Features
- Mean, Median, Min - Mean, Median, Min
@ -34,6 +19,7 @@
- acot/acoth functions - acot/acoth functions
- Sums and products with functional arguments - Sums and products with functional arguments
- Add functions: gcd, inverse mod, dice - Add functions: gcd, inverse mod, dice
- Tuple operations
## Prompt ## Prompt
- Fix terminal color detection - Fix terminal color detection
@ -47,5 +33,5 @@
- long prefixes (megatonne, etc) - long prefixes (megatonne, etc)
- HMS for degrees - HMS for degrees
- Exact radians, using pi constant? - Exact radians, using pi constant?
- Weird units: flops, lumen, lux, bel - Odd units: flops, lumen, lux, bel
- Command to list units - Command to list units

View File

@ -49,7 +49,7 @@ value = "1.602176634e-19 C"
enum_name = "ElectronMass" enum_name = "ElectronMass"
pretty_name = "Electron mass" pretty_name = "Electron mass"
strings = ["electronmass"] strings = ["electronmass"]
value = "9.1093837015-31 kg" value = "9.1093837015e-31 kg"
[[constant]] [[constant]]
enum_name = "ProtonMass" enum_name = "ProtonMass"

19
default.nix Normal file
View File

@ -0,0 +1,19 @@
{ lib, fetchgit, rustPlatform }:
rustPlatform.buildRustPackage rec {
pname = "daisy";
version = "1.1.4";
cargoLock.lockFile = src + /Cargo.lock;
src = fetchgit {
url = "https://github.com/rm-dr/daisy.git";
rev = "v${version}";
sha256 = "sha256-aENuKtE1+tBRN0HZzRr8Gk+dVEYTiP6FNRz817Sk88o=";
};
meta = with lib; {
description = "A pretty command-line scientific calculator";
homepage = "https://github.com/rm-dr/daisy";
#license = licenses.GPL;
maintainers = [ maintainers.tailhook ];
};
}

View File

@ -19,6 +19,7 @@ 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 {
@ -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())); 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 {
@ -46,16 +48,26 @@ 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();
return Ok(Some(r)); match r {
Ok(mut r) => {
r.set_linelocation(&args_ll);
return Ok(Some(r));
},
Err( (_, err) ) => {
return Err((args_ll, err));
}
}
}, },
Operator::Negative => { Operator::Negative => {