Skip to content

Commit

Permalink
grammar: Prototypes (will only be externally defined, so not sure this
Browse files Browse the repository at this point in the history
is the best name at the moment)
  • Loading branch information
obiwac committed Sep 10, 2024
1 parent 216104a commit 50337ab
Show file tree
Hide file tree
Showing 4 changed files with 3,930 additions and 3,259 deletions.
11 changes: 11 additions & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module.exports = grammar({
$.var_decl,
$.function_declaration,
$.class_declaration,
$.proto,
$.return,
),

Expand All @@ -79,6 +80,16 @@ module.exports = grammar({
),
),

proto: $ =>
prec.right(
seq(
"proto",
field("name", choice($.identifier, $.overloadable_operator)),
optional(seq("(", optional(field("params", $.param_list)), ")")),
optional(seq("->", field("ret_type", $.type))),
),
),

function_expression: $ =>
seq("fn", optional(seq("(", optional(field("params", $.param_list)), ")")), field("body", $.statement)),

Expand Down
96 changes: 96 additions & 0 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 50337ab

Please sign in to comment.