From owner-freebsd-hackers Mon Nov 5 12:28:59 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from snipe.prod.itd.earthlink.net (snipe.mail.pas.earthlink.net [207.217.120.62]) by hub.freebsd.org (Postfix) with ESMTP id 656F737B405; Mon, 5 Nov 2001 12:28:57 -0800 (PST) Received: from dialup-209.245.136.200.dial1.sanjose1.level3.net ([209.245.136.200] helo=mindspring.com) by snipe.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 160qMU-0002vi-00; Mon, 05 Nov 2001 12:28:51 -0800 Message-ID: <3BE6F6B4.D9A0D806@mindspring.com> Date: Mon, 05 Nov 2001 12:29:40 -0800 From: Terry Lambert Reply-To: tlambert2@mindspring.com X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Matthew Emmerton Cc: David O'Brien , Poul-Henning Kamp , hackers@FreeBSD.ORG Subject: Re: Idea for project: Make cpp do unifdef service... References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Matthew Emmerton wrote: > > I looked into this over the weekend. Although it's fairly trivial to make > it understand things like '#if defined(FOO)', it's somewhat more tricky to > understand something like '#if ((!defined(FOO) && defined(BAR)) || > defined(FUBAR))', which I believe was the functionality that phk wanted, > and why he requested it of cpp rather than unifdef. This is a pretty trivial lex/yacc program to write; I admit that changing the exiting code to handle this would be difficult (it's trivial code), but the exiting code already breaks on the "#" not in the first column, and doesn't handle things like C++ comments, and does bad things with single and double quote mixing. It also doesn't handle numeric constants correctly. Given the line rules for preprocessor directives, this would be an easy program to get right. If someone wants to do something about this, it would be best, IMO, to: o Rewrite it from scratch in lex and yacc. o Do _NOT_ jam it into gcc, both because of the cpp maybe going away in the future, and because the language and tools dependence that would be added. It's a good job for someone cutting their teeth on lex/yacc (hint: you can handle all the stateful stuff using start states, including the expression evaluation). -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message