tree-sitter-0.8.0.2: Unstable bindings for the tree-sitter parsing library.
Safe HaskellNone
LanguageHaskell2010

TreeSitter.GenerateSyntax

Synopsis

Documentation

astDeclarationsForLanguage :: Ptr Language -> FilePath -> Q [Dec] Source #

Derive Haskell datatypes from a language and its node-types.json file.

Datatypes will be generated according to the specification in the node-types.json file, with anonymous leaf types defined as synonyms for the Token datatype.

Any datatypes among the node types which have already been defined in the module where the splice is run will be skipped, allowing customization of the representation of parts of the tree. Note that this should be used sparingly, as it imposes extra maintenance burden, particularly when the grammar is changed. This may be used to e.g. parse literals into Haskell equivalents (e.g. parsing the textual contents of integer literals into Integers), and may require defining UnmarshalAnn or SymbolMatching instances for (parts of) the custom datatypes, depending on where and how the datatype occurs in the generated tree, in addition to the usual Foldable, Functor, etc. instances provided for generated datatypes.