|YACC parser & conditional compilation directives email@example.com (Vadim) (1995-06-23)|
|Re: YACC parser & conditional compilation directives johnm@soda.CSUA.Berkeley.EDU (1995-06-27)|
|Re: YACC parser & conditional compilation directives firstname.lastname@example.org (1995-06-27)|
|Re: YACC parser & conditional compilation directives email@example.com (Scott Nicol) (1995-07-05)|
|From:||johnm@soda.CSUA.Berkeley.EDU (John D. Mitchell)|
|Keywords:||yacc, PCCTS, semantics|
|Organization:||Computer Science Undergraduate Association, UC Berkeley|
|Date:||Tue, 27 Jun 1995 15:00:31 GMT|
Vadim <firstname.lastname@example.org> 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.
>[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,
Return to the
Search the comp.compilers archives again.