tree-sitter-crystal
A WIP tree-sitter grammar for Crystal.
Status
- Comments
- Literals
- nil
- bool
- float
- integer
- symbol
- char
- string
- literals
- interpolation
- array
- hash
- array-or-hash-index-access (
foo[0]orfoo[:something]) - range
- regex
- tuple
- namedtuple
- proc
- command
- literals
- interpolation
- Assignment
- to local var
- to instance var
- to class var
- to constant
- to "assignment methods"/properties
- multiple-assignment
- Binary operations
- basic support
- per-operator precedence definitions
- Variables
- local variables
- instance variables
- class variables
- constants
- Control expressions
- if/else
- "block-level" form (
if something ; stuff ; else ; end) - "suffix" form (
foo = bar if something)
- "block-level" form (
- unless
- "block-level" form (
unless something ; stuff ; else ; end) - "suffix" form (
foo = bar unless something)
- "block-level" form (
- case
- while
- until
- if/else
-
requirestatements - Type grammar
- Basic "bare" types (e.g.
Foo) - Namespaced types (e.g.
Some::Namespace::Foo) - Generic types (e.g.
Foo(T)andFoo(A, B)) - Union types
- Class definitions
- Module definitions
-
includestatements
-
- Structs
- Enums
- Type annotations
- in variable declarations
- in method parameter declarations
- as method return types
-
aliasstatements
- Basic "bare" types (e.g.
- Blocks
-
doblocks (with and without parameters) -
{|x| whatever }blocks (with parameters only) -
begin...rescue...endblocks
-
- Method definitions
- Method calls
- "Bare" function calls (like
puts 1andputs(1)) - Splats
- in method calls
- in method definitions
- Macros
- Annotations
Developing
To test tree-sitter generate && tree-sitter test (or just npm test)