summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/assert/desugar-visitor.hh
blob: 88d689eb75155d6359fe97deb44bf3f5fb19154e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
 ** \file assert/desugar-visitor.hh
 ** \brief Declaration of assert::DesugarVisitor.
 */

#pragma once

#include <ast/assert-visitor.hh>
#include <desugar/desugar-visitor.hh>

namespace assert {

  class DesugarVisitor
    : public desugar::DesugarVisitor
    , public ast::AssertConstVisitor
  {
  public:
    using super_type = desugar::DesugarVisitor;
    using super_type::operator();

    // Build a DesugarVisitor
    DesugarVisitor(bool desugar_for_p, bool desugar_string_cmp_p);

    // Desugar assertions
    // \param e Node to visit
    void operator()(const ast::AssertExp& e) override;

  private:

    // Retrieve the pretty-printed version of an assertion's condition as a
    // string
    // \param e Node to pretty-print.
    inline std::string get_formatted_assert_cond(const ast::AssertExp& e);

    // Retrieve the pretty-printed version of a Location as a string
    // \param loc Location record to pretty-print
    inline std::string get_formatted_location(const ast::Location& loc);
  };

} // namespace assert

#include <assert/desugar-visitor.hxx>