Re: yacc/lex and precompiler statements

Scott Stanchfield <>
17 Sep 1996 22:12:53 -0400

          From comp.compilers

Related articles
yacc/lex and precompiler statements (Waldo van Riemsdijk) (1996-09-17)
Re: yacc/lex and precompiler statements (Scott Stanchfield) (1996-09-17)
| List of all articles for this month |

From: Scott Stanchfield <>
Newsgroups: comp.compilers,
Date: 17 Sep 1996 22:12:53 -0400
Organization: McCabe & Associates
References: 96-09-085
Keywords: parse, Pascal

If I remember correctly, VOS doesn't allow you to reuse keywords as
idents, right? (Our Pascal parser recognizes VOS Pascal as one of its

If the above statement is true, I'd suggest taking a simpler approach
for your pretty-printer: forget a full parser, and just do it with a
simple scanner.

First, you need to keep track of whether you are in comments or strings,
then, if you're not in either and get a keyword like BEGIN, increase
indentation, END would decrease it and so forth.

You could then implement a simple stack for the $IF...$ELSE...$ENDIF

Good luck!

Waldo van Riemsdijk wrote:
> 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.
> ...
> 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
> 'precompiler-problem'?

Scott Stanchfield McCabe & Associates -- Columbia, Maryland

Post a followup to this message

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