Add support for defaults to bytecode, compiler and VM

This commit is contained in:
Daniel Watkins committed 2018-08-29 08:58:20 -04:00
1 parent 0787115d07
commit 2cecd362fe
9 files changed
+113 -25

No files matched your search

+3 -3
View File
@@ -95,12 +95,12 @@ pub enum Statement {
ClassDef {
name: String,
body: Vec<LocatedStatement>,
args: Vec<String>,
args: Vec<(String, Option<Expression>)>,
// TODO: docstring: String,
},
FunctionDef {
name: String,
args: Vec<String>,
args: Vec<(String, Option<Expression>)>,
// docstring: String,
body: Vec<LocatedStatement>,
},
@@ -161,7 +161,7 @@ pub enum Expression {
name: String,
},
Lambda {
args: Vec<String>,
args: Vec<(String, Option<Expression>)>,
body: Box<Expression>,
},
True,
+7 -3
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 = {