-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsjp.h
More file actions
29 lines (23 loc) · 807 Bytes
/
sjp.h
File metadata and controls
29 lines (23 loc) · 807 Bytes
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
#pragma once
#include <cassert>
#include <fstream>
#include <iostream>
#include <souffle/SouffleInterface.h>
#include <streambuf>
#include <string>
#include <tuple>
namespace sjp {
using ast_node = int;
using token = std::tuple<std::string, std::string, size_t, size_t>;
struct ast {
ast_node root;
std::unordered_map<ast_node, std::string> name;
std::unordered_map<ast_node, size_t> starts_at;
std::unordered_map<ast_node, size_t> ends_at;
std::unordered_map<ast_node, std::vector<std::pair<std::string, ast_node>>> parent_of;
std::unordered_map<ast_node, std::vector<std::pair<std::string, std::vector<ast_node>>>> parent_of_list;
};
std::vector<token> lex(const char* content);
ast parse_file(const char* filename);
ast parse_string(const char* content);
} // namespace sjp