Add declarations

main
trivernis 4 months ago
parent c44b5ef6c3
commit b5fa1c0efe
Signed by: Trivernis
GPG Key ID: 7E6D18B61C8D2F4B

@ -1,9 +1,10 @@
file = { "hello world" }
expr = { infix_expr | term }
statement = { decl }
decl = { "let" ~ #name = ident ~ #args = (ident)* ~ "=" ~ expr }
expr = { infix_expr | term }
term = _{ ident | literal | "(" ~ expr ~ ")" }
infix_expr = {
#lhs = term ~ operator ~ #rhs = expr
}

@ -1,5 +1,6 @@
mod infix_expressions;
mod literals;
mod statements;
use crate::parse;

@ -0,0 +1,19 @@
use pest::{consumes_to, parses_to};
use crate::{Rule, SnekParser};
#[test]
fn it_parses_assignments() {
parses_to!(parser: SnekParser, input: "let a = 1", rule: Rule::statement, tokens: [
statement(0, 9, [
decl(0, 9, [
ident(4, 5),
expr(8, 9, [
literal(8, 9, [
integer(8, 9)
]),
])
])
])
]);
}
Loading…
Cancel
Save