File tree 4 files changed +87
-0
lines changed
4 files changed +87
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ missingIncludeSystem
13
13
unusedStructMember
14
14
unmatchedSuppression
15
15
16
+ // Ignore debug methods
17
+ unusedFunction
18
+
16
19
// libpython uses this a lot, unfortunately
17
20
cstyleCast
18
21
Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ #include < roxas/ast.h>
3
+
4
+ namespace roxas {
5
+
6
+ namespace ast {
7
+
8
+ node::node (std::string const & type)
9
+ : type_(std::move(type))
10
+ , literal_({ literal::UNKNOWN, " unknown" })
11
+ , children_({})
12
+ {
13
+ }
14
+
15
+ void node::print ()
16
+ {
17
+ std::cout << " node type: " << type_;
18
+ }
19
+
20
+ } // namespace ast
21
+
22
+ } // namespace roxas
Original file line number Diff line number Diff line change
1
+ #pragma once
2
+
3
+ #include < optional>
4
+ #include < string>
5
+ #include < tuple>
6
+ #include < vector>
7
+
8
+ namespace roxas {
9
+
10
+ namespace ast {
11
+
12
+ class node ;
13
+ struct definition ;
14
+
15
+ } // namespace ast
16
+
17
+ using AST = std::vector<ast::definition>;
18
+
19
+ AST parse_tree_to_ast (std::string const & parse_tree);
20
+
21
+ namespace ast {
22
+
23
+ enum class literal : int
24
+ {
25
+ NUMBER,
26
+ CONSTANT,
27
+ STRING,
28
+ UNKNOWN
29
+ };
30
+
31
+ using literal_datatype = std::tuple<literal, std::string>;
32
+
33
+ struct definition
34
+ {
35
+ enum class type : int
36
+ {
37
+ FUNCTION,
38
+ VECTOR
39
+ };
40
+
41
+ type type{ type::FUNCTION };
42
+ std::vector<node> children{};
43
+ };
44
+
45
+ class node
46
+ {
47
+ public:
48
+ node (node const &) = delete ;
49
+ node& operator =(node const &) = delete ;
50
+
51
+ explicit node (std::string const & type);
52
+ void print ();
53
+
54
+ private:
55
+ std::string type_;
56
+ std::optional<literal_datatype> literal_;
57
+ std::optional<std::vector<node>> children_;
58
+ };
59
+
60
+ } // namespace ast
61
+ } // namespace roxas
Original file line number Diff line number Diff line change 16
16
17
17
#include < cstdlib>
18
18
#include < iostream>
19
+ #include < roxas/ast.h>
19
20
#include < roxas/parse_tree.h>
20
21
21
22
int main (int argc, const char * argv[])
You can’t perform that action at this time.
0 commit comments