Boost logo

Boost Users :

Subject: Re: [Boost-users] Spirit with UI Tools
From: Larry Evans (cppljevans_at_[hidden])
Date: 2014-11-03 09:45:17


On 11/02/2014 07:48 AM, Philipp Kraus wrote:> Hello,

> I would like to create a small parser with Boost.Spirit. I have run
> the short examples and everything works well, so I would like to
> create my own LL grammar. In my case I need also for documentation
> a EBNF or something else and in the best case I can would like to
> create the EBNF first and transform this into the Spirit LL grammar
> code.

> Did you know any tools to do this? My first idea is to use AntLR to
> create the grammar but imho it creates a LR grammar. Can you
> recommend a tool to define the grammar structure and generate the
> Spirit code?

Why couldn't you use Spirit to describe spirit grammar? IOW,
a grammar has a syntax:

  grammar = +production;
  productions = +(terminal|non_terminal|action);
  non_termainal = non_term_1|non_term_2|...|non_term_Nnon;
  terminal = term_1|term_2|...|term_Nterm;
  action = act_1|act_2|...|act_Nact;

Couldn't this grammar be described using spirit, and that spirit
"source" grammar could be used to *read* your the grammar you actually
want from a file and create the actual "target" grammar you want?
After all, I don't see what Antlr would buy you because, IIUC, you'll
havde to do essentially the same thing, except using Antlr you have to
learn to systems, Antlr as well as spirit.

I've never tried it with spirit; however, I did do it many years ago,
but that involved using virtual functions instead of the more template
expression grammer currently used in spirit. IIRC, Joel initially did
it this way, but changed to template expressions because the resulting
parser of the "target" language was faster.

> Thanks a lot
>
> Phil
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net