Skip to content

Commit

Permalink
Don't consume trailing newlines as part layouts (#74)
Browse files Browse the repository at this point in the history
Additionally, using left-associative precedence for lambda case causes
brace layouts to fail
  • Loading branch information
tek committed Mar 12, 2022
1 parent e4335ea commit 0fcad22
Show file tree
Hide file tree
Showing 8 changed files with 333,390 additions and 314,090 deletions.
3 changes: 3 additions & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = grammar({
extras: $ => [
/\p{Zs}/,
/\n/,
/\r/,
$.cpp,
$.comment,
$.pragma,
Expand Down Expand Up @@ -201,6 +202,8 @@ module.exports = grammar({
* Implicit parameters have slightly weird restrictions.
*/
[$._type_or_implicit, $._context_constraints],

[$.exp_lambda_case],
],

word: $ => $._varid,
Expand Down
4 changes: 2 additions & 2 deletions grammar/exp.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ module.exports = {
/**
* left associative because the alts are optional
*/
exp_lambda_case: $ => prec.left(seq(
exp_lambda_case: $ => seq(
'\\',
'case',
optional($.alts),
)),
),

rec: $ => seq(
'rec',
Expand Down
57 changes: 30 additions & 27 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -4031,33 +4031,29 @@
]
},
"exp_lambda_case": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "\\"
},
{
"type": "STRING",
"value": "case"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "alts"
},
{
"type": "BLANK"
}
]
}
]
}
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "\\"
},
{
"type": "STRING",
"value": "case"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "alts"
},
{
"type": "BLANK"
}
]
}
]
},
"rec": {
"type": "SEQ",
Expand Down Expand Up @@ -8972,6 +8968,10 @@
"type": "PATTERN",
"value": "\\n"
},
{
"type": "PATTERN",
"value": "\\r"
},
{
"type": "SYMBOL",
"name": "cpp"
Expand Down Expand Up @@ -9071,6 +9071,9 @@
[
"_type_or_implicit",
"_context_constraints"
],
[
"exp_lambda_case"
]
],
"precedences": [
Expand Down

0 comments on commit 0fcad22

Please sign in to comment.