Trying out a thing

This commit is contained in:
Greg Shuflin 2024-04-21 03:08:05 -07:00
parent 8cde20641b
commit f33195ab28
2 changed files with 35 additions and 1 deletions

View File

@ -6,9 +6,33 @@ module.exports = grammar({
_definition: $ => choice(
$.function_definition
//TODO others
)
),
function_definition: $ => seq(
"fn",
$.identifier,
$.parameter_list,
$._type,
$.block,
),
parameter_list: $ => seq("(", /* TODO */ ")"),
block: $ => seq(
"{",
repeat($._statement),
"}"
),
_statement: $ => choice(
$._return_statement
),
_return_statement: $ => seq("return", $._expression, ";"),
_expression: $ => choice($.identifier),
_type: $ => "bool",
identifier: $ => /[a-z]+/,
}
});

View File

@ -7,3 +7,13 @@ hello
----
(source_file)
=====
Another
====
fn main() { }
------
()