From: "boyd, rounin" <boyd@insultant.net>
To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu>
Subject: Re: [9fans] 8c (pcc) bug??
Date: Wed, 9 Feb 2005 10:32:55 +0100 [thread overview]
Message-ID: <002301c50e8a$56392af0$7c18dfd5@kilgore> (raw)
In-Reply-To: <41F879E200020C44@stateless1.tiscali.cz>
this is one nasty bug.
the problem is the // and /* comments are parsed twice:
1) in a #define
2) in an ordinary code block
the assumption that /sys/src/cmd/cc/macbody makes [case #1] is that
a #define consists of a:
- name
- optional list of args
- list of names (possibly arguments)
- line continuations
- comments
- characters
should you have the misfortune to:
#define S "//...
or
#define S "/*...
you get:
#define S "
and you are in a "world of pain".
to my mind it should be taught about strings, but this is somewhat non-trivial.
well, maybe not. it needs to know about comments to skip arguments that
maybe are hidden away in comment. ahh, this give me an idea.
/sys/src/cmd/cc/lex.c [case 2] goes to some effort to lex up strings and pass
them up to yacc. it uses esschar() which decodes chars & Runes in char and
string constants, Rune by Rune.
i'm not a language lawyer, nor do i have copies of the numerous standards,
but do i do believe that:
#define S "//foo"
should give me:
"//foo"
hmm, yeah, i think i have a fix.
--
MGRS 31U DQ 52572 12604
next prev parent reply other threads:[~2005-02-09 9:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-09 6:49 tapique
2005-02-09 9:32 ` boyd, rounin [this message]
2005-02-09 12:07 ` boyd, rounin
2005-02-09 13:29 ` C H Forsyth
2005-02-11 0:03 ` boyd, rounin
2005-02-09 13:02 ` Charles Forsyth
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='002301c50e8a$56392af0$7c18dfd5@kilgore' \
--to=boyd@insultant.net \
--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).