souffle  2.0.2-371-g6315b36
Pragma.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2017, 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 Pragma.h
12  *
13  * Defines the pragma class
14  *
15  ***********************************************************************/
16 
17 #pragma once
18 
19 #include "ast/Node.h"
20 #include "parser/SrcLocation.h"
21 #include <ostream>
22 #include <string>
23 #include <utility>
24 
25 namespace souffle::ast {
26 
27 /**
28  * @class Pragma
29  * @brief Representation of a global option
30  */
31 class Pragma : public Node {
32 public:
33  Pragma(std::string key, std::string value, SrcLocation loc = {})
34  : Node(std::move(loc)), key(std::move(key)), value(std::move(value)) {}
35 
36  Pragma* clone() const override {
37  return new Pragma(key, value, getSrcLoc());
38  }
39 
40  /* Get kvp */
41  std::pair<std::string, std::string> getkvp() const {
42  return std::pair<std::string, std::string>(key, value);
43  }
44 
45 protected:
46  void print(std::ostream& os) const override {
47  os << ".pragma " << key << " " << value << "\n";
48  }
49 
50  bool equal(const Node& node) const override {
51  const auto& other = static_cast<const Pragma&>(node);
52  return other.key == key && other.value == value;
53  }
54 
55  /** Name of the key */
56  std::string key;
57 
58  /** Value */
59  std::string value;
60 };
61 
62 } // namespace souffle::ast
souffle::ast::Pragma::Pragma
Pragma(std::string key, std::string value, SrcLocation loc={})
Definition: Pragma.h:39
SrcLocation.h
souffle::ast::Pragma::getkvp
std::pair< std::string, std::string > getkvp() const
Definition: Pragma.h:47
souffle::ast::Pragma::print
void print(std::ostream &os) const override
Output to a given output stream.
Definition: Pragma.h:52
souffle::ast::Pragma
Representation of a global option.
Definition: Pragma.h:37
souffle::ast::Pragma::key
std::string key
Name of the key.
Definition: Pragma.h:62
souffle::ast::Pragma::clone
Pragma * clone() const override
Create a clone (i.e.
Definition: Pragma.h:42
Node.h
souffle::ast::Pragma::value
std::string value
Value.
Definition: Pragma.h:65
souffle::ast::Node
Abstract class for syntactic elements in an input program.
Definition: Node.h:40
souffle::ast::Node::Node
Node(SrcLocation loc={})
Definition: Node.h:42
souffle::ast::Pragma::equal
bool equal(const Node &node) const override
Abstract equality check for two AST nodes.
Definition: Pragma.h:56
souffle::ast::Node::getSrcLoc
const SrcLocation & getSrcLoc() const
Return source location of the Node.
Definition: Node.h:46
souffle::ast
Definition: Aggregator.h:35