tree-sitter / tree-sitter-haskell

Haskell grammar for tree-sitter.
MIT License
152 stars 36 forks source link

How do I build this outside of nvim-tree-sitter? #51

Closed wenkokke closed 2 years ago

tek commented 2 years ago

I've only ever used it from neovim. I'll try to investigate

gwerbin commented 2 years ago

I built it using LLVM 13 that shipped with my copy of MacOS 11.x:

clang++ -fPIC -shared -Os -std=c++14 -lstdc++ \
  -o tree-sitter-haskell/parser.so \
  -I tree-sitter-haskell/src \
  tree-sitter-haskell/src/parser.c tree-sitter-haskell/src/scanner.cc

However I got a warning due to mixing C and C++ files:

clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]

I based this invocation of of the Nvim-Treesitter source code: https://github.com/nvim-treesitter/nvim-treesitter/blob/e3e43c4/lua/nvim-treesitter/shell_command_selectors.lua#L58-L94.

There appears to be nothing special here, other than the need for -std=c++14 in the Haskell parser, which is apparently not required for most other parsers.

wenkokke commented 2 years ago

Unfortunately, that means that building it with the cli, e.g., using tree-sitter build-wasm fails as it compiles via emscripten and passes -std=c99.

wenkokke commented 2 years ago

This bug means tree-sitter-haskell cannot currently be built using tree-sitter build-wasm, which blocks its inclusion in wider projects such as the VSCode parse tree extension.

Can anyone who is familiar with this codebase advice me on how to fix this?

tek commented 2 years ago

what do you see as a possible solution to this problem?

wenkokke commented 2 years ago

I don't fully understand what tree-sitter is doing. However, on my system, tree-sitter test fails for this project with a number of C compiler errors.

wenkokke commented 2 years ago

The following patch seems at least part of the solution, but it doesn't fully fix the problem:

diff --git a/binding.gyp b/binding.gyp
index 91d2eae..b2fa651 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -12,8 +12,11 @@
         "src/scanner.cc",
       ],
       "cflags_c": [
-        "-std=c99",
-      ]
+        "-std=c++14",
+      ],
+      'xcode_settings': {
+        'CLANG_CXX_LANGUAGE_STANDARD': 'c++14',
+      },
tek commented 2 years ago

ah, that's nice. what's the result with this?

wenkokke commented 2 years ago

Still and endless wall of errors indicating that the C++ version is smaller than C++14:

Parser compilation failed.
Stdout: 
Stderr: /Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:82:10: error: expected expression
  return [=](A a) { return f(g(a)); };
         ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:86:10: error: expected expression
  return [=](A a) { return f(g(a)); };
         ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:90:10: error: expected expression
  return [=](A a) { return f(g(a)); };
         ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:93:64: error: expected expression
template<class A, class B> function<B(A)> const_(B b) { return [=](auto _) { return b; }; }
                                                               ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:163:16: error: non-aggregate type 'vector<std::string>' (aka 'vector<basic_string<char> >') cannot be initialized with an initializer list
vector<string> names = {
               ^       ~
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:193:69: error: expected expression
bool all(const bool *syms) { return std::all_of(syms, syms + empty, [](bool a) { return a; }); }
                                                                    ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:250:8: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
  for (auto i : state.indents) {
       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:250:15: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
  for (auto i : state.indents) {
              ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:294:1: warning: 'function<void (State &)>' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
function<void(State&)> mark(string marked_by) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<void (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:295:10: error: expected expression
  return [=](State & state) {
         ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:316:9: warning: 'function<bool (unsigned int)>' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
typedef function<bool(uint32_t)> Peek;
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (unsigned int)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:318:22: warning: 'Peek' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Peek operator&(const Peek & l, const Peek & r) { return [=](uint32_t c) { return l(c) && r(c); }; }
                     ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (unsigned int)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:318:38: warning: 'Peek' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Peek operator&(const Peek & l, const Peek & r) { return [=](uint32_t c) { return l(c) && r(c); }; }
                                     ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (unsigned int)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:318:1: warning: 'Peek' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Peek operator&(const Peek & l, const Peek & r) { return [=](uint32_t c) { return l(c) && r(c); }; }
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (unsigned int)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:318:57: error: expected expression
Peek operator&(const Peek & l, const Peek & r) { return [=](uint32_t c) { return l(c) && r(c); }; }
                                                        ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:319:22: warning: 'Peek' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Peek operator|(const Peek & l, const Peek & r) { return [=](uint32_t c) { return l(c) || r(c); }; }
                     ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (unsigned int)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:319:38: warning: 'Peek' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Peek operator|(const Peek & l, const Peek & r) { return [=](uint32_t c) { return l(c) || r(c); }; }
                                     ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (unsigned int)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:319:1: warning: 'Peek' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Peek operator|(const Peek & l, const Peek & r) { return [=](uint32_t c) { return l(c) || r(c); }; }
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (unsigned int)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:319:57: error: expected expression
Peek operator|(const Peek & l, const Peek & r) { return [=](uint32_t c) { return l(c) || r(c); }; }
                                                        ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:320:11: warning: 'Peek' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Peek not_(Peek con) { return [=](uint32_t c) { return !con(c); }; }
          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (unsigned int)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:320:1: warning: 'Peek' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Peek not_(Peek con) { return [=](uint32_t c) { return !con(c); }; }
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (unsigned int)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:320:30: error: expected expression
Peek not_(Peek con) { return [=](uint32_t c) { return !con(c); }; }
                             ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:329:9: warning: 'function<bool (State &)>' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
typedef function<bool(State&)> Condition;
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:331:27: warning: 'Condition' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Condition operator&(const Condition & l, const Condition & r) { return [=](auto s) { return l(s) && r(s); }; }
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:331:48: warning: 'Condition' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Condition operator&(const Condition & l, const Condition & r) { return [=](auto s) { return l(s) && r(s); }; }
                                               ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:331:1: warning: 'Condition' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Condition operator&(const Condition & l, const Condition & r) { return [=](auto s) { return l(s) && r(s); }; }
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:331:72: error: expected expression
Condition operator&(const Condition & l, const Condition & r) { return [=](auto s) { return l(s) && r(s); }; }
                                                                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:332:27: warning: 'Condition' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Condition operator|(const Condition & l, const Condition & r) { return [=](auto s) { return l(s) || r(s); }; }
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:332:48: warning: 'Condition' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Condition operator|(const Condition & l, const Condition & r) { return [=](auto s) { return l(s) || r(s); }; }
                                               ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:332:1: warning: 'Condition' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Condition operator|(const Condition & l, const Condition & r) { return [=](auto s) { return l(s) || r(s); }; }
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:332:72: error: expected expression
Condition operator|(const Condition & l, const Condition & r) { return [=](auto s) { return l(s) || r(s); }; }
                                                                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:333:22: warning: 'Condition' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Condition not_(const Condition & c) { return [=](State & state) { return !c(state); }; }
                     ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:333:1: warning: 'Condition' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Condition not_(const Condition & c) { return [=](State & state) { return !c(state); }; }
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:333:46: error: expected expression
Condition not_(const Condition & c) { return [=](State & state) { return !c(state); }; }
                                             ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:339:9: warning: 'function<std::pair<bool, unsigned int> (State &)>' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
typedef function<pair<bool, uint32_t>(State &)> PeekResult;
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<std::pair<bool, unsigned int> (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:346:1: warning: 'Condition' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Condition pure(bool c) { return const_<State&>(c); }
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:93:28: warning: 'function<bool (State &)>' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
template<class A, class B> function<B(A)> const_(B b) { return [=](auto _) { return b; }; }
                           ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:348:1: warning: 'Peek' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Peek eq(uint32_t target) { return [=](uint32_t c) { return target == static_cast<uint32_t>(c); }; }
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (unsigned int)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:348:35: error: expected expression
Peek eq(uint32_t target) { return [=](uint32_t c) { return target == static_cast<uint32_t>(c); }; }
                                  ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:360:52: warning: 'Peek' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
function<std::pair<bool, uint32_t>(State &)> peeks(Peek pred) {
                                                   ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (unsigned int)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:360:1: warning: 'function<std::pair<bool, unsigned int> (State &)>' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
function<std::pair<bool, uint32_t>(State &)> peeks(Peek pred) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<std::pair<bool, unsigned int> (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:361:10: error: expected expression
  return [=](State & state) {
         ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:368:21: warning: 'Peek' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Condition peek_with(Peek pred) { return fst<bool, uint32_t> * peeks(pred); }
                    ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (unsigned int)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:368:1: warning: 'Condition' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Condition peek_with(Peek pred) { return fst<bool, uint32_t> * peeks(pred); }
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:89:37: warning: 'function<bool (State &)>' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
template<class A, class B, class C> function<C(A)> operator*(C (&f)(B), function<B(A)> g) {
                                    ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:89:73: warning: 'function<std::pair<bool, unsigned int> (State &)>' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
template<class A, class B, class C> function<C(A)> operator*(C (&f)(B), function<B(A)> g) {
                                                                        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<std::pair<bool, unsigned int> (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:370:1: warning: 'Condition' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Condition varid = cond::peek_with(cond::varid_start_char);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:375:1: warning: 'Condition' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Condition peek(uint32_t c) { return fst<bool, uint32_t> * peeks(eq(c)); }
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:381:20: warning: 'Peek' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
PeekResult skip_if(Peek pred) {
                   ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (unsigned int)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:381:1: warning: 'PeekResult' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
PeekResult skip_if(Peek pred) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<std::pair<bool, unsigned int> (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:382:10: error: expected expression
  return [=](State & state) {
         ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:392:17: warning: 'Peek' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Condition skips(Peek pred) { return fst<bool, uint32_t> * skip_if(pred); }
                ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (unsigned int)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:392:1: warning: 'Condition' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Condition skips(Peek pred) { return fst<bool, uint32_t> * skip_if(pred); }
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:398:1: warning: 'Condition' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Condition skip(uint32_t c) { return skips(eq(c)); }
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:403:23: warning: 'Peek' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
PeekResult consume_if(Peek pred) {
                      ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (unsigned int)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:403:1: warning: 'PeekResult' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
PeekResult consume_if(Peek pred) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<std::pair<bool, unsigned int> (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:404:10: error: expected expression
  return [=](State & state) {
         ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:414:20: warning: 'Peek' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Condition consumes(Peek pred) { return fst<bool, uint32_t> * consume_if(pred); }
                   ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (unsigned int)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:414:1: warning: 'Condition' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Condition consumes(Peek pred) { return fst<bool, uint32_t> * consume_if(pred); }
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:419:1: warning: 'Condition' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Condition consume(uint32_t c) { return consumes(eq(c)); }
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:425:1: warning: 'Condition' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
Condition seq(const string & s) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:426:10: error: expected expression
  return [=](State & state) { return all_of(s.begin(), s.end(), [&](auto a) { return consume(a)(state); }); };
         ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:429:39: warning: 'Peek' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
function<void(State &)> consume_while(Peek pred) {
                                      ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<bool (unsigned int)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:429:1: warning: 'function<void (State &)>' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
function<void(State &)> consume_while(Peek pred) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<void (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:430:10: error: expected expression
  return [=](State & state) {
         ^
/Users/wen/Projects/tree-sitter-haskell/src/scanner.cc:441:1: warning: 'function<void (State &)>' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations]
function<void(State &)> consume_until(string target) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1449:27: note: 'function<void (State &)>' has been explicitly marked deprecated here
template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:1444:24: note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION'
        __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
                       ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
47 warnings and 20 errors generated.
tek commented 2 years ago

I'm not aware that there's a way to reliably make tree-sitter choose an appropriate compiler. did you try using gcc like it's described in the readme?

wenkokke commented 2 years ago

I built it using LLVM 13 that shipped with my copy of MacOS 11.x:

clang++ -fPIC -shared -Os -std=c++14 -lstdc++ \
  -o tree-sitter-haskell/parser.so \
  -I tree-sitter-haskell/src \
  tree-sitter-haskell/src/parser.c tree-sitter-haskell/src/scanner.cc

However I got a warning due to mixing C and C++ files:

clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]

I based this invocation of of the Nvim-Treesitter source code: https://github.com/nvim-treesitter/nvim-treesitter/blob/e3e43c4/lua/nvim-treesitter/shell_command_selectors.lua#L58-L94.

There appears to be nothing special here, other than the need for -std=c++14 in the Haskell parser, which is apparently not required for most other parsers.

This comment makes it seem like it can be built using clang?

tek commented 2 years ago

yeah, the problem is that tree-sitter uses the default mode of the available compiler, afaict, which is fine for gcc but lacks the c++14 for clang

tek commented 2 years ago

something like that, I think

wenkokke commented 2 years ago

For reference, the solution provided in the README, shadowing Apple Clang using a Homebrewed GCC, no longer seems to work:

ln -sf /opt/homebrew/bin/gcc-11 /usr/local/bin/gcc

I still get the errors, even though ls -l $(which gcc) resolves to:

/usr/local/bin/gcc -> /usr/local/Cellar/gcc/11.2.0_3/bin/gcc-11

Which might mean that tree-sitter has become "cleverer" about resolving which C compiler to use?

tek commented 2 years ago

this is done by node-gyp, which I didn't find very accessible. check out its docs: https://gyp.gsrc.io/docs/UserDocumentation.md

wenkokke commented 2 years ago

Using CXX=g++-11 still works:

brew install gcc
CXX=g++-11 tree-sitter test