|yacc/lex and precompiler statements email@example.com (Waldo van Riemsdijk) (1996-09-17)|
|Re: yacc/lex and precompiler statements firstname.lastname@example.org (Scott Stanchfield) (1996-09-17)|
|From:||Scott Stanchfield <email@example.com>|
|Date:||17 Sep 1996 22:12:53 -0400|
|Organization:||McCabe & Associates|
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
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
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
Scott Stanchfield McCabe & Associates -- Columbia, Maryland
Return to the
Search the comp.compilers archives again.