[racket] the Numbers grammar

From: milo arvidsson (miloarvidsson at gmail.com)
Date: Wed Aug 8 21:07:43 EDT 2012

I've been studying the numbers grammar in section 1.3.3 of the Racket
reference and I think I've spotted a few mistakes:

1. <exact-complex_n> allows the imaginary part of an exact complex
number to be signed given that an exact rational may be signed:

<exact-integer_n> ::= [<sign>] <unsigned-integer_n>
<exact-rational_n> ::= <exact-integer_n> / <unsigned-integer_n>
<exact-complex_n> ::= <exact-rational_n> <sign> <exact-rational_n> i

The rule allows exact complex numbers like this one: 1/2+-3/4i

but ...

1/2+-3/4i: undefined;
 cannot reference undefined identifier

2. The three alternatives in <inexact-simple_n> should be unsigned
given that <inexact-unsigned_n> uses <inexact-normal_n> which uses
<inexact-simple_n>. But since exact integers may be signed, the second
alternative in <inexact-simple_n> may be signed:

<inexact-simple_n> ::= [<exact-integer_n>] . <digits#_n>

3. <inexact-normal_n> allows #  in an exponent:

<digits#_n> ::= <digit_n>+ #*
‹inexact-normal_n› ::= <inexact-simple_n> [<exp-mark_n> [<sign>] <digits#_n>]

but ...

3.14e+87#: undefined;
 cannot reference undefined identifier

Posted on the users mailing list.