Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED!nerds-end From: Hans-Peter Diettrich Newsgroups: comp.compilers Subject: Re: type or identifier fundamental parsing issue - Need help from parsing experts Date: Wed, 04 Jul 2012 11:43:08 +0100 Organization: Compilers Central Lines: 31 Sender: johnl@iecc.com Approved: comp.compilers@iecc.com Message-ID: <12-07-007@comp.compilers> References: <12-07-004@comp.compilers> NNTP-Posting-Host: news.iecc.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: leila.iecc.com 1341694743 37234 64.57.183.58 (7 Jul 2012 20:59:03 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Sat, 7 Jul 2012 20:59:03 +0000 (UTC) Keywords: types, parse, practice Posted-Date: 07 Jul 2012 16:59:03 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:707 AD schrieb: > Greetings All, > > I am dealing with a programming langauge that supports something like > sizeof() as well as sizeof() expression. > > For parsing such a construct, one would need a parser/yacc rule somewhat like > the following: > > SIZEOF_KEYWORD '(' IDENTIFIER ')' > > The fundamemtal problem in the rules of the language (that I am dealing with) > is that its lookup/resolution rule *doesn't* allow me to check in symbol table > if that 'IDENTIFIER' is a type or non-type variable. Problem is, this language > supports certain constructs which can potentially/later make such early > lookup/resolution decisions wrong. In short, name resolutions in this langauge > (as per the langauge definition) can only be initiated after the entire source > code has been completely parsed/seen. There exist pros and cons. The C preprocessor *requires* that sizeof is a built-in *macro*, so that it can be used in #if conditions. OTOH the size of structs depends heavily on the target environment, alignments and other factors, so that I'd delay the evaluation until code generation, where all involved factors are definitely known. Anything between these extremes is possible as well. The real question is: Do there exist reasons/situations, where sizeof *must* be evaluated prior to the code generation/execution phase? DoDi