From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@cse.psu.edu From: Joel Salomon Date: Sun, 18 Feb 2007 15:19:42 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Subject: [9fans] cc lexer bug? Content-Transfer-Encoding: quoted-printable Topicbox-Message-UUID: 114e35d6-ead2-11e9-9d60-3106f5b1d025 cpu% cat t.c void foo (void) { double d; d =3D 08.7; USED(d); } cpu% 8c t.c t.c:4 syntax error, last name: 8.7 cpu%=20 This came up as I=E2=80=99m making my lexer for C able to scan numbers. = I tried to understand ken=E2=80=99s code, but it gets very hairy right arou= nd /sys/src/cmd/cc/lex.c:751 =E2=80=94 and I think there=E2=80=99s a bug. O= r, at least, an undocumented departure from the ANSI standard; Harbison & Steele (5E) suggest that =E2=80=9C08.7=E2=80=9D is a valid floating point consta= nt. As far as my lexer is concerned (http://www.tip9ug.jp/who/chesky/comp/lex= .c, if anyone cares), it=E2=80=99s using line-at-a-time buffering courtesy of Brdstr(2), so I=E2=80=99m back to thinking that regcomp(2) + strtod(2) et= al. is the way to go. It won=E2=80=99t handle hex floats, but who cares? --Joel