Skip to content

Dhall grammar for tree-sitter

License

MIT, BSD-3-Clause licenses found

Licenses found

MIT
LICENSE
BSD-3-Clause
LICENSE.dhall-lang
Notifications You must be signed in to change notification settings

jbellerb/tree-sitter-dhall

Repository files navigation

tree-sitter-dhall

Dhall grammar for tree-sitter

Scope

This parser is designed for syntax highlighting and does not strictly follow the Dhall language semantics. My goal is for all valid Dhall expressions to parse to something sensible. An invalid expression parsing is fine, except when it is obviously wrong. To help with this, the output of the parser is checked with hand-written syntax trees for every Dhall successful parse test (current with dhall-lang commit 4fecb49) except:

  • unit/ShebangA.dhall, unit/ShebangNixA.dhall: Handled by the text editor.
  • unit/TrailingLineCommentWithoutNewlineA.dhall: Unclear how to test with tree-sitter.

These tests also serve as a reference for what syntax trees various Dhall expressions produce. A shell script (tests.sh) is used to check that all tests are included. There may be extra test cases besides the Dhall ones. Ideally, those would eventually get upstreamed.

References

  • The Dhall Syntax Grammar - Dhall syntax is specified as an ABNF grammar based on RFC 5234.
  • The Dhall Acceptance Tests - Tests provided by the Dhall authors to verify implementation correctness. The binary format parsing tests evaluate to is described here.
  • Dhall Semantics - The complete specification of the dhall language, which all implementations are based on.

License

Copyright (C) jae beller, 2022.
Released under the MIT License. Test scenarios in test/corpus/ are copyright the Dhall authors and reproduced under the BSD-3-Clause License.