Skip to content

Commit

Permalink
feat: Allow calls immediately after function definition.
Browse files Browse the repository at this point in the history
  • Loading branch information
reiniscirpons committed May 26, 2024
1 parent e92c672 commit 2c1958e
Show file tree
Hide file tree
Showing 5 changed files with 5,934 additions and 5,931 deletions.
8 changes: 6 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,11 @@ module.exports = grammar({
call: $ => prec(PREC.CALL, seq(
field('function', choice(
$._variable,
$.parenthesized_expression
$.parenthesized_expression,
// Yes, you can define a function and immediately call it
$.function
// But not an atomic function, for some reason!?
// $.atomic_function
)),
field('arguments', $.argument_list)
)),
Expand Down Expand Up @@ -545,7 +549,7 @@ module.exports = grammar({
comment: _ => token(seq('#', /.*/)),

// TODO: implement external scanner for line continuations
line_continuation: _ => token(seq('\\', choice(seq(optional('\r'), '\n'), '\0'))),
// line_continuation: _ => token(seq('\\', choice(seq(optional('\r'), '\n'), '\0'))),

qualifier: _ => choice('readonly', 'readwrite')

Expand Down
46 changes: 4 additions & 42 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,10 @@
{
"type": "SYMBOL",
"name": "parenthesized_expression"
},
{
"type": "SYMBOL",
"name": "function"
}
]
}
Expand Down Expand Up @@ -2232,48 +2236,6 @@
]
}
},
"line_continuation": {
"type": "TOKEN",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "\\"
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "\r"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "\n"
}
]
},
{
"type": "STRING",
"value": "\u0000"
}
]
}
]
}
},
"qualifier": {
"type": "CHOICE",
"members": [
Expand Down
4 changes: 4 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,10 @@
"type": "component_selector",
"named": true
},
{
"type": "function",
"named": true
},
{
"type": "identifier",
"named": true
Expand Down
Loading

0 comments on commit 2c1958e

Please sign in to comment.