Replace some initializer_lists with vectors
This commit is contained in:
parent
df3397f02c
commit
b01c672fca
3 changed files with 7 additions and 7 deletions
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <initializer_list>
|
||||
#include "rule.h"
|
||||
|
||||
namespace tree_sitter {
|
||||
|
|
@ -17,7 +16,7 @@ namespace tree_sitter {
|
|||
public:
|
||||
|
||||
transition_map() : contents(contents_type()) {};
|
||||
transition_map(std::initializer_list<pair_type> pairs) : contents(pairs) {};
|
||||
transition_map(std::vector<pair_type> pairs) : contents(pairs) {};
|
||||
|
||||
bool operator==(const transition_map<TKey, TValue> &other) const {
|
||||
if (size() != other.size()) return false;
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
using std::make_shared;
|
||||
using std::string;
|
||||
using std::initializer_list;
|
||||
using std::set;
|
||||
using std::vector;
|
||||
|
||||
namespace tree_sitter {
|
||||
namespace rules {
|
||||
|
|
@ -24,7 +24,7 @@ namespace tree_sitter {
|
|||
return make_shared<CharacterSet>(ranges, sign);
|
||||
}
|
||||
|
||||
rule_ptr choice(const initializer_list<rule_ptr> &rules) {
|
||||
rule_ptr choice(const vector<rule_ptr> &rules) {
|
||||
rule_ptr result;
|
||||
for (auto rule : rules)
|
||||
result = result.get() ? make_shared<Choice>(result, rule) : rule;
|
||||
|
|
@ -39,7 +39,7 @@ namespace tree_sitter {
|
|||
return std::make_shared<Repeat>(content);
|
||||
}
|
||||
|
||||
rule_ptr seq(const initializer_list<rule_ptr> &rules) {
|
||||
rule_ptr seq(const vector<rule_ptr> &rules) {
|
||||
rule_ptr result = blank();
|
||||
for (auto rule : rules)
|
||||
result = (typeid(*result) != typeid(Blank)) ?
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include "character_set.h"
|
||||
#include "repeat.h"
|
||||
#include "visitor.h"
|
||||
#include <vector>
|
||||
|
||||
namespace tree_sitter {
|
||||
namespace rules {
|
||||
|
|
@ -19,10 +20,10 @@ namespace tree_sitter {
|
|||
rule_ptr character(const std::set<CharacterRange> &matches);
|
||||
rule_ptr character(const std::set<CharacterRange> &matches, bool);
|
||||
|
||||
rule_ptr choice(const std::initializer_list<rule_ptr> &rules);
|
||||
rule_ptr choice(const std::vector<rule_ptr> &rules);
|
||||
rule_ptr pattern(const std::string &value);
|
||||
rule_ptr repeat(const rule_ptr content);
|
||||
rule_ptr seq(const std::initializer_list<rule_ptr> &rules);
|
||||
rule_ptr seq(const std::vector<rule_ptr> &rules);
|
||||
rule_ptr str(const std::string &value);
|
||||
rule_ptr sym(const std::string &name);
|
||||
rule_ptr aux_sym(const std::string &name);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue