<commit_before>Visitor
=======

Rather than exposing the data structure
representing the abstract syntax tree directly,
FormAST exposes the structure by means of
`visitation <http://en.wikipedia.org/wiki/Visitor_pattern>`_.
In practice, visitation provides every means for evaluating
the abstract syntax tree,
or for compiling it into another tree structure
for whatever sofisticated purpose.

Simply derive a subclass from :cpp:class:`formast::Visitor`
and overload the desired methods.

.. cpp:class:: formast::Visitor

   Visitor for the abstract syntax tree.

   .. cpp:function:: void module(Module const & module)

      Visits a :cpp:class:`formast::Module`,
      dispatching each of its children
      to the appropriate ``module_...`` method.

   .. cpp:function:: void module_class(Class const & class_)

   .. cpp:function:: void stats(Stats const & stats)

      Visits a :cpp:class:`formast::Stats`,
      dispatching each of its children
      to the appropriate ``stats_...`` method.

   .. cpp:function:: void stats_field(Field const & field)
   .. cpp:function:: void stats_if(If const & if_)

   .. cpp:function:: void expr(formast::Expr const & e)

      Visits an :cpp:class:`formast::Expr`,
      dispatching
      to the appropriate ``expr_...`` method.

   .. cpp:function:: void expr_uint(boost::uint64_t const & n)
   .. cpp:function:: void expr_id(std::string const & i)
   .. cpp:function:: void expr_pos(formast::Expr const & right)
   .. cpp:function:: void expr_neg(formast::Expr const & right)
   .. cpp:function:: void expr_add(formast::Expr const & left, formast::Expr const & right)
   .. cpp:function:: void expr_sub(formast::Expr const & left, formast::Expr const & right)
   .. cpp:function:: void expr_mul(formast::Expr const & left, formast::Expr const & right)
   .. cpp:function:: void expr_div(formast::Expr const & left, formast::Expr const & right)
   .. cpp:function:: void expr_mod(Expr const & left, Expr const & right)
   .. cpp:function:: void expr_pow(Expr const & left, Expr const & right)
   .. cpp:function:: void expr_logical_and(Expr const & left, Expr const & right)
   .. cpp:function:: void expr_logical_or(Expr const & left, Expr const & right)
   .. cpp:function:: void expr_logical_not(Expr const & right)<commit_msg>Use namespace consistently in visitor documentation.<commit_after>Visitor
=======

Rather than exposing the data structure
representing the abstract syntax tree directly,
FormAST exposes the structure by means of
`visitation <http://en.wikipedia.org/wiki/Visitor_pattern>`_.
In practice, visitation provides every means for evaluating
the abstract syntax tree,
or for compiling it into another tree structure
for whatever sofisticated purpose.

Simply derive a subclass from :cpp:class:`formast::Visitor`
and overload the desired methods.

.. cpp:class:: formast::Visitor

   Visitor for the abstract syntax tree.

   .. cpp:function:: void module(Module const & module)

      Visits a :cpp:class:`formast::Module`,
      dispatching each of its children
      to the appropriate ``module_...`` method.

   .. cpp:function:: void module_class(Class const & class_)

   .. cpp:function:: void stats(Stats const & stats)

      Visits a :cpp:class:`formast::Stats`,
      dispatching each of its children
      to the appropriate ``stats_...`` method.

   .. cpp:function:: void stats_field(Field const & field)
   .. cpp:function:: void stats_if(If const & if_)

   .. cpp:function:: void expr(Expr const & e)

      Visits an :cpp:class:`formast::Expr`,
      dispatching
      to the appropriate ``expr_...`` method.

   .. cpp:function:: void expr_uint(boost::uint64_t const & n)
   .. cpp:function:: void expr_id(std::string const & i)
   .. cpp:function:: void expr_pos(Expr const & right)
   .. cpp:function:: void expr_neg(Expr const & right)
   .. cpp:function:: void expr_add(Expr const & left, Expr const & right)
   .. cpp:function:: void expr_sub(Expr const & left, Expr const & right)
   .. cpp:function:: void expr_mul(Expr const & left, Expr const & right)
   .. cpp:function:: void expr_div(Expr const & left, Expr const & right)
   .. cpp:function:: void expr_mod(Expr const & left, Expr const & right)
   .. cpp:function:: void expr_pow(Expr const & left, Expr const & right)
   .. cpp:function:: void expr_logical_and(Expr const & left, Expr const & right)
   .. cpp:function:: void expr_logical_or(Expr const & left, Expr const & right)
   .. cpp:function:: void expr_logical_not(Expr const & right)
{'fraction_non_alphanumeric': 0.1216096042685638, 'fraction_numerical': 0.0008892841262783459, 'mean_word_length': 3.906215921483097, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1957441', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1309, 'n_words': 442}