Boost logo

Boost :

From: John Max Skaller (skaller_at_[hidden])
Date: 2001-06-10 09:59:30


joel de guzman wrote:
>
> ----- Original Message -----
> From: "John Max Skaller"
>
> > > I am asking this because in principle (I haven't done this yet)
> > > Spirit can be a lexer and a parser.
> >
> > Well, just an idea .. bootstrap it.

> This is interesting. Please elaborate more.
> Pardon my limited comprehension.

        A Spirit grammar is written with a certain syntax:
a particular subset of C++. You use

        * x | y

for thr RHS of a grammar, for example. So you can write
a parser that reads this, and generates yacc, provided
you write the Spirit code in a styalised enough way.

So now, for any grammar which is encoded in the styalised
Spirit syntax, you can

        a) execute it in C++
        b) generate yacc tables

Now, using this styalised Spirit syntax, write a parser
for styalised Spirit syntax.

Compile this with C++. Execute the program on itself,
and you have a yacc version of Spirit which generates
yacc tables. So you have a version which is itself
very fast and which generates very fast parsers.

The use: first use C++ to prototype your grammar,
then, after you are happy, you can compile a production
quality parser using the spirit->yacc translator.
This is also a 'C++' routine, but it is compiled
rather than interpreted (in some sense).

-- 
John (Max) Skaller, mailto:skaller_at_[hidden]
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper http://Vyper.sourceforge.net
download Interscript http://Interscript.sourceforge.net

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk