the-little-typer/pie

Reader is too liberal

david-christiansen opened this issue · 0 comments

Our re-use of the Racket reader leads to this implementation accepting programs that the book implies should be rejected. Here are examples from an email that I received:

1. Pipe-Delimited Atoms

In the textbook, an Atom is supposedly an apostrophe followed by one or more letters or hyphens. However, in the current version of Pie you can also use pipes.
Example code:

(check-same Atom '|sam| 'sam)
(check-same Atom '|s||a||m| 'sam)
(check-same Atom '|||s|am 'sam)
(check-same Atom '|| '||||||)

2. Spaces in Atoms

I don't think this matters as much, but a space is not a letter or hyphen, so I might as well mention it. Also, this messes with the syntax highlighting.
Example code:

(check-same Atom '    abc 'abc)
(check-same Atom '      abc '  abc)

3. Number Oddities

I doubt anyone would ever stumble upon this unless they've already programmed in Racket. Also, I don't think any of these even need changing. Anyway, here's the example code:

(check-same Nat -0 0)
(check-same Nat 0/3 0)
(check-same Nat -0/3 0)
(check-same Nat 12/4 3)
(check-same Nat #e5 5)
(check-same Nat 2+0i 2)
(check-same Nat #x10 16)