Commit graph

141 commits

Author SHA1 Message Date
d6b9d7a407
refactor: use lib.rs in main.rs
this avoids duplicating unit tests, for instance

https://stackoverflow.com/a/77038955
2026-10-04 16:41:38 -07:00
564f95aa32
refactor: use Node::from from parsed Floats
this is a little nicer, hopefully it has no perf penalty
2026-10-04 16:35:22 -07:00
0afc7aab25
feat: allow changing max_digits for pretty_eval 2026-10-04 16:34:08 -07:00
69bf8f4635
refactor: impl From for Node to easily insert constants
this is mostly useful for tests and in Node::from_name
2026-10-04 16:22:53 -07:00
d8dc549954
feat: add "e" as a constant
this is not great, because due to lacking whitespace-awareness
`e sin(1)` evaluates as `esin(1)` which does not exist.
2026-10-04 16:04:25 -07:00
ba33a71501
feat: increase PREC 512 -> 2048 2026-10-02 13:37:16 -07:00
098df2aef2
fix: ignoring decimal place accidentally 2026-10-02 13:32:53 -07:00
c745d6b5d2
feat: don't print scientific notation for n < 1000
unfortunately it isn't this easy for n > 0.001,
a similar strategy seems to prefer printing eg 1.0 * 10^-1
2026-10-02 13:22:49 -07:00
ef9d07923e
refactor: simplify raw_string creation 2026-10-02 13:09:43 -07:00
3c20174ecb
feat: prettyify scientific notation
this way it's also typst-compatible!
2026-09-30 20:10:03 -07:00
46c697234c
feat: cap significant_digits to 10 in pretty_eval 2026-09-30 20:07:15 -07:00
c249d7cb41
fix: always a single leading space 2026-09-30 20:02:27 -07:00
3d67c22905
refactor: use nodes::eval helper in formatting
this also silences the corresponding dead_code warning with bin builds
2026-09-30 19:52:19 -07:00
2deabb148e
refactor: rename modules to nicer names 2026-09-30 19:48:14 -07:00
35da9a0d40
feat: return Result instead of panicking
this doesn't always work still;
there are a lot of panicking index operations there.

a feature was stabilized very recently that would help fix that:
https://github.com/rust-lang/rust/issues/146954
2026-09-30 19:39:34 -07:00
d2368adc8f
feat: create lib.rs API 2026-09-30 18:25:46 -07:00
ae9e6604e8
refactor: fix unused lint 2026-09-30 18:18:35 -07:00
4363916608
refactor: split main.rs to support planned lib.rs 2026-09-30 17:40:31 -07:00
18a777c449
refactor: sort unit tests 2026-09-30 15:40:26 -07:00
396deba4e1
test: add test for backslash re-addition 2026-09-30 15:30:40 -07:00
9bacccfb71
feat: preserve leading_spaces 2026-09-30 15:18:15 -07:00
ca9a522d2b
refactor: drastically simplify should_add_back_equals logic 2026-09-29 16:18:50 -07:00
06b6c38f30
feat: ignore and add back trailing backslash 2026-09-29 16:04:15 -07:00
15534793fd
build: enable thick lto and minimize codegen-units
binary size goes from 1224 to 1068
(as reported by `du result/bin/tylc`)
2026-09-28 13:08:32 -07:00
1bb69e7357
build: don't duplicate cargo files in the store 2026-09-28 13:08:17 -07:00
c3526bf161
refactor: add and use testing helper fn eval 2026-09-28 13:01:24 -07:00
5f25c92404
fix: plus evaluated before minus 2026-09-28 12:58:12 -07:00
b7c3972949
fix: remove leftover dbg!() 2026-08-09 10:59:11 -07:00
d7b77fe5b5
refactor: use a more generic flake style 2026-08-09 10:52:42 -07:00
4bdb51968f
fix: combine arguments in the correct order
`tylc 40e3 / 6e3` interpreted the args as "6e3/40e3"
(before this change)
2026-07-27 22:28:05 -07:00
262c55b91a
feat: add back single ampersand 2026-07-24 21:57:30 -07:00
704ef81816
feat: ignore and add back single equal sign
more than one is likely a user mistake and a panic still makes sense

should also add back '&' in the same way, if applicable
2026-07-24 21:50:58 -07:00
0dc140909f
docs: reflow comments 2026-07-24 14:23:28 -07:00
4dcbc94e0f
style: use Self where possible 2026-07-24 11:38:51 -07:00
442dc5fd91
fix: 1e-1 edge case
the "wrap up any unfinished parsing" section doesn't need to be changed,
since this edge case is only valid when there is a number after the '-'
which there never is in the case of only one extra character

in other words, 1e- is not valid:
`NumberParsing("1e-", ParseFloatError { kind: ExpNoDigits })`
2026-07-24 11:26:56 -07:00
431ea5b67e
feat: recognize dedicated minus sign
> As per Unicode 17.0.0, the ASCII hyphen-minus is not a mathematical symbol. To express the minus sign in math, U+2212 − MINUS SIGN is used instead.

https://en.wikipedia.org/wiki/Mathematical_operators_and_symbols_in_Unicode#cite_ref-7
2026-07-21 14:23:37 -07:00
6e141a0132
refactor(significant_digits): obsolete temp value
also use the correct value for if all digits are significant,
since we filter out the dot(s). in practice though, this is very rare.
2026-07-21 13:29:38 -07:00
f9d4290659
fix(significant_digits): ignore dot completely 2026-07-21 13:21:03 -07:00
c108d3a2d2
fix(significant_digits): account for no dot or many dot 2026-07-21 13:20:47 -07:00
2b7884e802
feat: add Plank's constant 'h' 2026-07-21 10:31:00 -07:00
48a1da47fb
fix: implicit operator for adjacent parenthesis 2026-07-20 20:25:10 -07:00
016e21ac5a
fix: include '9' when checking for any more digits 2026-07-20 20:13:39 -07:00
ca6af4d06f
tests: for significant digits 2026-07-20 19:41:50 -07:00
6e14c4e967
style: don't bury fn main 2026-07-20 19:34:44 -07:00
c8bc766e2a
feat: also check consecutive nines
fixes `tylc "12.0096 + 15.9994 * 2"`
2026-07-20 19:32:22 -07:00
909bcfef6d
feat: trim out consective zeros
instead of clamping the number of significant digits

fixes `tylc "14.00643 + 1.00784 * 4 + 35.446 + 15.9994 * 4"`
2026-07-20 19:31:39 -07:00
42ccff8b12
fix: maximum significant digits
oops :3
2026-07-16 11:39:22 -07:00
9372d5dfa8
feat: support unicode mult & div 2026-07-16 11:36:21 -07:00
4d7a806caa
feat: support sqrt
other roots may prove to be quite a challenge,
since I would need to parse the syntax `root(base, value)`
2026-07-16 11:33:03 -07:00
93d8147048
feat: set a max for displayed significant digits 2026-07-16 11:29:51 -07:00