Skip to content

Commit

Permalink
Update and improve examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Cypher1 committed Oct 7, 2024
1 parent 55f9cbb commit 42418d7
Show file tree
Hide file tree
Showing 8 changed files with 235 additions and 40 deletions.
2 changes: 2 additions & 0 deletions tree-sitter-tako/test/corpus/contexts.tk
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ main() = {
print(test_logger)
}
---


2 changes: 2 additions & 0 deletions tree-sitter-tako/test/corpus/fib_acc.tk
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ fib(n: T, forall T: Nat): T=fib_helper(n, 0, 1)

print(fib(80))
---


3 changes: 3 additions & 0 deletions tree-sitter-tako/test/corpus/format_string.tk
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ Format strings

"1+1 = {1+1}"
---

(source_file
(string_literal (add (int_literal) (int_literal)))
2 changes: 2 additions & 0 deletions tree-sitter-tako/test/corpus/generic_abstract_data_types.tk
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ Expr(
boolean(value: Boolean): Expr(SubExpr, R=Boolean),
)
---


2 changes: 2 additions & 0 deletions tree-sitter-tako/test/corpus/instances.tk
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ Showable.add_values(
integer(t: Integer)=t.to_base(base=10)
)
---


180 changes: 140 additions & 40 deletions tree-sitter-tako/test/corpus/simple_exprs.tk
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ Simple value with postfix sequence
0;

---

(source_file
(sequence
(int_literal)
)
)
(int_literal)))

==================
Simple values with infix sequence
Expand All @@ -18,12 +17,11 @@ Simple values with infix sequence
0;1

---

(source_file
(sequence
(int_literal)
(int_literal)
)
)
(int_literal)))

==================
Simple values with parens
Expand All @@ -32,11 +30,10 @@ Simple values with parens
(0)

---

(source_file
(parens
(int_literal)
)
)
(int_literal)))

==================
Simple values with more parens
Expand All @@ -45,13 +42,11 @@ Simple values with more parens
((0))

---

(source_file
(parens
(parens
(int_literal)
)
)
)
(int_literal))))

==================
Simple values with mismatched parens
Expand All @@ -60,14 +55,13 @@ Simple values with mismatched parens
((0()

---

(source_file
(parens
(parens
(int_literal)
(ERROR))
(MISSING ")")
)
)
(MISSING ")")))

==================
Empty Block
Expand All @@ -76,9 +70,9 @@ Empty Block
{}

---

(source_file
(block)
)
(block))

==================
Empty Block with suffix sequence
Expand All @@ -87,9 +81,10 @@ Empty Block with suffix sequence
{};

---

(source_file
(sequence (block))
)
(sequence
(block)))

==================
Empty Container notation
Expand All @@ -98,10 +93,9 @@ Empty Container notation
[]

---
(source_file
(container)
)

(source_file
(container))

==================
Container notation with a single value
Expand All @@ -110,11 +104,10 @@ Container notation with a single value
[1]

---

(source_file
(container
(int_literal)
)
)
(int_literal)))

==================
Container notation with multiple values
Expand All @@ -123,14 +116,13 @@ Container notation with multiple values
[1,2,3,4,]

---

(source_file
(container
(int_literal)
(int_literal)
(int_literal)
(int_literal)
)
)
(int_literal)))

==================
Container notation containing multiple identifiers
Expand All @@ -139,15 +131,13 @@ Container notation containing multiple identifiers
[a,b,c,d,]

---

(source_file
(container
(ident)
(ident)
(ident)
(ident)
)
)

(ident)))

==================
Container notation containing multiple subexpressions
Expand All @@ -156,14 +146,91 @@ Container notation containing multiple subexpressions
[3+a,b*c,c=0,"Wow",]

---

(source_file
(container
(add (int_literal) (ident))
(mul (ident) (ident))
(assign (ident) (int_literal))
(string_literal)
)
)
(add
(int_literal)
(ident))
(mul
(ident)
(ident))
(assign
(ident)
(int_literal))
(string_literal)))

==================
Sequence containing an empty block
==================

{};
---

(source_file
(sequence
(block)))

==================
Sequence containing a container containing an empty block
==================

[{}];
---

(source_file
(sequence
(container
(block))))

==================
Sequence containing a container containing an empty container
==================

[[]];
---

(source_file
(sequence
(container
(container))))

==================
Sequence containing a block containing an empty block
==================

{{}};
---

(source_file
(sequence
(block
(block))))

==================
Sequence containing parens containing an empty block
==================

({});
---

(source_file
(sequence
(parens
(block))))

==================
Sequence containing a call containing an empty block
==================

print({});
---

(source_file
(sequence
(call
(ident)
(block))))

==================
Simple Expressions
Expand All @@ -183,7 +250,7 @@ Simple Expressions

[];

[{}]
[{}];

[[]];

Expand All @@ -194,3 +261,36 @@ Simple Expressions
print({});

---

(source_file
(shebang)
(single_line_comment)
(sequence
(int_literal)
(sequence
(parens
(int_literal))
(sequence
(parens
(parens
(int_literal)))
(sequence
(block)
(sequence
(container)
(sequence
(container
(block))
(sequence
(container
(container))
(sequence
(block
(block))
(sequence
(parens
(block))
(sequence
(call
(ident)
(block)))))))))))))
41 changes: 41 additions & 0 deletions tree-sitter-tako/test/corpus/vector_transpose.tk
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,44 @@ main = {
print("{x3by2}.transpose() is {x2by3}");
}
---

(source_file
(shebang)
(single_line_comment)
(assign
(ident)
(block
(sequence
(assign
(ident)
(field
(ident)
(call
(ident)
(container
(container
(int_literal)
(int_literal))
(container
(int_literal)
(int_literal))
(container
(int_literal)
(int_literal))))))
(single_line_comment)
(sequence
(assign
(has_type
(ident)
(call
(ident)
(int_literal)
(int_literal)))
(field
(ident)
(call
(ident))))
(sequence
(call
(ident)
(string_literal))))))))
Loading

0 comments on commit 42418d7

Please sign in to comment.