Skip to content

Calculator example: fixing some weird behavior about whitespaces#580

Open
crguezl wants to merge 24 commits intokach:masterfrom
crguezl:master
Open

Calculator example: fixing some weird behavior about whitespaces#580
crguezl wants to merge 24 commits intokach:masterfrom
crguezl:master

Conversation

@crguezl
Copy link

@crguezl crguezl commented Jun 4, 2021

Hi,

Thanks for giving us Nearley.js. It is a great tool and I have used successfully in the classroom this course.

This pull request is about the arithmetic.ne grammar example in examples/calculator. When you run it, it has a peculiar behavior for some inputs like:

 ➜  calculator git:(master) . ./build-and-test.sh 
> sinpi
1.2246467991473532e-16
> sqrtsinpi
1.1066376096750703e-8

that is due to the set of rules for N and P and _

With the proposed change, this is the new behavior:

calculator git:(master) ✗ . ./build-and-test.sh
> sinpi
-----^  Error.
> sin(pi)
1.2246467991473532e-16
> sqrtsinpi
------^  Error.
> sqrt(sin(pi))
1.1066376096750703e-8
> 

Nothing else changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants