A WIP tree-sitter grammar for Crystal.
- 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
-
require
statements - 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
-
include
statements
-
- Structs
- Enums
- Type annotations
- in variable declarations
- in method parameter declarations
- as method return types
-
alias
statements
- Basic "bare" types (e.g.
- Blocks
-
do
blocks (with and without parameters) -
{|x| whatever }
blocks (with parameters only) -
begin
...rescue
...end
blocks
-
- Method definitions
- Method calls
- "Bare" function calls (like
puts 1
andputs(1)
) - Splats
- in method calls
- in method definitions
- Macros
- Annotations
To test tree-sitter generate && tree-sitter test
(or just npm test
)