9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Joel Salomon <JoelCSalomon@Gmail.com>
To: 9fans@cse.psu.edu
Subject: [9fans] cc lexer bug?
Date: Sun, 18 Feb 2007 15:19:42 -0500	[thread overview]
Message-ID: <cd10e193dd8f20c43d30c91b7a8dd4a5@plan9.jp> (raw)

cpu% cat t.c
void foo (void)
{
	double d;
	d = 08.7;
	USED(d);
}
cpu% 8c t.c
t.c:4 syntax error, last name: 8.7
cpu% 

This came up as I’m making my lexer for C able to scan numbers.  I
tried to understand ken’s code, but it gets very hairy right around
/sys/src/cmd/cc/lex.c:751 — and I think there’s a bug.  Or, at least,
an undocumented departure from the ANSI standard; Harbison & Steele
(5E) suggest that “08.7” is a valid floating point constant.

As far as my lexer is concerned (http://www.tip9ug.jp/who/chesky/comp/lex.c,
if anyone cares), it’s using line-at-a-time buffering courtesy of
Brdstr(2), so I’m back to thinking that regcomp(2) + strtod(2) et al.
is the way to go.  It won’t handle hex floats, but who cares?

--Joel



             reply	other threads:[~2007-02-18 20:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-18 20:19 Joel Salomon [this message]
2007-02-18 21:22 ` erik quanstrom
2007-02-18 22:07   ` Joel Salomon
2007-02-18 22:40     ` erik quanstrom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cd10e193dd8f20c43d30c91b7a8dd4a5@plan9.jp \
    --to=joelcsalomon@gmail.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).