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) |
Newsgroups: | comp.compilers,comp.unix.programmer |
From: | Vadim <spx4vc@cf.ac.uk> |
Keywords: | yacc, question, comment |
Organization: | University of Wales College of Cardiff, Cardiff, WALES, UK. |
Date: | Fri, 23 Jun 1995 03:45:34 GMT |
Status: | RO |
I'm writing a kind of assembler translator, the grammar is perfectly
suitable for Yacc, but my problem is the conditional compilation
directives. For example, in the following source first and third
sections must be bypassed:
DEFINE a,2
IF a==1
... Do one thing ...
ELSE
.IF a==2
... Do another thing
.ELSE
... Do yet another thing
.ENDIF
ENDIF
etc.
(All directives start with dot)
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]
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.