Parse named function definitions

This commit is contained in:
Joscha 2022-11-19 19:24:23 +01:00
parent ff3edf17e5
commit 0099277644
3 changed files with 95 additions and 9 deletions

View file

@ -4,7 +4,7 @@ use chumsky::prelude::*;
use crate::ast::{Expr, Var};
use super::basic::{ident, space, Error};
use super::basic::{ident, local, space, Error};
fn var_access(
expr: impl Parser<char, Expr, Error = Error> + Clone,
@ -25,9 +25,7 @@ fn var_access(
fn var_assign(
expr: impl Parser<char, Expr, Error = Error> + Clone,
) -> impl Parser<char, Var, Error = Error> + Clone {
let local = text::keyword("local").ignore_then(space()).or_not();
local
local()
.then_ignore(just('['))
.then(space())
.then(expr.clone())
@ -54,9 +52,7 @@ fn var_assign(
fn var_assign_ident(
expr: impl Parser<char, Expr, Error = Error> + Clone,
) -> impl Parser<char, Var, Error = Error> + Clone {
let local = text::keyword("local").ignore_then(space()).or_not();
local
local()
.then(ident())
.then(space())
.then_ignore(just('='))