From 5ed3edd4336e1568031e5a822ad19e39abaa51be Mon Sep 17 00:00:00 2001 From: Sofia Date: Sat, 14 Mar 2026 15:57:07 +0200 Subject: [PATCH] Parse function params --- examples/test.lua | 2 +- src/ast.rs | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/test.lua b/examples/test.lua index 027df47..d8a5243 100644 --- a/examples/test.lua +++ b/examples/test.lua @@ -1,4 +1,4 @@ -function max () +function max (a, b) local m = a -- if b > a then -- m = b diff --git a/src/ast.rs b/src/ast.rs index 3d46fa8..d8c238c 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -142,7 +142,15 @@ impl Parse for Function { let name = stream.parse::>().ok(); stream.expect(Token::Symbol('('))?; - let params = Vec::new(); + let mut params = Vec::new(); + + if let Ok(param) = stream.parse() { + params.push(param); + while stream.peek() == Some(Token::Symbol(',')) { + stream.next(); + params.push(stream.parse()?); + } + } stream.expect(Token::Symbol(')'))?;