Re: type or identifier fundamental parsing issue - Need help from parsing experts

Hans-Peter Diettrich <DrDiettrich1@aol.com>
Wed, 04 Jul 2012 11:43:08 +0100

          From comp.compilers

Related articles
type or identifier fundamental parsing issue - Need help from parsing hsad005@gmail.com (AD) (2012-07-03)
Re: type or identifier fundamental parsing issue - Need help from pars gneuner2@comcast.net (George Neuner) (2012-07-04)
Re: type or identifier fundamental parsing issue - Need help from pars DrDiettrich1@aol.com (Hans-Peter Diettrich) (2012-07-04)
Re: type or identifier fundamental parsing issue - Need help from pars torbenm@diku.dk (2012-07-11)
Re: C arcana, was type or identifier fundamental parsing issue - Need christian.bau@cbau.wanadoo.co.uk (christian.bau) (2012-07-12)
| List of all articles for this month |

DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=iecc.com; h=cc:from:subject:date:sender:message-id:references:mime-version:content-type:content-transfer-encoding:vbr-info; s=9180.4ff8a317.k1207; i=johnl@user.iecc.com; bh=++4DwmSFLah4dih8asvzdct5DCrj0yImj+q/BsiWsgA=; b=FnKMgBOjLjn+1lh4LEhAzLSK3mIapCQO/4FQL3CEXAmA9x2Rc8xzu7Oe8KaW1RB/TIofl03ODKM6sHnj8WMNrl8HfsU2pKYW/24v/xFzjOsSPvRn2rAecMZzcRBGKWCeBs4m+aVkfvMIPJmvc1EhuW/v3jXo7lBPcAFHg2qAD+M=
VBR-Info: md=iecc.com; mc=all; mv=dwl.spamhaus.org
From: Hans-Peter Diettrich <DrDiettrich1@aol.com>
Newsgroups: comp.compilers
Date: Wed, 04 Jul 2012 11:43:08 +0100
Organization: Compilers Central
References: 12-07-004
Keywords: types, parse, practice
Posted-Date: 07 Jul 2012 16:59:03 EDT

AD schrieb:
> Greetings All,
>
> I am dealing with a programming langauge that supports something like
> sizeof(<typename>) as well as sizeof(<variable-name>) 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


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.