/
Pragma.h
62 lines (50 loc) · 1.57 KB
/
Pragma.h
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Souffle - A Datalog Compiler
* Copyright (c) 2017, The Souffle Developers. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at:
* - https://opensource.org/licenses/UPL
* - <souffle root>/licenses/SOUFFLE-UPL.txt
*/
/************************************************************************
*
* @file Pragma.h
*
* Define the class AstPragma to update global options based on parameter.
*
***********************************************************************/
#pragma once
#include "SrcLocation.h"
#include "ast/Node.h"
#include <ostream>
#include <string>
#include <utility>
namespace souffle {
/**
* @class AstPragma
* @brief Representation of a global option
*/
class AstPragma : public AstNode {
public:
AstPragma(std::string key, std::string value, SrcLocation loc = {})
: AstNode(std::move(loc)), key(std::move(key)), value(std::move(value)) {}
AstPragma* clone() const override {
return new AstPragma(key, value, getSrcLoc());
}
/* Get kvp */
std::pair<std::string, std::string> getkvp() const {
return std::pair<std::string, std::string>(key, value);
}
protected:
void print(std::ostream& os) const override {
os << ".pragma " << key << " " << value << "\n";
}
bool equal(const AstNode& node) const override {
const auto& other = static_cast<const AstPragma&>(node);
return other.key == key && other.value == value;
}
/** Name of the key */
std::string key;
/** Value */
std::string value;
};
} // end of namespace souffle