souffle  2.0.2-371-g6315b36
ReorderFilterBreak.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2018, The Souffle Developers. All rights reserved
4  * Licensed under the Universal Permissive License v 1.0 as shown at:
5  * - https://opensource.org/licenses/UPL
6  * - <souffle root>/licenses/SOUFFLE-UPL.txt
7  */
8 
9 /************************************************************************
10  *
11  * @file ReorderFilterBreak.h
12  *
13  ***********************************************************************/
14 
15 #pragma once
16 
17 #include "ram/Program.h"
18 #include "ram/TranslationUnit.h"
20 #include <string>
21 
22 namespace souffle::ram::transform {
23 
24 /**
25  * @class ReorderBreak
26  * @brief Reorder filter-break nesting to a break-filter nesting
27  *
28  * For example ..
29  *
30  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
31  * QUERY
32  * ...
33  * IF C1
34  * BREAK C2
35  * ...
36  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
37  *
38  * will be rewritten to
39  *
40  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
41  * QUERY
42  * ...
43  * BREAK C2
44  * IF C1
45  * ...
46  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
47  *
48  */
49 class ReorderFilterBreak : public Transformer {
50 public:
51  std::string getName() const override {
52  return "ReorderFilterBreak";
53  }
54 
55  /**
56  * @brief reorder filter-break nesting to break-filter nesting
57  * @param program Program that is transform
58  * @return Flag showing whether the program has been changed by the transformation
59  */
60  bool reorderFilterBreak(Program& program);
61 
62 protected:
63  bool transform(TranslationUnit& translationUnit) override {
64  return reorderFilterBreak(translationUnit.getProgram());
65  }
66 };
67 
68 } // namespace souffle::ram::transform
souffle::ram::transform
Definition: ChoiceConversion.cpp:30
souffle::ram::transform::ReorderFilterBreak::getName
std::string getName() const override
@Brief get name of the transformer
Definition: ReorderFilterBreak.h:55
souffle::ram::Program
RAM program relation declaration and functions.
Definition: Program.h:58
Program.h
souffle::ram::transform::ReorderFilterBreak::transform
bool transform(TranslationUnit &translationUnit) override
@Brief transform the translation unit / used by apply @Param translationUnit that will be transformed...
Definition: ReorderFilterBreak.h:67
souffle::ram::TranslationUnit::getProgram
Program & getProgram() const
Get the RAM Program of the translation unit
Definition: TranslationUnit.h:107
souffle::ram::TranslationUnit
Translating a RAM program.
Definition: TranslationUnit.h:55
TranslationUnit.h
Transformer.h
souffle::ram::transform::ReorderFilterBreak::reorderFilterBreak
bool reorderFilterBreak(Program &program)
reorder filter-break nesting to break-filter nesting
Definition: ReorderFilterBreak.cpp:33