Skip to content

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 (WIP) (current with dhall-lang commit 4bedfcf) 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. It's probably not portable, so open an issue if that becomes a problem. 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) Jared Beller, 2022.
Released under the MIT License. Test scenarios in corpus/ are copyright the Dhall authors and reproduced under the BSD-3-Clause License.

About

Dhall grammar for tree-sitter

Topics

Resources

License

MIT, BSD-3-Clause licenses found

Licenses found

MIT
LICENSE
BSD-3-Clause
LICENSE.dhall-lang

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages