From owner-freebsd-hackers@FreeBSD.ORG Wed Jan 16 15:07:05 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5A3A616A418 for ; Wed, 16 Jan 2008 15:07:05 +0000 (UTC) (envelope-from lulf@stud.ntnu.no) Received: from bene2.itea.ntnu.no (bene2.itea.ntnu.no [IPv6:2001:700:300:3::57]) by mx1.freebsd.org (Postfix) with ESMTP id 5BAA613C45B for ; Wed, 16 Jan 2008 15:07:04 +0000 (UTC) (envelope-from lulf@stud.ntnu.no) Received: from localhost (localhost [127.0.0.1]) by bene2.itea.ntnu.no (Postfix) with ESMTP id 79C3D90004; Wed, 16 Jan 2008 16:07:02 +0100 (CET) Received: from carrot.studby.ntnu.no (caracal.stud.ntnu.no [129.241.56.185]) by bene2.itea.ntnu.no (Postfix) with ESMTP id B1E8790003; Wed, 16 Jan 2008 16:06:56 +0100 (CET) Date: Wed, 16 Jan 2008 16:06:56 +0100 From: Ulf Lilleengen To: Bob Bishop Message-ID: <20080116150655.GA47095@carrot.studby.ntnu.no> References: <20080116093302.GA13632@carrot.studby.ntnu.no> <0CE4984F-41F7-44EA-9FE7-0E573DB2B338@gid.co.uk> <20080116133214.GA2666@carrot.studby.ntnu.no> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) X-Virus-Scanned: Debian amavisd-new at bene2.itea.ntnu.no Cc: freebsd-hackers@freebsd.org Subject: Re: Csup cvsmode build discussion X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jan 2008 15:07:05 -0000 On ons, jan 16, 2008 at 02:39:26pm +0000, Bob Bishop wrote: > Hi, > > On 16 Jan 2008, at 13:32, Ulf Lilleengen wrote: > >> On Wed, Jan 16, 2008 at 11:08:20AM +0000, Bob Bishop wrote: >>> [...] >>> Why do you want prefixing? And precisely what do you want to do with >>> parameters? >>> >> Prefixing is needed since csup already have a configuration parser written >> in >> lex/yacc and therefore needed to avoid conflicts. > > You can alternatively avoid conflicts by putting both grammars in the same > file, with an entry rule which refers to one or other of the two grammars' > real entries based on a defined token. You then arrange for the lexer to > supply the appropriate value of the switch token each time the parser is > started up. > As noted by others in this thread, the lex and yacc versions in base does in fact support prefixing. Thus, the only problem is reentrancy, which I've commented on below. >> Parameters is nice if one >> were to modify the parser to take extra arguments, I don't have a concrete >> example for it yet, but it's nonetheless a requirement for reentrancy. >> [etc] > > You may be able to do this using a variation on the above trick. > So for the reentrancy part, what you suggest is that instead of passing the argument to the reentrant parser, I create the global variables for each thread using the parser, and then use one or the other global variables depending on which thread is calling the parser? It's a very interesting trick, and I think it might work. It's not very "scalable", but it's a good workaround to be able to use the base system lex and yacc. However, this might only fix the issue with yacc if I'm thinking correctly, because the lexer also needs to be told about this for reentrancy. (But perhaps a much smaller problem since it's a matter of updating the lex version in base). Anyway, thanks for a useful suggestion. I'll try it out. -- Ulf Lilleengen