1
- const { commaSep, commaSep1, commaSep2} = require ( './utils.js' )
1
+ const { commaSep, commaSep1, commaSep2 } = require ( './utils.js' )
2
2
3
3
module . exports = {
4
4
function_definition : $ => seq (
5
5
field ( "type_variables" , optional ( $ . type_variables_list ) ) ,
6
6
field ( "return_type" , $ . _type ) ,
7
7
field ( "name" , $ . function_name ) ,
8
- field ( "arguments" , $ . parameter_list ) ,
9
- field ( "specifiers" , optional ( $ . specifiers_list ) ) ,
10
8
choice (
11
- ';' ,
12
- field ( "body" , $ . block_statement ) ,
13
- field ( "asm_body" , $ . asm_function_body )
9
+ seq (
10
+ field ( "arguments" , $ . parameter_list ) ,
11
+ field ( "specifiers" , optional ( $ . specifiers_list ) ) ,
12
+ choice (
13
+ field ( "body" , $ . block_statement ) ,
14
+ field ( "asm_body" , $ . asm_function_body )
15
+ )
16
+ ) ,
17
+ seq (
18
+ field ( "arguments" , $ . parameter_list_relaxed ) ,
19
+ field ( "specifiers" , optional ( $ . specifiers_list ) ) ,
20
+ ';' ,
21
+ )
14
22
)
15
23
) ,
16
24
17
- function_name : $ => / ( ` .* ` ) | ( ( \. | ~ ) ? ( ( [ $ a - z A - Z _ ] ( \w | [ ' ? : $ ] ) + ) | ( [ a - z A - Z $ ] ) ) ) / ,
25
+ function_name : $ => / ( ` .* ` ) | ( ( \. | ~ ) ? ( ( [ $ % a - z A - Z _ ] ( \w | [ ' ? : $ % ] ) + ) | ( [ a - z A - Z % $ ] ) ) ) / ,
18
26
19
27
impure : $ => "impure" ,
20
28
inline : $ => choice ( "inline" , "inline_ref" ) ,
@@ -23,8 +31,8 @@ module.exports = {
23
31
) ) ,
24
32
25
33
specifiers_list : $ => choice (
26
- seq ( $ . impure , optional ( $ . inline ) , optional ( $ . method_id ) ) ,
27
- seq ( $ . inline , optional ( $ . method_id ) ) ,
34
+ seq ( $ . impure , optional ( $ . inline ) , optional ( $ . method_id ) ) ,
35
+ seq ( $ . inline , optional ( $ . method_id ) ) ,
28
36
$ . method_id
29
37
) ,
30
38
@@ -34,17 +42,31 @@ module.exports = {
34
42
"->"
35
43
) ,
36
44
37
- parameter_list : $ => seq (
45
+ parameter_list : $ => prec ( 1 , seq (
38
46
'(' ,
39
47
commaSep ( $ . parameter_declaration ) ,
40
48
')'
49
+ ) ) ,
50
+
51
+ parameter_list_relaxed : $ => seq (
52
+ '(' ,
53
+ commaSep (
54
+ choice (
55
+ $ . parameter_declaration ,
56
+ field ( 'name' , $ . identifier ) ,
57
+ $ . underscore
58
+ )
59
+ ) ,
60
+ ')'
41
61
) ,
42
62
43
63
parameter_declaration : $ => seq (
44
- optional ( field ( 'type' , $ . _type ) ) ,
45
- choice (
46
- field ( 'name' , $ . identifier ) ,
47
- $ . underscore
64
+ field ( 'type' , $ . _type ) ,
65
+ optional (
66
+ choice (
67
+ field ( 'name' , $ . identifier ) ,
68
+ $ . underscore
69
+ )
48
70
)
49
71
) ,
50
72
0 commit comments