compare of 2 existing methods to implement grammar recursion

Larry Evans <[email protected]>
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <[email protected]>
The repository:
   https://github.com/boostorg/spirit/tree/develop
has toy.cpp here:
   */workbench/x3/toy/toy.cpp
which connects the rule with it's rule_definition using
the context; however, it's not clear from the code how
to connect multiple rule's withe their rule_definition's.

In contrast:

   */include/boost/spirit/home/x3/nonterminal/rule.hpp

uses the BOOST_SPIRIT_DEFINE macro to do this, as illustrated by:

   */example/x3/calc/calc1.cpp

The gist:

   https://gist.github.com/cppljevans/3634cc4e8ad4da81531608e6aa847de5

shows both methods except, in contrast to toy.cpp, it uses
make_defns to link multiple rule's with their definitions.

Also, the gist uses a macro, USE_PARSE_RULE, to switch between the
2 methods to ease comparison.  It also has *plenty* of debug
prints to help clarify how it works.

It helped me understand the x3 design a bit better and
hopefully the above gist will help others do the same.

HTH.

-regards,
Larry



------------------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.