Skip to content

Latest commit

 

History

History
78 lines (51 loc) · 2.55 KB

CONTRIBUTING.md

File metadata and controls

78 lines (51 loc) · 2.55 KB

Thank you for contributing

Project Setup

The project consists of

  • grammar.js the tree-sitter grammar for xQuery.
  • test/corpus/
  • queries/ highlight.scm etc
  • examples/ xQuery example files
  • config this is the symlinked to the $HOME/.tree-sitter
  • Makefile: some tree-sitter shortcut commands, helped by a dot env file

The top-level make just invokes tree-sitter generate. To adjust what files are tested, parsed or queried, I alter vars in '.env'. make test var TEST_SECTION: will test my current working section under test.
For make parse, make test, make query and make hl, will use the EXAMPLE file in the examples folder

xQuery Treesitter Grammar

Although there is a lot to digest the guides I have found useful are

xQuery Treesitter Queries

Capture queries are written as S-expresions

  1. hightlights: WIP
  2. locals: TODO
  3. folds: TODO
  4. indents: TODO

The above are built in, but there should be other queries associated with treesitter plugin modules

Apart from looking at how other grammar queries are constructed, I refer to the following

Captures will only capture if a query will resolve to a valid node in the grammer. So frequently running make query-all is a good idea, as it will throw an diagnostic error

Known limitations/issues

comments

errors if ':' or ')' at end of comment delimiter

(: OK! (: xquery allows embed comments :) :)
(:~
:  ok with doc style comments
:
:)
 (: but this will error ::)

There are no lookahead regex expr allowed for tree-sitter grammars, so this might no be resolved, unless a c lexer is used. Thats what other TS grammars use.

extra node can appear in direct constructors

not sure how to resolve

regex edge cases

TODO