| File src/ts/TSTransformer.cpp changed (mode: 100644) (index 6ace846..cedce55) |
| ... |
... |
TSTransformer::TSTransformer(const std::string &contents, |
| 35 |
35 |
TreeBuilder &tb, |
TreeBuilder &tb, |
| 36 |
36 |
const std::unordered_map<std::string, SType> &stypes, |
const std::unordered_map<std::string, SType> &stypes, |
| 37 |
37 |
const std::unordered_map<std::string, Type> &types, |
const std::unordered_map<std::string, Type> &types, |
|
38 |
|
const std::unordered_set<std::string> &badNodes, |
| 38 |
39 |
int tabWidth, |
int tabWidth, |
| 39 |
40 |
bool debug) |
bool debug) |
| 40 |
41 |
: contents(contents), tsLanguage(tsLanguage), tb(tb), stypes(stypes), |
: contents(contents), tsLanguage(tsLanguage), tb(tb), stypes(stypes), |
| 41 |
|
types(types), tabWidth(tabWidth), debug(debug) |
|
|
42 |
|
types(types), badNodes(badNodes), tabWidth(tabWidth), debug(debug) |
| 42 |
43 |
{ } |
{ } |
| 43 |
44 |
|
|
| 44 |
45 |
void |
void |
| |
| ... |
... |
TSTransformer::visit(const TSNode &node) |
| 112 |
113 |
void |
void |
| 113 |
114 |
TSTransformer::visitLeaf(SType stype, PNode *pnode, const TSNode &leaf) |
TSTransformer::visitLeaf(SType stype, PNode *pnode, const TSNode &leaf) |
| 114 |
115 |
{ |
{ |
|
116 |
|
if (badNodes.find(ts_node_type(leaf)) != badNodes.end()) { |
|
117 |
|
return; |
|
118 |
|
} |
|
119 |
|
|
| 115 |
120 |
uint32_t from = ts_node_start_byte(leaf); |
uint32_t from = ts_node_start_byte(leaf); |
| 116 |
121 |
uint32_t to = ts_node_end_byte(leaf); |
uint32_t to = ts_node_end_byte(leaf); |
| 117 |
122 |
|
|
| File src/ts/TSTransformer.hpp changed (mode: 100644) (index 4e843ad..c78985c) |
| ... |
... |
public: |
| 40 |
40 |
TreeBuilder &tb, |
TreeBuilder &tb, |
| 41 |
41 |
const std::unordered_map<std::string, SType> &stypes, |
const std::unordered_map<std::string, SType> &stypes, |
| 42 |
42 |
const std::unordered_map<std::string, Type> &types, |
const std::unordered_map<std::string, Type> &types, |
|
43 |
|
const std::unordered_set<std::string> &badNodes, |
| 43 |
44 |
int tabWidth, |
int tabWidth, |
| 44 |
45 |
bool debug); |
bool debug); |
| 45 |
46 |
|
|
| |
| ... |
... |
private: |
| 61 |
62 |
TreeBuilder &tb; // Result builder. |
TreeBuilder &tb; // Result builder. |
| 62 |
63 |
const std::unordered_map<std::string, SType> &stypes; // Node type -> SType. |
const std::unordered_map<std::string, SType> &stypes; // Node type -> SType. |
| 63 |
64 |
const std::unordered_map<std::string, Type> &types; // Node type -> Type. |
const std::unordered_map<std::string, Type> &types; // Node type -> Type. |
|
65 |
|
const std::unordered_set<std::string> &badNodes; // Nodes to ignore. |
| 64 |
66 |
std::unordered_set<std::string> badSTypes; // Missing stypes. |
std::unordered_set<std::string> badSTypes; // Missing stypes. |
| 65 |
67 |
std::unordered_set<std::string> badTypes; // Missing types. |
std::unordered_set<std::string> badTypes; // Missing types. |
| 66 |
68 |
int line; // Current line. |
int line; // Current line. |
| File src/ts/bash/TSBashLanguage.cpp changed (mode: 100644) (index 98ff740..e63dea4) |
| ... |
... |
TsBashLanguage::parse(const std::string &contents, |
| 52 |
52 |
cpp17::pmr::monolithic &mr) const |
cpp17::pmr::monolithic &mr) const |
| 53 |
53 |
{ |
{ |
| 54 |
54 |
TreeBuilder tb(mr); |
TreeBuilder tb(mr); |
| 55 |
|
TSTransformer t(contents, tsLanguage, tb, stypes, types, tabWidth, debug); |
|
|
55 |
|
TSTransformer t(contents, tsLanguage, tb, stypes, types, badNodes, tabWidth, |
|
56 |
|
debug); |
| 56 |
57 |
t.transform(); |
t.transform(); |
| 57 |
58 |
|
|
| 58 |
59 |
return tb; |
return tb; |
| File src/ts/bash/TSBashLanguage.hpp changed (mode: 100644) (index 4d635d8..892adee) |
| 18 |
18 |
#define ZOGRASCOPE__TS__BASH__TSBASHLANGUAGE_HPP__ |
#define ZOGRASCOPE__TS__BASH__TSBASHLANGUAGE_HPP__ |
| 19 |
19 |
|
|
| 20 |
20 |
#include <unordered_map> |
#include <unordered_map> |
|
21 |
|
#include <unordered_set> |
| 21 |
22 |
|
|
| 22 |
23 |
#include "Language.hpp" |
#include "Language.hpp" |
| 23 |
24 |
|
|
| |
| ... |
... |
private: |
| 89 |
90 |
const TSLanguage &tsLanguage; // Language description. |
const TSLanguage &tsLanguage; // Language description. |
| 90 |
91 |
std::unordered_map<std::string, SType> stypes; // Maps nodes to STypes. |
std::unordered_map<std::string, SType> stypes; // Maps nodes to STypes. |
| 91 |
92 |
std::unordered_map<std::string, Type> types; // Maps nodes to Types. |
std::unordered_map<std::string, Type> types; // Maps nodes to Types. |
|
93 |
|
std::unordered_set<std::string> badNodes; // Lists nodes to ignore. |
| 92 |
94 |
}; |
}; |
| 93 |
95 |
|
|
| 94 |
96 |
#endif // ZOGRASCOPE__TS__BASH__TSBASHLANGUAGE_HPP__ |
#endif // ZOGRASCOPE__TS__BASH__TSBASHLANGUAGE_HPP__ |
| File src/ts/lua/TSLuaLanguage.cpp changed (mode: 100644) (index f6f3183..121ee6f) |
| ... |
... |
TsLuaLanguage::parse(const std::string &contents, |
| 181 |
181 |
cpp17::pmr::monolithic &mr) const |
cpp17::pmr::monolithic &mr) const |
| 182 |
182 |
{ |
{ |
| 183 |
183 |
TreeBuilder tb(mr); |
TreeBuilder tb(mr); |
| 184 |
|
TSTransformer t(contents, tsLanguage, tb, stypes, types, tabWidth, debug); |
|
|
184 |
|
TSTransformer t(contents, tsLanguage, tb, stypes, types, badNodes, tabWidth, |
|
185 |
|
debug); |
| 185 |
186 |
t.transform(); |
t.transform(); |
| 186 |
187 |
|
|
| 187 |
188 |
return tb; |
return tb; |
| File src/ts/lua/TSLuaLanguage.hpp changed (mode: 100644) (index a7f2716..849268f) |
| 18 |
18 |
#define ZOGRASCOPE__TS__LUA__TSLUALANGUAGE_HPP__ |
#define ZOGRASCOPE__TS__LUA__TSLUALANGUAGE_HPP__ |
| 19 |
19 |
|
|
| 20 |
20 |
#include <unordered_map> |
#include <unordered_map> |
|
21 |
|
#include <unordered_set> |
| 21 |
22 |
|
|
| 22 |
23 |
#include "Language.hpp" |
#include "Language.hpp" |
| 23 |
24 |
|
|
| |
| ... |
... |
private: |
| 89 |
90 |
const TSLanguage &tsLanguage; // Language description. |
const TSLanguage &tsLanguage; // Language description. |
| 90 |
91 |
std::unordered_map<std::string, SType> stypes; // Maps nodes to STypes. |
std::unordered_map<std::string, SType> stypes; // Maps nodes to STypes. |
| 91 |
92 |
std::unordered_map<std::string, Type> types; // Maps nodes to Types. |
std::unordered_map<std::string, Type> types; // Maps nodes to Types. |
|
93 |
|
std::unordered_set<std::string> badNodes; // Lists nodes to ignore. |
| 92 |
94 |
}; |
}; |
| 93 |
95 |
|
|
| 94 |
96 |
#endif // ZOGRASCOPE__TS__LUA__TSLUALANGUAGE_HPP__ |
#endif // ZOGRASCOPE__TS__LUA__TSLUALANGUAGE_HPP__ |