
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? Thanks a lot Phil

On 11/2/14, 9:48 PM, 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?
No, ANTLR is recursive descent. You can use it. ANTLR means, ANother Tool for Language Recognition. Don't be mislead by the LR suffix. Regards, -- Joel de Guzman http://www.ciere.com http://boost-spirit.com http://www.cycfi.com/

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

Hello
Am 03.11.2014 um 15:45 schrieb Larry Evans
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.
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? Thanks Phil

On 11/04/2014 06:01 AM, Philipp Kraus wrote:
Hello
Am 03.11.2014 um 15:45 schrieb Larry Evans
: 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 :(
Thanks
Phil
-regards, Larry

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
: 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:
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/

Hi Joel,
thanks for your nice answer.
Am 04.11.2014 um 16:44 schrieb Joel de Guzman
If you can write an ANTLR to Spirit code generator, I'd be very very interested!
IMHO I’m starting with the project, so my first try is to define the grammar. If it works, I can think about a AntLR to Spirit translation. I have worked with yacc / bison in the native way (write grammar rules in text), so a graphical visualization can be very nice Thanks Phil
participants (3)
-
Joel de Guzman
-
Larry Evans
-
Philipp Kraus