Re: YACC parser & conditional compilation directives

johnm@soda.CSUA.Berkeley.EDU (John D. Mitchell)
Tue, 27 Jun 1995 15:00:31 GMT

          From comp.compilers

Related articles
YACC parser & conditional compilation directives spx4vc@cf.ac.uk (Vadim) (1995-06-23)
Re: YACC parser & conditional compilation directives johnm@soda.CSUA.Berkeley.EDU (1995-06-27)
Re: YACC parser & conditional compilation directives ccrlphr@xensei.com (1995-06-27)
Re: YACC parser & conditional compilation directives scott@infoadv.mn.org (Scott Nicol) (1995-07-05)
| List of all articles for this month |
Newsgroups: comp.compilers,comp.unix.programmer
From: johnm@soda.CSUA.Berkeley.EDU (John D. Mitchell)
Keywords: yacc, PCCTS, semantics
Organization: Computer Science Undergraduate Association, UC Berkeley
References: 95-06-028
Date: Tue, 27 Jun 1995 15:00:31 GMT
Status: RO

Vadim <spx4vc@cf.ac.uk> wrote:
[...Conditional compilation code example, etc....]
>Of course, I could use some kind of hack in lexer, that would recognize
>IFs, .ELSEs, .ENDIFs etc. and act accordindly, but I want to know
>if there is a _nice_ way of skipping the conditioned out source ?
>Besides, the conditional expression may be quite complex and I would have
>problems with its parsing, had I used the hack.
>
>Vadim
>[Yacc doesn't handle this kind of two-level grammar at all well. You need
>either a two-pass system or some gross lexical hacks. -John]


Right, YACC is unsuitable for this sort of thing. This is, however,
a perfect example where the 'semantic predicates' capability of the
ANTLR parser generator that is part of the PCCTS suit.


You want to be able to have semantic information that you have gathered
during parsing to affect how you continute to parse the input. In your
example you don't need a two-pass system or any of that malarky as
your conditional directive is already decidable.


Anyways, to find out more about PCCTS (snarf the documentation, code,
examples, etc.) check out ftp://ftp.parr-research.com/pub/pccts
and/or the comp.compilers.tools.pccts newsgroup.


Hope this helps,
John
--


Post a followup to this message

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