From 4b817dc07cc77762b3e0f98c119ff6797bd251df Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 12 Oct 2015 17:29:02 -0700 Subject: [PATCH] Fix linter errors --- spec/compiler/build_tables/item_set_closure_spec.cc | 2 +- src/compiler/build_tables/lex_item.cc | 2 +- src/compiler/build_tables/lex_item.h | 2 +- src/compiler/build_tables/lex_item_transitions.cc | 5 +++-- src/compiler/build_tables/lex_item_transitions.h | 6 +++--- src/compiler/build_tables/lookahead_set.h | 2 +- src/compiler/build_tables/parse_item.h | 2 +- src/compiler/parse_table.cc | 2 +- src/compiler/precedence_range.h | 2 +- src/compiler/prepare_grammar/flatten_grammar.cc | 5 +++-- src/compiler/prepare_grammar/initial_syntax_grammar.h | 6 +++--- src/compiler/rule.h | 4 ++-- src/compiler/rules/character_range.cc | 5 +---- src/compiler/syntax_grammar.h | 6 +++--- src/compiler/variable.h | 1 + 15 files changed, 26 insertions(+), 26 deletions(-) diff --git a/spec/compiler/build_tables/item_set_closure_spec.cc b/spec/compiler/build_tables/item_set_closure_spec.cc index dace0a23..8a0f8334 100644 --- a/spec/compiler/build_tables/item_set_closure_spec.cc +++ b/spec/compiler/build_tables/item_set_closure_spec.cc @@ -38,7 +38,7 @@ describe("item_set_closure", []() { ParseItemSet item_set = item_set_closure(ParseItemSet({ { ParseItem(Symbol(0), 0, 0, 100), - set({ Symbol(10, true) }), + LookaheadSet({ Symbol(10, true) }), } }), grammar); diff --git a/src/compiler/build_tables/lex_item.cc b/src/compiler/build_tables/lex_item.cc index dae87fd4..ddb41996 100644 --- a/src/compiler/build_tables/lex_item.cc +++ b/src/compiler/build_tables/lex_item.cc @@ -1,8 +1,8 @@ #include "compiler/build_tables/lex_item.h" +#include #include "compiler/build_tables/get_metadata.h" #include "compiler/build_tables/lex_item_transitions.h" #include "compiler/rules/symbol.h" -#include namespace tree_sitter { namespace build_tables { diff --git a/src/compiler/build_tables/lex_item.h b/src/compiler/build_tables/lex_item.h index 4e0630db..0ff4d0e7 100644 --- a/src/compiler/build_tables/lex_item.h +++ b/src/compiler/build_tables/lex_item.h @@ -27,7 +27,7 @@ class LexItem { class LexItemSet { public: LexItemSet(); - LexItemSet(const std::unordered_set &); + explicit LexItemSet(const std::unordered_set &); bool operator==(const LexItemSet &) const; std::map transitions() const; diff --git a/src/compiler/build_tables/lex_item_transitions.cc b/src/compiler/build_tables/lex_item_transitions.cc index a813e04c..099205c7 100644 --- a/src/compiler/build_tables/lex_item_transitions.cc +++ b/src/compiler/build_tables/lex_item_transitions.cc @@ -2,6 +2,7 @@ #include #include #include +#include #include "compiler/build_tables/rule_can_be_blank.h" #include "compiler/rules/blank.h" #include "compiler/rules/choice.h" @@ -28,10 +29,10 @@ class LexItemTransitions : public rules::RuleFn { const rules::Symbol &item_lhs; LexItemSet transform_item_set(const LexItemSet &item_set, - function transform) { + function callback) { LexItemSet new_set; for (const LexItem &item : item_set.entries) - new_set.entries.insert(LexItem(item.lhs, transform(item.rule))); + new_set.entries.insert(LexItem(item.lhs, callback(item.rule))); return new_set; } diff --git a/src/compiler/build_tables/lex_item_transitions.h b/src/compiler/build_tables/lex_item_transitions.h index b6f24b0a..342df991 100644 --- a/src/compiler/build_tables/lex_item_transitions.h +++ b/src/compiler/build_tables/lex_item_transitions.h @@ -1,5 +1,5 @@ -#ifndef COMPILER_BUILD_TABLES_RULE_TRANSITIONS_H_ -#define COMPILER_BUILD_TABLES_RULE_TRANSITIONS_H_ +#ifndef COMPILER_BUILD_TABLES_LEX_ITEM_TRANSITIONS_H_ +#define COMPILER_BUILD_TABLES_LEX_ITEM_TRANSITIONS_H_ #include #include @@ -16,4 +16,4 @@ void lex_item_transitions(std::map *transitions } // namespace build_tables } // namespace tree_sitter -#endif // COMPILER_BUILD_TABLES_RULE_TRANSITIONS_H_ +#endif // COMPILER_BUILD_TABLES_LEX_ITEM_TRANSITIONS_H_ diff --git a/src/compiler/build_tables/lookahead_set.h b/src/compiler/build_tables/lookahead_set.h index ff2f25fc..c729d33f 100644 --- a/src/compiler/build_tables/lookahead_set.h +++ b/src/compiler/build_tables/lookahead_set.h @@ -11,7 +11,7 @@ namespace build_tables { class LookaheadSet { public: LookaheadSet(); - LookaheadSet(const std::set &); + explicit LookaheadSet(const std::set &); bool empty() const; bool operator==(const LookaheadSet &) const; diff --git a/src/compiler/build_tables/parse_item.h b/src/compiler/build_tables/parse_item.h index 4fe3fddf..3b7eb140 100644 --- a/src/compiler/build_tables/parse_item.h +++ b/src/compiler/build_tables/parse_item.h @@ -26,7 +26,7 @@ class ParseItem { class ParseItemSet { public: ParseItemSet(); - ParseItemSet(const std::map &); + explicit ParseItemSet(const std::map &); std::map transitions(const SyntaxGrammar &) const; bool operator==(const ParseItemSet &) const; diff --git a/src/compiler/parse_table.cc b/src/compiler/parse_table.cc index 730472b4..50788d8e 100644 --- a/src/compiler/parse_table.cc +++ b/src/compiler/parse_table.cc @@ -1,6 +1,6 @@ #include "compiler/parse_table.h" -#include "compiler/precedence_range.h" #include +#include "compiler/precedence_range.h" namespace tree_sitter { diff --git a/src/compiler/precedence_range.h b/src/compiler/precedence_range.h index 690fc8a5..5e7903c2 100644 --- a/src/compiler/precedence_range.h +++ b/src/compiler/precedence_range.h @@ -7,7 +7,7 @@ struct PrecedenceRange { PrecedenceRange(); PrecedenceRange(int min, int max); - void add(int); + void add(int value); bool operator==(const PrecedenceRange &other) const; bool operator<(const PrecedenceRange &other) const; diff --git a/src/compiler/prepare_grammar/flatten_grammar.cc b/src/compiler/prepare_grammar/flatten_grammar.cc index a58ea204..4b6a7f50 100644 --- a/src/compiler/prepare_grammar/flatten_grammar.cc +++ b/src/compiler/prepare_grammar/flatten_grammar.cc @@ -1,4 +1,7 @@ #include "compiler/prepare_grammar/flatten_grammar.h" +#include +#include +#include #include "compiler/prepare_grammar/extract_choices.h" #include "compiler/prepare_grammar/initial_syntax_grammar.h" #include "compiler/rules/visitor.h" @@ -6,8 +9,6 @@ #include "compiler/rules/symbol.h" #include "compiler/rules/metadata.h" #include "compiler/rules/built_in_symbols.h" -#include -#include namespace tree_sitter { namespace prepare_grammar { diff --git a/src/compiler/prepare_grammar/initial_syntax_grammar.h b/src/compiler/prepare_grammar/initial_syntax_grammar.h index fea28935..ccbc19ff 100644 --- a/src/compiler/prepare_grammar/initial_syntax_grammar.h +++ b/src/compiler/prepare_grammar/initial_syntax_grammar.h @@ -1,5 +1,5 @@ -#ifndef COMPILER_INITIAL_SYNTAX_GRAMMAR_H_ -#define COMPILER_INITIAL_SYNTAX_GRAMMAR_H_ +#ifndef COMPILER_PREPARE_GRAMMAR_INITIAL_SYNTAX_GRAMMAR_H_ +#define COMPILER_PREPARE_GRAMMAR_INITIAL_SYNTAX_GRAMMAR_H_ #include #include @@ -21,4 +21,4 @@ struct InitialSyntaxGrammar { } // namespace prepare_grammar } // namespace tree_sitter -#endif // COMPILER_INITIAL_SYNTAX_GRAMMAR_H_ +#endif // COMPILER_PREPARE_GRAMMAR_INITIAL_SYNTAX_GRAMMAR_H_ diff --git a/src/compiler/rule.h b/src/compiler/rule.h index 2dbe4046..b77e54a4 100644 --- a/src/compiler/rule.h +++ b/src/compiler/rule.h @@ -23,8 +23,8 @@ class Rule { virtual void accept(rules::Visitor *visitor) const = 0; virtual ~Rule(); - template - const T * as() const { + template + const T *as() const { return dynamic_cast(this); } }; diff --git a/src/compiler/rules/character_range.cc b/src/compiler/rules/character_range.cc index e1d92087..1f6292e3 100644 --- a/src/compiler/rules/character_range.cc +++ b/src/compiler/rules/character_range.cc @@ -1,14 +1,11 @@ #include "compiler/rules/character_range.h" -#include #include #include "compiler/util/string_helpers.h" namespace tree_sitter { namespace rules { -using std::ostream; using std::string; -using std::to_string; CharacterRange::CharacterRange(uint32_t value) : min(value), max(value) {} CharacterRange::CharacterRange(uint32_t min, uint32_t max) @@ -32,7 +29,7 @@ string CharacterRange::to_string() const { if (min == max) return util::escape_char(min); else - return string() + util::escape_char(min) + "-" + util::escape_char(max); + return util::escape_char(min) + "-" + util::escape_char(max); } } // namespace rules diff --git a/src/compiler/syntax_grammar.h b/src/compiler/syntax_grammar.h index 936e9638..7b18eec9 100644 --- a/src/compiler/syntax_grammar.h +++ b/src/compiler/syntax_grammar.h @@ -1,5 +1,5 @@ -#ifndef COMPILER_PREPARED_GRAMMAR_H_ -#define COMPILER_PREPARED_GRAMMAR_H_ +#ifndef COMPILER_SYNTAX_GRAMMAR_H_ +#define COMPILER_SYNTAX_GRAMMAR_H_ #include #include @@ -44,4 +44,4 @@ struct SyntaxGrammar { } // namespace tree_sitter -#endif // COMPILER_PREPARED_GRAMMAR_H_ +#endif // COMPILER_SYNTAX_GRAMMAR_H_ diff --git a/src/compiler/variable.h b/src/compiler/variable.h index 043c6499..ebdca774 100644 --- a/src/compiler/variable.h +++ b/src/compiler/variable.h @@ -1,6 +1,7 @@ #ifndef COMPILER_VARIABLE_H_ #define COMPILER_VARIABLE_H_ +#include #include "tree_sitter/compiler.h" #include "compiler/rules/symbol.h"