Boost logo

Boost :

From: Dan Nuffer (dnuffer_at_[hidden])
Date: 2001-05-27 13:45:57

"John Max Skaller" <skaller_at_[hidden]> wrote:
> The main problem I see (due to ignorance) is how
> to specify the semantic rules. For a grammar, there
> the notation
> $n
> refers to the attributes of the n'th symbol. What do you do with
> Symbol*
> or
> Symbol?

In a parser I've written in yacc, the rules simply built an abstract syntax
tree, and then I used a visitor pattern to process the language.

Symbol? was handled by the ast, if the symbol wasn't present, the pointer
was 0, if it was, the pointer was valid.
I handled Symbol* by using a list in the ast.

The parser is part of OpenWBEM ( and
If you want to examine the code, the relevant files are in the src/mof
subdirectory, or you can see it via the web:

After writing all the ast classes of the mof parser by hand, I decided it
would be nice to have a tool that would do it for me and generate the ast as
well as the yacc file to build it. Right now it will take as input simply a
BNF grammar, but eventiually it will translate ebnf into yacc bnf and
generate the corresponding ast and visitor classes.

I think that Spirit would need to implement a similar approach, by building
an ast, and then allowing processing on the ast. For some grammars, without
having an ast in memory, it becomes difficult to process, if all you have
are $1,$2, etc.

--Dan Nuffer

Boost list run by bdawes at, gregod at, cpdaniel at, john at