Boost logo

Boost Users :

Subject: Re: [Boost-users] Spirit with UI Tools
From: Joel de Guzman (djowel_at_[hidden])
Date: 2014-11-04 10:44:54


On 11/4/14, 9:34 PM, Larry Evans wrote:
> On 11/04/2014 06:01 AM, Philipp Kraus wrote:
>> Hello
>>
>> Am 03.11.2014 um 15:45 schrieb Larry Evans <cppljevans_at_[hidden]>:
>>
>>> 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;
>>
>> I know this, but I would like to shown the „plain text grammar“ in a structure like (E)BNF
>> for documentation.
>>
> That's why I thought parsing the grammar from a "plain text file" was
> what you needed. I confess I didn't understand the UI part of your
> subject line. Googling I found:
>
> http://www.antlr3.org/works/
>
> Is that more like what you want? In particular:
>
> http://www.antlr3.org/works/screenshots/editor.jpg
>>
>>> 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?
>>
>> The grammar shouldn’t read from a file at runtime, it should be build-in
>>
>>> 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.
>>
>> AntLR is a nice tool to create a visual representation of the grammar and
>> it can be also helpful during the developing of the grammar. In my case
>> I would like to create a logical language and don’t want to create a
>> „hard encoding spirit code“, so I would like to design the grammar in a
>> UI tool and create from the visual representation the Spirit code and
>> paste it in my class file which create parser & lexer.
>>
>> UI Grammer Modelling -> Spirit Code Generator -> Spirit Code -> Lexer / Parser
>>
>> Hope this is a bit clearer. Did you know a UI modeling tool or anything helpful for this
>> developing process?
>>
> The one mentioned above, http://www.antlr3.org/works/, looks like a UI
> modeling tool, but I've never used it and don't know if it can be used
> to generate a qi grammar. I kinda doubt it since I guess it's used
> to create a java implementation of the parser, not a c++, qi based one
> :(

There are advantages to prototyping using something like ANTLR. One big
advantage is that you get better error messages, instead of a ton of
ugly C++ error messages. When you've done prototyping the grammar, it
can be translated (not automatically though) to Spirit. Both ANTLR
and Spirit are recursive descent anyway. For example, ANTLR detects
left recursion and gives you a nice warning.

I haven't used www.antlr3.org/works. I once used the predecessor of
the ANTLR a long time ago. It was in C++ and called PCCTS. If you can
write an ANTLR to Spirit code generator, I'd be very very interested!

Regards,

-- 
Joel de Guzman
http://www.ciere.com
http://boost-spirit.com
http://www.cycfi.com/

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