The Artima Developer Community
Sponsored Link

Java Buzz Forum
A Little C++ To Boost Your Spirit

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Weiqi Gao

Posts: 1808
Nickname: weiqigao
Registered: Jun, 2003

Weiqi Gao is a Java programmer.
A Little C++ To Boost Your Spirit Posted: Mar 26, 2008 10:33 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Weiqi Gao.
Original Post: A Little C++ To Boost Your Spirit
Feed Title: Weiqi Gao's Weblog
Feed URL: http://www.weiqigao.com/blog/rss.xml
Feed Description: Sharing My Experience...
Latest Java Buzz Posts
Latest Java Buzz Posts by Weiqi Gao
Latest Posts From Weiqi Gao's Weblog

Advertisement

Take a look at the following snippet of valid C++ code ...

group = '(' >> expr >> ')';
fact = integer | group;
term = fact >> *( ('*' >> fact) | ('/' >> fact) );
expr = term >> *( ('+' >> term) | ('-' >> term) );

... and tell me C++ is not the perfect language for DSLs! ;=)

Seriously, I copied down the above from Adam Mitz's OCI internal C++ lunch talk about Boost.Spirit yesterday.

Boost.Spirit documentation: Spirit is an object-oriented recursive-descent parser generator framework implemented using template meta-programming techniques. Expression templates allow us to approximate the syntax of Extended Backus-Normal Form (EBNF) completely in C++.

The Spirit framework enables a target grammar to be written exclusively in C++. Inline EBNF grammar specifications can mix freely with other C++ code and, thanks to the generative power of C++ templates, are immediately executable. In retrospect, conventional compiler-compilers or parser-generators have to perform an additional translation step from the source EBNF code to C or C++ code.

As parser generators go, Boost.Spirit is pretty powerful stuff. As an example, Adam redid Mark Volkmann's Math example from the ANTLR 3 talk, ASTs and all.

Geeky as Boost.Spirit may seem, can think of one occasion in past projects where we could have used it instead of coding a recursive descent parser by hand.

Read: A Little C++ To Boost Your Spirit

Topic: Precious Things Previous Topic   Next Topic Topic: Links for 2008-03-18 [del.icio.us]

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use