Remove all uses of 'using namespace'
This commit is contained in:
parent
de5deeeb69
commit
a4120f36d4
30 changed files with 95 additions and 60 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "compiler/prepare_grammar/expand_repeats.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "compiler/prepared_grammar.h"
|
||||
#include "compiler/rules/visitor.h"
|
||||
#include "compiler/rules/seq.h"
|
||||
|
|
@ -13,32 +14,32 @@ namespace tree_sitter {
|
|||
using std::to_string;
|
||||
using std::map;
|
||||
using std::make_shared;
|
||||
using namespace rules;
|
||||
using rules::rule_ptr;
|
||||
|
||||
namespace prepare_grammar {
|
||||
class ExpandRepeats : public RuleFn<rule_ptr> {
|
||||
class ExpandRepeats : public rules::RuleFn<rule_ptr> {
|
||||
rule_ptr make_repeat_helper(string name, const rule_ptr &rule) {
|
||||
return Choice::Build({
|
||||
Seq::Build({ rule, make_shared<Symbol>(name, SymbolTypeAuxiliary) }),
|
||||
make_shared<Blank>() });
|
||||
return rules::Choice::Build({
|
||||
rules::Seq::Build({ rule, make_shared<rules::Symbol>(name, rules::SymbolTypeAuxiliary) }),
|
||||
make_shared<rules::Blank>() });
|
||||
}
|
||||
|
||||
void visit(const Repeat *rule) {
|
||||
void visit(const rules::Repeat *rule) {
|
||||
rule_ptr inner_rule = apply(rule->content);
|
||||
string helper_rule_name = string("repeat_helper") + to_string(aux_rules.size() + 1);
|
||||
aux_rules.insert({ helper_rule_name, make_repeat_helper(helper_rule_name, inner_rule) });
|
||||
value = make_shared<Symbol>(helper_rule_name, SymbolTypeAuxiliary);
|
||||
value = make_shared<rules::Symbol>(helper_rule_name, rules::SymbolTypeAuxiliary);
|
||||
}
|
||||
|
||||
void visit(const Seq *rule) {
|
||||
value = Seq::Build({ apply(rule->left), apply(rule->right) });
|
||||
void visit(const rules::Seq *rule) {
|
||||
value = rules::Seq::Build({ apply(rule->left), apply(rule->right) });
|
||||
}
|
||||
|
||||
void visit(const Choice *rule) {
|
||||
value = Choice::Build({ apply(rule->left), apply(rule->right) });
|
||||
void visit(const rules::Choice *rule) {
|
||||
value = rules::Choice::Build({ apply(rule->left), apply(rule->right) });
|
||||
}
|
||||
|
||||
void default_visit(const Rule *rule) {
|
||||
void default_visit(const rules::Rule *rule) {
|
||||
value = rule->copy();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "compiler/prepare_grammar/extract_tokens.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "tree_sitter/compiler.h"
|
||||
#include "compiler/prepared_grammar.h"
|
||||
#include "compiler/rules/visitor.h"
|
||||
|
|
@ -17,24 +18,24 @@ namespace tree_sitter {
|
|||
using std::to_string;
|
||||
using std::map;
|
||||
using std::make_shared;
|
||||
using namespace rules;
|
||||
using rules::rule_ptr;
|
||||
|
||||
namespace prepare_grammar {
|
||||
class IsToken : public RuleFn<bool> {
|
||||
void default_visit(const Rule *rule) {
|
||||
class IsToken : public rules::RuleFn<bool> {
|
||||
void default_visit(const rules::Rule *rule) {
|
||||
value = false;
|
||||
}
|
||||
|
||||
void visit(const String *rule) {
|
||||
void visit(const rules::String *rule) {
|
||||
value = true;
|
||||
}
|
||||
|
||||
void visit(const Pattern *rule) {
|
||||
void visit(const rules::Pattern *rule) {
|
||||
value = true;
|
||||
}
|
||||
};
|
||||
|
||||
class TokenExtractor : public RuleFn<rule_ptr> {
|
||||
class TokenExtractor : public rules::RuleFn<rule_ptr> {
|
||||
string add_token(const rule_ptr &rule) {
|
||||
for (auto pair : tokens)
|
||||
if (*pair.second == *rule)
|
||||
|
|
@ -44,25 +45,25 @@ namespace tree_sitter {
|
|||
return name;
|
||||
}
|
||||
|
||||
void default_visit(const Rule *rule) {
|
||||
void default_visit(const rules::Rule *rule) {
|
||||
auto result = rule->copy();
|
||||
if (IsToken().apply(result)) {
|
||||
value = make_shared<Symbol>(add_token(result), SymbolTypeAuxiliary);
|
||||
value = make_shared<rules::Symbol>(add_token(result), rules::SymbolTypeAuxiliary);
|
||||
} else {
|
||||
value = result;
|
||||
}
|
||||
}
|
||||
|
||||
void visit(const Choice *rule) {
|
||||
value = Choice::Build({ apply(rule->left), apply(rule->right) });
|
||||
void visit(const rules::Choice *rule) {
|
||||
value = rules::Choice::Build({ apply(rule->left), apply(rule->right) });
|
||||
}
|
||||
|
||||
void visit(const Seq *rule) {
|
||||
value = Seq::Build({ apply(rule->left), apply(rule->right) });
|
||||
void visit(const rules::Seq *rule) {
|
||||
value = rules::Seq::Build({ apply(rule->left), apply(rule->right) });
|
||||
}
|
||||
|
||||
void visit(const Repeat *rule) {
|
||||
value = make_shared<Repeat>(apply(rule->content));
|
||||
void visit(const rules::Repeat *rule) {
|
||||
value = make_shared<rules::Repeat>(apply(rule->content));
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue