Skip to content

Commit

Permalink
multiple values can now be returned
Browse files Browse the repository at this point in the history
  • Loading branch information
Maiori44 committed Mar 19, 2022
1 parent 3811c6c commit 94e4f0c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,9 @@ pub fn CompileTokens(scope: usize, ctokens: Expression) -> String {
DO_BLOCK(code) => {
format!("{}end{}", CompileCodeBlock(scope, "do", code), IndentateIf(ctokens, scope))
}
RETURN_EXPR(expr) => {
if let Some(expr) = expr {
format!("return {};", CompileExpression(scope, None, expr))
RETURN_EXPR(exprs) => {
if let Some(exprs) = exprs {
format!("return {};", CompileExpressions(scope, None, exprs))
} else {
String::from("return;")
}
Expand Down
7 changes: 4 additions & 3 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pub enum ComplexToken {
CALL(Vec<Expression>),
EXPR(Expression),
DO_BLOCK(CodeBlock),
RETURN_EXPR(Option<Expression>),
RETURN_EXPR(Option<Vec<Expression>>),
CONTINUE_LOOP, BREAK_LOOP
}

Expand Down Expand Up @@ -1227,10 +1227,11 @@ pub fn ParseTokens(tokens: Vec<Token>, filename: String) -> Result<Expression, S
let expr = if i.advanceIf(SEMICOLON) {
None
} else {
Some(i.findExpression(0, 0, 0, 0, |t| {
Some(i.findExpressions(0, 0, 0, 0, |t| {
match t {
COMMA => CHECK_BUILD,
SEMICOLON => CHECK_ADVANCESTOP,
_ => CHECK_CONTINUE,
_ => CHECK_CONTINUE
}
})?)
};
Expand Down

0 comments on commit 94e4f0c

Please sign in to comment.