Related articles |
---|
Look for a LALR grammar for visual basic tsupplisson@suresnes.marben.fr (Thierry Supplisson) (1997-08-16) |
Re: Look for a LALR grammar for visual basic thetick@scruz.net (Scott Stanchfield) (1997-08-19) |
Re: Look for a LALR grammar for visual basic genew@vip.net (1997-08-20) |
Re: Look for a LALR grammar for visual basic jrr@atml.co.uk (1997-08-24) |
Re: Look for a LALR grammar for visual basic thetick@magelang.com (Scott Stanchfield) (1997-09-07) |
Re: Look for a LALR grammar for visual basic genew@vip.net (1997-09-12) |
From: | Scott Stanchfield <thetick@scruz.net> |
Newsgroups: | comp.compilers |
Date: | 19 Aug 1997 22:52:45 -0400 |
Organization: | scruz-net |
References: | 97-08-050 |
Keywords: | Basic, parse |
When I worked at McCabe & Associates I wrote a Visual basic parser using
yacc.
It's definitely not public domain, but if you're so inclined, you might
want to contact my old boss there, arthur@mccabe.comm and see if
they might be interested in helping you.
Unfornately, my NDA with them prevents me from saying much more about
it... I think I can say that it was a fairly nasty beast in some areas:
Think about
IF x = 1 THEN
END
100: END IF
which would complicate a grammar significantly (yes, VB allows a label
on things like "END IF" -- yuck!
A trick I've used for several projects (at home and in various jobs) is
to create a wrapper for yylex that acts like a token buffer. (You need
to rename the lex-generated yylex, and name the buffer yylex, calling
the renamed yylex.) This buffer watches for a few combinations of
tokens and modifies the set of tokens that the parser will see.
Sometimes it will merge several real tokens into one "metatoken;" other
times it will insert dummy tokens in the token stream. Both tricks can
make the grammar much cleaner and simpler.
In Visual Basic, things like "END IF" become a single ENDIF token, "NEXT
X,Y" becomes "NEXT X : NEXT Y" and so on. (In the above example, you
could change "LABEL END IF" to LABELLED_ENDIF so it can't conflict with
the "LABEL END" in the body of the if statement.
-- Scott
Thierry Supplisson wrote:
>
> Hi everybody !
>
> Has someone heard about a yacc grammar for microsoft visual basic?
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.