Parse function params
This commit is contained in:
parent
044d2b9d25
commit
5ed3edd433
@ -1,4 +1,4 @@
|
|||||||
function max ()
|
function max (a, b)
|
||||||
local m = a
|
local m = a
|
||||||
-- if b > a then
|
-- if b > a then
|
||||||
-- m = b
|
-- m = b
|
||||||
|
|||||||
10
src/ast.rs
10
src/ast.rs
@ -142,7 +142,15 @@ impl Parse for Function {
|
|||||||
let name = stream.parse::<Node<String>>().ok();
|
let name = stream.parse::<Node<String>>().ok();
|
||||||
stream.expect(Token::Symbol('('))?;
|
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(')'))?;
|
stream.expect(Token::Symbol(')'))?;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user