Trying out a thing
This commit is contained in:
parent
8cde20641b
commit
f33195ab28
@ -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]+/,
|
||||
}
|
||||
});
|
||||
|
@ -7,3 +7,13 @@ hello
|
||||
----
|
||||
|
||||
(source_file)
|
||||
|
||||
|
||||
=====
|
||||
Another
|
||||
====
|
||||
|
||||
fn main() { }
|
||||
|
||||
------
|
||||
()
|
||||
|
Loading…
Reference in New Issue
Block a user