Skip to content

Commit ca4afaa

Browse files
authored
Merge pull request #160 from brandonspark/toplevel-methods
2 parents 38be6ec + 9997f02 commit ca4afaa

File tree

6 files changed

+52072
-44283
lines changed

6 files changed

+52072
-44283
lines changed

grammar.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ module.exports = grammar({
7676
word: $ => $.identifier,
7777

7878
rules: {
79-
program: $ => repeat($.statement),
79+
program: $ => repeat($._toplevel_statement),
80+
81+
_toplevel_statement: $ => choice(
82+
$.statement,
83+
$.method_declaration,
84+
),
8085

8186
// Literals
8287

src/grammar.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,22 @@
66
"type": "REPEAT",
77
"content": {
88
"type": "SYMBOL",
9-
"name": "statement"
9+
"name": "_toplevel_statement"
1010
}
1111
},
12+
"_toplevel_statement": {
13+
"type": "CHOICE",
14+
"members": [
15+
{
16+
"type": "SYMBOL",
17+
"name": "statement"
18+
},
19+
{
20+
"type": "SYMBOL",
21+
"name": "method_declaration"
22+
}
23+
]
24+
},
1225
"_literal": {
1326
"type": "CHOICE",
1427
"members": [

src/node-types.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2941,6 +2941,10 @@
29412941
"multiple": true,
29422942
"required": false,
29432943
"types": [
2944+
{
2945+
"type": "method_declaration",
2946+
"named": true
2947+
},
29442948
{
29452949
"type": "statement",
29462950
"named": true

0 commit comments

Comments
 (0)