[Nix-dev] isFloat
Christian Theune
ct at flyingcircus.io
Tue Jan 5 10:34:25 CET 2016
Hi,
(I lost a mail. Hopefully this doesn’t end up in a double post).
I got it working and made a ticket to get into a more structured working mode. :)
nix-instantiate --eval -E '123.45 * 1E2'
12345
If anyone wants to follow up:
https://github.com/NixOS/nix/issues/760
Happy to do whatever is necessary to wrap this up. :)
Cheers,
Christian
> On 05 Jan 2016, at 00:48, Christian Theune <ct at flyingcircus.io> wrote:
>
> Hi,
>
> alright. I was really interested in trying to see whether I can figure out what’s going on.
>
> I didn’t quite get it working today and my lack of Flex/Bison understanding is blocking me from figuring out what’s going on. :/
>
> Most changes were done by reviewing everything that touched the integer handling and following all traces of all things it touched.
>
> My current work is here:
> https://github.com/NixOS/nix/compare/master...ctheune:ctheune-floats?expand=1
>
> For some reason, the lexer seems to fail picking up the FLOAT symbol _at all_ and complains:
>
> nix-instantiate --eval -E '123.1'
> error: syntax error, unexpected INT, expecting ID or OR_KW or DOLLAR_CURLY or '"', at (string):1:5
>
> So it notices the first thing as an INT (I think, it might be a float, but I don’t think so) but the “.” seems to be interpreted as the attribute access operator. I didn’t find the rule for this - can someone point this out to me?
>
> Overall, I hope I didn’t make too much of a mess. I picked up a few little things along the way that I think warranted a quick correction (NixInt vs. regular int references and using a custom parser instead of stoi - or should that be stol?).
>
> If someone could help me figure out what I’m butchering in the Lexer (or elsewhere) …
>
> Cheers,
> Christian
>
>> On 04 Jan 2016, at 17:27, Eelco Dolstra <eelco.dolstra at logicblox.com> wrote:
>>
>> Hi,
>>
>> On 04/01/16 17:12, Rok Garbas wrote:
>>
>>> should we add this to nixpkgs/lib? it is usefull (using it right now) :)
>>
>> IMHO, it would be cleaner to add floats to the Nix language. Before somebody
>> decides to implement floating point arithmetic using a bunch of regexps ;-)
>>
>> --
>> Eelco Dolstra | LogicBlox, Inc. | http://nixos.org/~eelco/
>> _______________________________________________
>> nix-dev mailing list
>> nix-dev at lists.science.uu.nl
>> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
> --
> Christian Theune · ct at flyingcircus.io · +49 345 219401 0
> Flying Circus Internet Operations GmbH · http://flyingcircus.io
> Forsterstraße 29 · 06112 Halle (Saale) · Deutschland
> HR Stendal HRB 21169 · Geschäftsführer: Christian. Theune, Christian. Zagrodnick
>
--
Christian Theune · ct at flyingcircus.io · +49 345 219401 0
Flying Circus Internet Operations GmbH · http://flyingcircus.io
Forsterstraße 29 · 06112 Halle (Saale) · Deutschland
HR Stendal HRB 21169 · Geschäftsführer: Christian. Theune, Christian. Zagrodnick
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
Url : http://lists.science.uu.nl/pipermail/nix-dev/attachments/20160105/5ee451f4/attachment.bin
More information about the nix-dev
mailing list