diff --git a/include/tree_sitter/compiler.h b/include/tree_sitter/compiler.h index 5a6eebf2..a6941088 100644 --- a/include/tree_sitter/compiler.h +++ b/include/tree_sitter/compiler.h @@ -1,18 +1,19 @@ #ifndef TREE_SITTER_COMPILER_H_ #define TREE_SITTER_COMPILER_H_ -#include +#include #include #include -#include +#include +#include namespace tree_sitter { + namespace rules { + class Rule; typedef std::shared_ptr rule_ptr; -std::ostream &operator<<(std::ostream &stream, const rule_ptr &rule); - rule_ptr blank(); rule_ptr choice(const std::vector &rules); rule_ptr repeat(const rule_ptr &content); @@ -25,10 +26,12 @@ rule_ptr keypattern(const std::string &value); rule_ptr err(const rule_ptr &rule); rule_ptr prec(int precedence, rule_ptr rule); rule_ptr token(rule_ptr rule); -} + +std::ostream &operator<<(std::ostream &stream, const rules::rule_ptr &rule); + +} // namespace rules class Grammar { - protected: const std::vector > rules_; std::set ubiquitous_tokens_; std::set separators_; @@ -38,7 +41,6 @@ class Grammar { bool operator==(const Grammar &other) const; std::string start_rule_name() const; const rules::rule_ptr rule(const std::string &name) const; - const std::vector > &rules() const; const std::set &ubiquitous_tokens() const; Grammar &ubiquitous_tokens(const std::set &ubiquitous_tokens); @@ -47,7 +49,7 @@ class Grammar { }; struct Conflict { - Conflict(std::string description); + explicit Conflict(std::string description); std::string description; bool operator==(const Conflict &other) const; bool operator<(const Conflict &other) const; @@ -66,12 +68,13 @@ class GrammarError { std::string message; }; +std::tuple, const GrammarError *> compile( + const Grammar &grammar, std::string name); + std::ostream &operator<<(std::ostream &stream, const Grammar &grammar); std::ostream &operator<<(std::ostream &stream, const Conflict &conflict); std::ostream &operator<<(std::ostream &stream, const GrammarError *error); -std::tuple, const GrammarError *> compile( - const Grammar &grammar, std::string name); -} +} // namespace tree_sitter #endif // TREE_SITTER_COMPILER_H_ diff --git a/script/lint.sh b/script/lint.sh index a63af0e4..f1e84dee 100755 --- a/script/lint.sh +++ b/script/lint.sh @@ -8,9 +8,7 @@ if [[ ! -f $CPPLINT ]]; then chmod +x $CPPLINT fi -$CPPLINT \ - --root=src \ - --linelength=85 \ - --filter=-legal/copyright,-readability/todo \ - $(find src/compiler -type f) \ - 2>&1 +FILTERS='--filter=-legal/copyright,-readability/todo' + +$CPPLINT --root=include $FILTERS include/tree_sitter/compiler.h 2>&1 +$CPPLINT --root=src $FILTERS $(find src/compiler -type f) 2>&1