Add support for defaults to bytecode, compiler and VM

This commit is contained in:
Daniel Watkins
2018-08-27 22:16:51 -04:00
parent 0787115d07
commit 2cecd362fe
9 changed files with 113 additions and 25 deletions

View File

@@ -308,12 +308,16 @@ FuncDef: ast::LocatedStatement = {
},
};
Parameters: Vec<String> = {
Parameters: Vec<(String, Option<ast::Expression>)> = {
"(" <a: TypedArgsList> ")" => a,
};
TypedArgsList: Vec<String> = {
<a: Comma<Identifier>> => a,
// parameters are (String, None), kwargs are (String, Some(Test)) where Test is
// the default
TypedArgsList: Vec<(String, Option<ast::Expression>)> = {
<a: Comma<Identifier>> => {
a.iter().map(|param| (param.clone(), None)).collect()
},
};
ClassDef: ast::LocatedStatement = {