MrLogarithm / emeszida

SIGBOVIK 2024
5 stars 1 forks source link

Numbers #1

Open willismonroe opened 8 months ago

willismonroe commented 8 months ago

We need to parse numbers written in sexigesimal notation.

I think we should avoid parsing to decimal and back as that will run into major problems with fractions. So all of our operators need to function in sexigesimal notation. That should be easy enough but here's a repository for reference: https://github.com/HrushikeshPawar/Sexagesimal-Calculator.

A short test suite would be useful: ๐’• = 1 ๐’• = 60 (NB: how do we deal with unknown placevalues, or do we default to "1"?) ๐’•๐’• = 2 (or ๐’– = 2, *one glyph) ๐’•๐’‘ฑ๐’• = 61 ๐’Œ‹๐’• = 11 ๐’•๐’Œ‹ = 70 ๐’•๐’Œ‹๐’• = 71 ๐’•๐’•๐’Œ‹ = 130

MrLogarithm commented 8 months ago

730d32dba59b486fb071e62ca45c4234bdae0b32 implements a parser that can handle numerals. It also adds a test/ directory with all of the above examples as test cases (run with make test).

Notes:

Remaining issue:

MrLogarithm commented 8 months ago

Should ๐’Œ‹๐’‘ฑ๐’Œ‹๐’• be read as 10,0,11 or 10,11 or both?

MrLogarithm commented 8 months ago

Assuming ๐’Œ‹๐’‘ฑ๐’Œ‹๐’• is 10,0,11, this should be(?) resolved by 58ffcb1.

MrLogarithm commented 8 months ago

Should we support negative numbers, given that there was no conception of these historically? I feel a language without negatives is more in line with the spirit of SIGBOVIK.

MrLogarithm commented 8 months ago

I'm realizing there is no way to directly encode some numbers with the grammar as it exists now: e.g. 50,1 (which I think should be ๐’๐’‘ฑ๐’• where the ๐’‘ฑ is a delimiter, and not a true zero??) can't be directly input since ๐’๐’‘ฑ๐’• gets parsed as 50,0,1. Do we need to find a way to overload ๐’‘ฑ, or is there another character that can be used as a delimiter? Or do we say this is fine, and let the user construct 50,1 via addition ๐’๐’‘ฑ ๐’• + if they need such a number?

(I guess this is where whitespace would have been used as a delimiter originally? but that also introduces ambiguity between consecutive numbers separated by whitespace vs one number with whitespace between digit groups...)

willismonroe commented 8 months ago

I'm looking for good calculations from texts that we can borrow, I think they might make a good test set.

Anyway, as for ambiguous numbers, yes it's certainly going to be an issue. This text seems to imply (at least from the copy) that a space is used to mark a unit difference; image 20 a-na 1.07.30 i-ลกi 22.30

So if we want to include spaces as a delimiter and ๐’‘ฑ as a empty unit, what if a double space marks a boundary between tokens?

MrLogarithm commented 8 months ago

Sounds good - the parser currently assumes no whitespace between tokens so we will need to add an explicit " " or WS token to the grammar rules where relevant.