Skip to content

Commit

Permalink
Add failing let expression corpus tests.
Browse files Browse the repository at this point in the history
Resolving them may help with issue #1.
  • Loading branch information
jmitchell committed Mar 2, 2019
1 parent 2eadc04 commit 69a9c9d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules
build
*.log
corpus/broken-*.txt

26 changes: 26 additions & 0 deletions corpus-broken/expression.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
========================================
Let (nested with multiple `in`)
========================================

let x = e1 in let y = e2 in e3

---

(source_file (complete_expression (expression
(let (let_raw)) (label (simple_label)) (equal)
(expression (annotated_expression (operator_expression (import_alt_expression (or_expression (plus_expression (text_append_expression (list_append_expression (and_expression (combine_expression (prefer_expression (combine_types_expression (times_expression (equal_expression (not_equal_expression (application_expression (import_expression (selector_expression (primitive_expression (identifier (label (simple_label))))))))))))))))))))))
(in (in_raw))
(let (let_raw)) (label (simple_label)) (equal)
(expression (annotated_expression (operator_expression (import_alt_expression (or_expression (plus_expression (text_append_expression (list_append_expression (and_expression (combine_expression (prefer_expression (combine_types_expression (times_expression (equal_expression (not_equal_expression (application_expression (import_expression (selector_expression (primitive_expression (identifier (label (simple_label))))))))))))))))))))))
(in (in_raw))
(expression (annotated_expression (operator_expression (import_alt_expression (or_expression (plus_expression (text_append_expression (list_append_expression (and_expression (combine_expression (prefer_expression (combine_types_expression (times_expression (equal_expression (not_equal_expression (application_expression (import_expression (selector_expression (primitive_expression (identifier (label (simple_label)))))))))))))))))))))))))

========================================
Let (label containing `in`)
========================================

let x = binary in e2

---

(source_file (complete_expression (expression (let (let_raw)) (label (simple_label)) (equal) (expression (annotated_expression (operator_expression (import_alt_expression (or_expression (plus_expression (text_append_expression (list_append_expression (and_expression (combine_expression (prefer_expression (combine_types_expression (times_expression (equal_expression (not_equal_expression (application_expression (import_expression (selector_expression (primitive_expression (identifier (label (simple_label)))))))))))))))))))))) (in (in_raw)) (expression (annotated_expression (operator_expression (import_alt_expression (or_expression (plus_expression (text_append_expression (list_append_expression (and_expression (combine_expression (prefer_expression (combine_types_expression (times_expression (equal_expression (not_equal_expression (application_expression (import_expression (selector_expression (primitive_expression (identifier (label (simple_label)))))))))))))))))))))))))
2 changes: 1 addition & 1 deletion corpus/expression.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ let x = e1 in e2
(expression (annotated_expression (operator_expression (import_alt_expression (or_expression (plus_expression (text_append_expression (list_append_expression (and_expression (combine_expression (prefer_expression (combine_types_expression (times_expression (equal_expression (not_equal_expression (application_expression (import_expression (selector_expression (primitive_expression (identifier (label (simple_label)))))))))))))))))))))))))

========================================
Let (nested)
Let (nested with single `in`)
========================================

let x = e1 let y = e2 in e3
Expand Down
9 changes: 9 additions & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ module.exports = grammar({
// ; according to the ordering of alternatives. That is, the order of evaluation,
// ; of the alternatives is left-to-right.,
// ;,

// TODO: Add a corpus test case for this and consider how to
// convey the left-to-right alternation preference to tree-sitter.

// ; For example, the grammar for single quoted string literals is:,
// ;,
// ; single-quote-continue =,
Expand Down Expand Up @@ -153,6 +157,11 @@ module.exports = grammar({
// ; left-associative and all operators are left-associative when they are not,
// ; parenthesized.,
// ;,

// TODO: Consider how to test whether tree-sitter behaves this way
// and, if not, whether it can be persuaded to through a
// mechanical grammar translation.

// ; Additionally, try alternatives in an order that minimizes backtracking,
// ; according to the following rule:,
// ;,
Expand Down

0 comments on commit 69a9c9d

Please sign in to comment.