Skip to content

Commit

Permalink
Tests for type annotations and renam ops to use snake case
Browse files Browse the repository at this point in the history
  • Loading branch information
Cypher1 committed Oct 4, 2024
1 parent 13b9d7e commit 55f9cbb
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tree-sitter-tako/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const PREC = {
try: 15,
neg: 14,
not: 14,
bitnot: 14,
bit_not: 14,
cast: 13,
mul: 12,
div: 12,
Expand All @@ -16,9 +16,9 @@ const PREC = {
sub: 11,
left_shift: 10,
right_shift: 10,
bitand: 9,
bitxor: 8,
bitor: 7,
bit_and: 9,
bit_xor: 8,
bit_or: 7,
// comparative: 6,
equals: 6,
not_equals: 6,
Expand All @@ -44,9 +44,9 @@ const OPERATORS = [
['has_type', ':'],
['and', '&&'],
['or', '||'],
['bitand', '&'],
['bitor', '|'],
['bitxor', '^'],
['bit_and', '&'],
['bit_or', '|'],
['bit_xor', '^'],
['equals', '=='],
['not_equals', '!='],
['less_than', '<'],
Expand All @@ -73,7 +73,7 @@ const OPTIONALLY_POSTFIX_OPERATORS = [
const UNARY_OPERATORS = [
['neg', '-'],
['not', '!'],
['bitnot', '~'],
['bit_not', '~'],
];

const ALL_OPERATORS = [
Expand Down
53 changes: 53 additions & 0 deletions tree-sitter-tako/test/corpus/definitions.tk
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,56 @@ test(a, b) = {
(block (int_literal))
)
)

==================
Definition with type
==================
test: Num = 3
---
(source_file
(assign
(has_type
(ident)
(ident)
)
(int_literal)
)
)

==================
Definition with type that is an expression
==================
test: Float | Int = 3
---
(source_file
(assign
(has_type
(ident)
(bit_or
(ident)
(ident)
)
)
(int_literal)
)
)

==================
Function Definition with arguments and types using Block
==================
test(a: AType, b: BType): TestResultType = {
3: TestResultType
}
---
(source_file
(assign
(has_type
(call (ident)
(has_type (ident) (ident))
(has_type (ident) (ident))
)
(ident)
)
(block (has_type (int_literal) (ident)))
)
)

0 comments on commit 55f9cbb

Please sign in to comment.