Commit graph

106 commits

Author SHA1 Message Date
12455924e1
refactor: create constant for tests 2026-10-14 16:52:07 -07:00
702cf74647
feat: generalize splitting for plus.minus 2026-10-14 16:50:51 -07:00
2d6f03c28c
build: update flake (late commit) 2026-10-09 18:57:26 -07:00
5cdfbfea5e
refactor: avoid extra owned string
I think this is more readable, too
2026-10-09 18:53:02 -07:00
acc49edd31
feat: generalize removing and adding back prefix 2026-10-09 18:50:19 -07:00
da82532361
refactor(formatting): move tests into module 2026-10-09 16:20:04 -07:00
046a3e5b20
feat: ignore underscores in input
this isn't useful for typst usually,
since underscores are subscript and don't appear in expressions much.

however, when using tylc as a standalone calculator,
this is useful eg to seperate sets of three digits.

idea totally stolen from rust literals

note that this might cause problems when it comes to special variables,
eg A_n for Avogadro's number (but just A is fine)
2026-10-09 16:10:32 -07:00
bb985f917a
refactor: create submodules for tests 2026-10-06 16:21:18 -07:00
00dfcdb10c
fix: do not panic with zero-sized result 2026-10-06 16:17:02 -07:00
3745b655ba
refactor: factor out function aquisition 2026-10-06 15:56:10 -07:00
69d8d111ba
refactor: improve eval error handling (end)
now most of the panics come from Vec::remove,
which can be fixed with Vec::try_remove when it's stabolized
2026-10-06 15:49:16 -07:00
d6b775abfb
refactor: improve eval error handling (start) 2026-10-06 15:49:07 -07:00
3d4e9d8067
fix: recognize unary operators at ParenthesisStart 2026-10-06 12:30:13 -07:00
f1c6073708
feat: add ln function
this one is easier than log or root, because it only takes one arg
2026-10-06 11:51:04 -07:00
e59f928192
refactor: simplify input logic 2026-10-04 16:45:48 -07:00
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