diff --git a/src/lexer.rs b/src/lexer.rs index 6d22e1c..e442b0d 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -293,15 +293,9 @@ impl Lexer { kind: Kind::Local, }), ))), - func.clone() - .ignore_then(dotted) + func.ignore_then(dotted) .map(|(prefix, kind, name)| TagType::Func { prefix, name, kind }), - choice(( - expr.clone() - .then_ignore(func) - .map(|(prefix, kind, name)| TagType::Func { prefix, name, kind }), - expr.map(|(prefix, kind, name)| TagType::Expr { prefix, name, kind }), - )), + expr.map(|(prefix, kind, name)| TagType::Expr { prefix, name, kind }), keyword("return") .ignore_then(ident().padded()) .then_ignore(end()) diff --git a/src/parser/tags/func.rs b/src/parser/tags/func.rs index 0128661..b76eae6 100644 --- a/src/parser/tags/func.rs +++ b/src/parser/tags/func.rs @@ -73,7 +73,10 @@ impl_parse!(Func, { .then(Return::parse().repeated()) .then(See::parse()) .then(Usage::parse().or_not()) - .then(select! { TagType::Func { prefix, name, kind } => (prefix, name, kind) }) + .then(select! { + TagType::Func { prefix, name, kind } => (prefix, name, kind), + TagType::Expr { prefix, name, kind } => (prefix, name, kind), + }) .map( |(((((desc, params), returns), see), usage), (prefix, name, kind))| Self { name, diff --git a/tests/basic.rs b/tests/basic.rs index 873fca9..5b99792 100644 --- a/tests/basic.rs +++ b/tests/basic.rs @@ -225,6 +225,17 @@ fn functions() { return (U.mul(this, that) / U.sum(that, this)), (U.sum(this, that) * U.sub(that, this)) end + local function wrap(arg1, arg2) + return function(...) + -- Do work + end + end + + ---Wrapped function + ---@param foo string + ---@param bar integer + U.exported_fn = wrap('a', 'b') + return U "#; @@ -282,6 +293,14 @@ U.magical({this}, {that}) *U.magical* |U.sub| +U.exported_fn({foo}, {bar}) *U.exported_fn* + Wrapped function + + Parameters: ~ + {foo} (string) + {bar} (integer) + + " ) }