help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help constructing tiny expression grammar


From: Laurence Finston
Subject: Re: Help constructing tiny expression grammar
Date: Tue, 19 Oct 2004 11:34:27 +0200 (MEST)

On Tue, 19 Oct 2004, Randy W. Sims wrote:

> I'm trying to figure out how to write a grammar for a tiny expression
> language that checks for complicated module dependencies for Perl.

Languages have a way of becoming non-tiny.

> The def statements define macros that are to be substituted into the
> main expression.

If your macro expansion can be implemented as simple text
replacement, as in the C preprocessor, I think you might
find that it will be easier to read the macro definitions
into `strings', if you're using C++, or an array of `chars',
if you're using C, perform all of the expansion in an
action, store the resulting string somewhere, and then let
`yylex()' read it in for parsing when you call the macro.
This technique can also be used for macros that take
arguments.  The macro call will have to be parsed and
special substrings in the macro string will have to be
replaced with strings representing the arguments for a given
call to that macro.

This is how I plan to implement macros in GNU 3DLDF, but I
haven't tried it out yet.  However, I do use the technique
of reading input into strings for loops and conditionals, so
I know that that works.

>
> I'm unsure how to define some of these elements. Below is what I have so
> far. (Please stop laughing.

I didn't see anything laughable.

> I've been reading the manual and googling.
> I've also just ordered some books, but would like to get some work done
> while waiting.)
>

I've found that the Bison manual is enough.

Laurence




reply via email to

[Prev in Thread] Current Thread [Next in Thread]