diff --git a/grammar.js b/grammar.js index 35c56fa..da1460a 100644 --- a/grammar.js +++ b/grammar.js @@ -104,7 +104,7 @@ module.exports = grammar({ ) ), - shebang: _ => /#![^\n]*/, + shebang: (_) => /#![^\n]*/, _last_statement: ($) => choice($.return_statement, $.break_statement), @@ -574,7 +574,7 @@ module.exports = grammar({ prec.right( PREC.FUNCTION, seq( - "function(", + choice("function(", "fun("), list_of($.emmy_function_parameter, ",", false), ")", optional(seq(":", $.emmy_identifier)) @@ -643,6 +643,7 @@ module.exports = grammar({ /\s*---@field\s+/, optional(seq(field("visibility", $.emmy_visibility), /\s+/)), field("name", $.identifier), + optional("?"), /\s+/, field("type", $._emmy_type), diff --git a/src/grammar.json b/src/grammar.json index 105a661..28cd010 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -3030,8 +3030,17 @@ "type": "SEQ", "members": [ { - "type": "STRING", - "value": "function(" + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "function(" + }, + { + "type": "STRING", + "value": "fun(" + } + ] }, { "type": "SEQ", @@ -3356,6 +3365,18 @@ "name": "identifier" } }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "?" + }, + { + "type": "BLANK" + } + ] + }, { "type": "PATTERN", "value": "\\s+" diff --git a/src/node-types.json b/src/node-types.json index b5b4448..2406b6b 100644 --- a/src/node-types.json +++ b/src/node-types.json @@ -2937,6 +2937,10 @@ "type": "for_start", "named": true }, + { + "type": "fun(", + "named": false + }, { "type": "function(", "named": false diff --git a/src/parser.c b/src/parser.c index 5d6646f..ae60524 100644 Binary files a/src/parser.c and b/src/parser.c differ