yacc/lex and precompiler statements

"Waldo van Riemsdijk" <riemsdijk@tailor.nl>
17 Sep 1996 00:19:03 -0400

          From comp.compilers

Related articles
yacc/lex and precompiler statements riemsdijk@tailor.nl (Waldo van Riemsdijk) (1996-09-17)
Re: yacc/lex and precompiler statements scooter@mccabe.com (Scott Stanchfield) (1996-09-17)
| List of all articles for this month |

From: "Waldo van Riemsdijk" <riemsdijk@tailor.nl>
Newsgroups: comp.compilers,comp.compilers.tools.pccts
Date: 17 Sep 1996 00:19:03 -0400
Organization: NLnet
Keywords: yacc, parse, question


I have been working on a lex/yacc programme to parse VOS (a language
somewhat like pascal) in order to make a code beautifier. I hate
indenting by myself - it's a computer's job, I think.

As for the parser, it's working quite nicely. I've used the pascal
versions of yacc en lex, and Delphi 2 as the pascal compiler. Now I
get to the difficult part:

IN vos, you can use $IF -- $ELSE -- $ENDIF statements. This is not
difficult for the VOS compiler itself, since it evaluates the $IF
expression and decides which part to skip. My beautifier, however,
should be able to 'PUSH' the yacc stack and, on occurce of an $ELSE,
POP it back.

I've tried to do this in the lexicografical phase (I.E. lex) but
haven't found out how to do this. Any suggestions about this

Thanks in advance,

Waldo van Riemsdijk
[Yuck. There have been some messages about a version of yacc that does
conditional reduction of rules, quite useful in parsing some of the worst
parts of C++, but I think this is tougher. In principle, the yacc state
is just a couple of arrays and some pointers, but I fear that getting the
parse restarted and undoing the reductions since you saved the state will
be quite difficult. -John]


Post a followup to this message

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