From ee2b50bac0be95afbfcf8faa746b9b63960444db Mon Sep 17 00:00:00 2001 From: Markus Freitag Date: Mon, 30 Oct 2023 21:28:01 +0100 Subject: [PATCH 01/11] implement elseif blocks --- ast/if.go | 19 +++++++++++++++---- evaluator/if.go | 19 ++++++++++--------- parser/block.go | 3 ++- parser/if.go | 26 ++++++++++++++++++++++---- token/token.go | 2 ++ 5 files changed, 51 insertions(+), 18 deletions(-) diff --git a/ast/if.go b/ast/if.go index 1415f45..76ec90f 100644 --- a/ast/if.go +++ b/ast/if.go @@ -6,10 +6,14 @@ import ( "github.com/flipez/rocket-lang/token" ) -type If struct { - Token token.Token // the if token +type ConditionConsequencePair struct { Condition Expression Consequence *Block +} + +type If struct { + Token token.Token // the if token + ConConPairs []ConditionConsequencePair Alternative *Block } @@ -18,9 +22,16 @@ func (ie *If) String() string { var out bytes.Buffer out.WriteString("if (") - out.WriteString(ie.Condition.String()) + out.WriteString(ie.ConConPairs[0].Condition.String()) out.WriteString(")\n ") - out.WriteString(ie.Consequence.String()) + out.WriteString(ie.ConConPairs[0].Consequence.String()) + + for _, pair := range ie.ConConPairs[1:] { + out.WriteString("ef (") + out.WriteString(pair.Condition.String()) + out.WriteString(")\n ") + out.WriteString(pair.Consequence.String()) + } if ie.Alternative != nil { out.WriteString("\nelse\n ") diff --git a/evaluator/if.go b/evaluator/if.go index 9f7f25b..db54067 100644 --- a/evaluator/if.go +++ b/evaluator/if.go @@ -6,16 +6,17 @@ import ( ) func evalIf(ie *ast.If, env *object.Environment) object.Object { - condition := Eval(ie.Condition, env) - - if object.IsError(condition) { - return condition + for _, pair := range ie.ConConPairs { + condition := Eval(pair.Condition, env) + if object.IsError(condition) { + return condition + } + if object.IsTruthy(condition) { + return Eval(pair.Consequence, env) + } } - if object.IsTruthy(condition) { - return Eval(ie.Consequence, env) - } else if ie.Alternative != nil { + if ie.Alternative != nil { return Eval(ie.Alternative, env) - } else { - return object.NIL } + return object.NIL } diff --git a/parser/block.go b/parser/block.go index 7b8a317..4813bcb 100644 --- a/parser/block.go +++ b/parser/block.go @@ -11,7 +11,8 @@ func (p *Parser) parseBlock() *ast.Block { p.nextToken() - for !p.curTokenIs(token.RBRACE) && !p.curTokenIs(token.EOF) && !p.curTokenIs(token.END) && !p.curTokenIs(token.ELSE) && !p.curTokenIs(token.RESCUE) { + for !p.curTokenIs(token.RBRACE) && !p.curTokenIs(token.EOF) && !p.curTokenIs(token.END) && !p.curTokenIs(token.ELSE) && !p.curTokenIs(token.EF) && !p.curTokenIs(token.RESCUE) { + stmt := p.parseStatement() if stmt != nil { block.Statements = append(block.Statements, stmt) diff --git a/parser/if.go b/parser/if.go index 33a3f75..bb9cf4f 100644 --- a/parser/if.go +++ b/parser/if.go @@ -6,23 +6,41 @@ import ( ) func (p *Parser) parseIf() ast.Expression { - expression := &ast.If{Token: p.curToken} + expression := &ast.If{Token: p.curToken, ConConPairs: make([]ast.ConditionConsequencePair, 1)} if !p.expectPeek(token.LPAREN) { return nil } p.nextToken() - expression.Condition = p.parseExpression(LOWEST) + expression.ConConPairs[0].Condition = p.parseExpression(LOWEST) if !p.expectPeek(token.RPAREN) { return nil } - expression.Consequence = p.parseBlock() + expression.ConConPairs[0].Consequence = p.parseBlock() - if p.curTokenIs(token.ELSE) { + for p.curTokenIs(token.EF) { + + if !p.expectPeek(token.LPAREN) { + return nil + } + p.nextToken() + + var pair ast.ConditionConsequencePair + pair.Condition = p.parseExpression(LOWEST) + + if !p.expectPeek(token.RPAREN) { + return nil + } + pair.Consequence = p.parseBlock() + expression.ConConPairs = append(expression.ConConPairs, pair) + } + + if p.curTokenIs(token.ELSE) { expression.Alternative = p.parseBlock() } + return expression } diff --git a/token/token.go b/token/token.go index 95b687b..e6b83e9 100644 --- a/token/token.go +++ b/token/token.go @@ -56,6 +56,7 @@ const ( TRUE = "TRUE" FALSE = "FALSE" IF = "IF" + EF = "EF" ELSE = "ELSE" END = "END" RETURN = "RETURN" @@ -90,6 +91,7 @@ var keywords = map[string]TokenType{ "true": TRUE, "false": FALSE, "if": IF, + "ef": EF, "end": END, "else": ELSE, "return": RETURN, From c297a66560c7397dc7ddc7d3e721053028de64ad Mon Sep 17 00:00:00 2001 From: Markus Freitag Date: Mon, 30 Oct 2023 21:28:33 +0100 Subject: [PATCH 02/11] tests: add multiple if/elseif/else examples --- tests/if.expected | 2 ++ tests/if.rl | 3 +++ tests/ifef.expected | 3 +++ tests/ifef.rl | 10 ++++++++++ tests/ifefefelse.expected | 5 +++++ tests/ifefefelse.rl | 14 ++++++++++++++ tests/ifefelse.expected | 4 ++++ tests/ifefelse.rl | 12 ++++++++++++ tests/ifelse.expected | 3 +++ tests/ifelse.rl | 10 ++++++++++ 10 files changed, 66 insertions(+) create mode 100644 tests/if.expected create mode 100644 tests/if.rl create mode 100644 tests/ifef.expected create mode 100644 tests/ifef.rl create mode 100644 tests/ifefefelse.expected create mode 100644 tests/ifefefelse.rl create mode 100644 tests/ifefelse.expected create mode 100644 tests/ifefelse.rl create mode 100644 tests/ifelse.expected create mode 100644 tests/ifelse.rl diff --git a/tests/if.expected b/tests/if.expected new file mode 100644 index 0000000..3e312ad --- /dev/null +++ b/tests/if.expected @@ -0,0 +1,2 @@ +"single if" +nil diff --git a/tests/if.rl b/tests/if.rl new file mode 100644 index 0000000..9da97b9 --- /dev/null +++ b/tests/if.rl @@ -0,0 +1,3 @@ +if (true) + puts("single if") +end diff --git a/tests/ifef.expected b/tests/ifef.expected new file mode 100644 index 0000000..8dffdb0 --- /dev/null +++ b/tests/ifef.expected @@ -0,0 +1,3 @@ +"if/ef: if block" +"if/ef: ef block" +nil diff --git a/tests/ifef.rl b/tests/ifef.rl new file mode 100644 index 0000000..c70417f --- /dev/null +++ b/tests/ifef.rl @@ -0,0 +1,10 @@ +i = 0 +while (i<2) + if (i==0) + puts("if/ef: if block") + ef (i==1) + puts("if/ef: ef block") + end + + i = i+1 +end diff --git a/tests/ifefefelse.expected b/tests/ifefefelse.expected new file mode 100644 index 0000000..ba44723 --- /dev/null +++ b/tests/ifefefelse.expected @@ -0,0 +1,5 @@ +"if/ef/el: if block" +"if/ef/ef/el: first ef block" +"if/ef/ef/el: second ef block" +"if/ef/else: else block" +nil diff --git a/tests/ifefefelse.rl b/tests/ifefefelse.rl new file mode 100644 index 0000000..e18164b --- /dev/null +++ b/tests/ifefefelse.rl @@ -0,0 +1,14 @@ +i = 0 +while (i<4) + if (i==0) + puts("if/ef/el: if block") + ef (i==1) + puts("if/ef/ef/el: first ef block") + ef (i==2) + puts("if/ef/ef/el: second ef block") + else + puts("if/ef/else: else block") + end + + i = i+1 +end diff --git a/tests/ifefelse.expected b/tests/ifefelse.expected new file mode 100644 index 0000000..d86978e --- /dev/null +++ b/tests/ifefelse.expected @@ -0,0 +1,4 @@ +"if/ef/el: if block" +"if/ef/el: ef block" +"if/ef/el: else block" +nil diff --git a/tests/ifefelse.rl b/tests/ifefelse.rl new file mode 100644 index 0000000..f02470f --- /dev/null +++ b/tests/ifefelse.rl @@ -0,0 +1,12 @@ +i = 0 +while (i<3) + if (i==0) + puts("if/ef/el: if block") + ef (i==1) + puts("if/ef/el: ef block") + else + puts("if/ef/el: else block") + end + + i = i+1 +end diff --git a/tests/ifelse.expected b/tests/ifelse.expected new file mode 100644 index 0000000..f131044 --- /dev/null +++ b/tests/ifelse.expected @@ -0,0 +1,3 @@ +"if/else: if block" +"if/else: else block" +nil diff --git a/tests/ifelse.rl b/tests/ifelse.rl new file mode 100644 index 0000000..0b0ba2d --- /dev/null +++ b/tests/ifelse.rl @@ -0,0 +1,10 @@ +i = 0 +while (i<2) + if (i==0) + puts("if/else: if block") + else + puts("if/else: else block") + end + + i = i+1 +end From 6524c02b72d5ff3e607501fb4804d989ed02332c Mon Sep 17 00:00:00 2001 From: Markus Freitag Date: Tue, 31 Oct 2023 19:01:41 +0100 Subject: [PATCH 03/11] rename ef into elif --- parser/block.go | 2 +- parser/if.go | 2 +- token/token.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/parser/block.go b/parser/block.go index 4813bcb..4f535a8 100644 --- a/parser/block.go +++ b/parser/block.go @@ -11,7 +11,7 @@ func (p *Parser) parseBlock() *ast.Block { p.nextToken() - for !p.curTokenIs(token.RBRACE) && !p.curTokenIs(token.EOF) && !p.curTokenIs(token.END) && !p.curTokenIs(token.ELSE) && !p.curTokenIs(token.EF) && !p.curTokenIs(token.RESCUE) { + for !p.curTokenIs(token.RBRACE) && !p.curTokenIs(token.EOF) && !p.curTokenIs(token.END) && !p.curTokenIs(token.ELSE) && !p.curTokenIs(token.ELIF) && !p.curTokenIs(token.RESCUE) { stmt := p.parseStatement() if stmt != nil { diff --git a/parser/if.go b/parser/if.go index bb9cf4f..77028a5 100644 --- a/parser/if.go +++ b/parser/if.go @@ -20,7 +20,7 @@ func (p *Parser) parseIf() ast.Expression { expression.ConConPairs[0].Consequence = p.parseBlock() - for p.curTokenIs(token.EF) { + for p.curTokenIs(token.ELIF) { if !p.expectPeek(token.LPAREN) { return nil diff --git a/token/token.go b/token/token.go index e6b83e9..c346a7b 100644 --- a/token/token.go +++ b/token/token.go @@ -56,7 +56,7 @@ const ( TRUE = "TRUE" FALSE = "FALSE" IF = "IF" - EF = "EF" + ELIF = "ELIF" ELSE = "ELSE" END = "END" RETURN = "RETURN" @@ -91,7 +91,7 @@ var keywords = map[string]TokenType{ "true": TRUE, "false": FALSE, "if": IF, - "ef": EF, + "elif": ELIF, "end": END, "else": ELSE, "return": RETURN, From 350c1d8e61ec1dd24b5f4ad78d6a4edaa5af07b5 Mon Sep 17 00:00:00 2001 From: Markus Freitag Date: Tue, 31 Oct 2023 19:15:52 +0100 Subject: [PATCH 04/11] follow up --- ast/if.go | 2 +- tests/ifef.expected | 3 --- tests/ifef.rl | 10 ---------- tests/ifefefelse.expected | 5 ----- tests/ifefefelse.rl | 14 -------------- tests/ifefelse.expected | 4 ---- tests/ifefelse.rl | 12 ------------ 7 files changed, 1 insertion(+), 49 deletions(-) delete mode 100644 tests/ifef.expected delete mode 100644 tests/ifef.rl delete mode 100644 tests/ifefefelse.expected delete mode 100644 tests/ifefefelse.rl delete mode 100644 tests/ifefelse.expected delete mode 100644 tests/ifefelse.rl diff --git a/ast/if.go b/ast/if.go index 76ec90f..15b2aae 100644 --- a/ast/if.go +++ b/ast/if.go @@ -27,7 +27,7 @@ func (ie *If) String() string { out.WriteString(ie.ConConPairs[0].Consequence.String()) for _, pair := range ie.ConConPairs[1:] { - out.WriteString("ef (") + out.WriteString("elif (") out.WriteString(pair.Condition.String()) out.WriteString(")\n ") out.WriteString(pair.Consequence.String()) diff --git a/tests/ifef.expected b/tests/ifef.expected deleted file mode 100644 index 8dffdb0..0000000 --- a/tests/ifef.expected +++ /dev/null @@ -1,3 +0,0 @@ -"if/ef: if block" -"if/ef: ef block" -nil diff --git a/tests/ifef.rl b/tests/ifef.rl deleted file mode 100644 index c70417f..0000000 --- a/tests/ifef.rl +++ /dev/null @@ -1,10 +0,0 @@ -i = 0 -while (i<2) - if (i==0) - puts("if/ef: if block") - ef (i==1) - puts("if/ef: ef block") - end - - i = i+1 -end diff --git a/tests/ifefefelse.expected b/tests/ifefefelse.expected deleted file mode 100644 index ba44723..0000000 --- a/tests/ifefefelse.expected +++ /dev/null @@ -1,5 +0,0 @@ -"if/ef/el: if block" -"if/ef/ef/el: first ef block" -"if/ef/ef/el: second ef block" -"if/ef/else: else block" -nil diff --git a/tests/ifefefelse.rl b/tests/ifefefelse.rl deleted file mode 100644 index e18164b..0000000 --- a/tests/ifefefelse.rl +++ /dev/null @@ -1,14 +0,0 @@ -i = 0 -while (i<4) - if (i==0) - puts("if/ef/el: if block") - ef (i==1) - puts("if/ef/ef/el: first ef block") - ef (i==2) - puts("if/ef/ef/el: second ef block") - else - puts("if/ef/else: else block") - end - - i = i+1 -end diff --git a/tests/ifefelse.expected b/tests/ifefelse.expected deleted file mode 100644 index d86978e..0000000 --- a/tests/ifefelse.expected +++ /dev/null @@ -1,4 +0,0 @@ -"if/ef/el: if block" -"if/ef/el: ef block" -"if/ef/el: else block" -nil diff --git a/tests/ifefelse.rl b/tests/ifefelse.rl deleted file mode 100644 index f02470f..0000000 --- a/tests/ifefelse.rl +++ /dev/null @@ -1,12 +0,0 @@ -i = 0 -while (i<3) - if (i==0) - puts("if/ef/el: if block") - ef (i==1) - puts("if/ef/el: ef block") - else - puts("if/ef/el: else block") - end - - i = i+1 -end From eb1ec73051737373161120fd96e23ba2f320d604 Mon Sep 17 00:00:00 2001 From: Markus Freitag Date: Tue, 31 Oct 2023 19:17:40 +0100 Subject: [PATCH 05/11] follow up --- tests/ifelif.expected | 3 +++ tests/ifelif.rl | 10 ++++++++++ tests/ifelifelifelse.expected | 5 +++++ tests/ifelifelifelse.rl | 14 ++++++++++++++ tests/ifelifelse.expected | 4 ++++ tests/ifelifelse.rl | 12 ++++++++++++ 6 files changed, 48 insertions(+) create mode 100644 tests/ifelif.expected create mode 100644 tests/ifelif.rl create mode 100644 tests/ifelifelifelse.expected create mode 100644 tests/ifelifelifelse.rl create mode 100644 tests/ifelifelse.expected create mode 100644 tests/ifelifelse.rl diff --git a/tests/ifelif.expected b/tests/ifelif.expected new file mode 100644 index 0000000..8dffdb0 --- /dev/null +++ b/tests/ifelif.expected @@ -0,0 +1,3 @@ +"if/ef: if block" +"if/ef: ef block" +nil diff --git a/tests/ifelif.rl b/tests/ifelif.rl new file mode 100644 index 0000000..0a3395e --- /dev/null +++ b/tests/ifelif.rl @@ -0,0 +1,10 @@ +i = 0 +while (i<2) + if (i==0) + puts("if/elif: if block") + elif (i==1) + puts("if/elif: elif block") + end + + i = i+1 +end diff --git a/tests/ifelifelifelse.expected b/tests/ifelifelifelse.expected new file mode 100644 index 0000000..ba44723 --- /dev/null +++ b/tests/ifelifelifelse.expected @@ -0,0 +1,5 @@ +"if/ef/el: if block" +"if/ef/ef/el: first ef block" +"if/ef/ef/el: second ef block" +"if/ef/else: else block" +nil diff --git a/tests/ifelifelifelse.rl b/tests/ifelifelifelse.rl new file mode 100644 index 0000000..0bccff2 --- /dev/null +++ b/tests/ifelifelifelse.rl @@ -0,0 +1,14 @@ +i = 0 +while (i<4) + if (i==0) + puts("if/elif/el: if block") + elif (i==1) + puts("if/elif/elif/el: first elif block") + elif (i==2) + puts("if/elif/elif/el: second elif block") + else + puts("if/elif/else: else block") + end + + i = i+1 +end diff --git a/tests/ifelifelse.expected b/tests/ifelifelse.expected new file mode 100644 index 0000000..d86978e --- /dev/null +++ b/tests/ifelifelse.expected @@ -0,0 +1,4 @@ +"if/ef/el: if block" +"if/ef/el: ef block" +"if/ef/el: else block" +nil diff --git a/tests/ifelifelse.rl b/tests/ifelifelse.rl new file mode 100644 index 0000000..21d863f --- /dev/null +++ b/tests/ifelifelse.rl @@ -0,0 +1,12 @@ +i = 0 +while (i<3) + if (i==0) + puts("if/elif/el: if block") + elif (i==1) + puts("if/elif/el: elif block") + else + puts("if/elif/el: else block") + end + + i = i+1 +end From 7ca9f3d96db0a20af456383b8b66999eb7ee2d56 Mon Sep 17 00:00:00 2001 From: Markus Freitag Date: Tue, 31 Oct 2023 19:22:03 +0100 Subject: [PATCH 06/11] follow up --- tests/ifelif.expected | 4 ++-- tests/ifelifelifelse.expected | 8 ++++---- tests/ifelifelse.expected | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/ifelif.expected b/tests/ifelif.expected index 8dffdb0..218b02f 100644 --- a/tests/ifelif.expected +++ b/tests/ifelif.expected @@ -1,3 +1,3 @@ -"if/ef: if block" -"if/ef: ef block" +"if/elif: if block" +"if/elif: elif block" nil diff --git a/tests/ifelifelifelse.expected b/tests/ifelifelifelse.expected index ba44723..2f98d16 100644 --- a/tests/ifelifelifelse.expected +++ b/tests/ifelifelifelse.expected @@ -1,5 +1,5 @@ -"if/ef/el: if block" -"if/ef/ef/el: first ef block" -"if/ef/ef/el: second ef block" -"if/ef/else: else block" +"if/elif/el: if block" +"if/elif/elif/el: first elif block" +"if/elif/elif/el: second elif block" +"if/elif/else: else block" nil diff --git a/tests/ifelifelse.expected b/tests/ifelifelse.expected index d86978e..2b102e8 100644 --- a/tests/ifelifelse.expected +++ b/tests/ifelifelse.expected @@ -1,4 +1,4 @@ -"if/ef/el: if block" -"if/ef/el: ef block" -"if/ef/el: else block" +"if/elif/el: if block" +"if/elif/el: elif block" +"if/elif/el: else block" nil From 1423a9ed3be60a030cfb7b0f850a7517de782a02 Mon Sep 17 00:00:00 2001 From: Markus Freitag Date: Tue, 31 Oct 2023 19:27:59 +0100 Subject: [PATCH 07/11] follow up --- parser/parser_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/parser/parser_test.go b/parser/parser_test.go index e0b05d5..fb95d99 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -443,17 +443,17 @@ func TestIfExpression(t *testing.T) { t.Fatalf("stmt.Expression is not ast.IfExpression. got=%T", stmt.Expression) } - if !testInfix(t, exp.Condition, "x", "<", "y") { + if !testInfix(t, exp.ConConPairs[0].Condition, "x", "<", "y") { return } - if len(exp.Consequence.Statements) != 1 { + if len(exp.ConConPairs[0].Consequence.Statements) != 1 { t.Errorf("consequence is not 1 statements. got=%d\n", len(program.Statements)) } - consequence, ok := exp.Consequence.Statements[0].(*ast.ExpressionStatement) + consequence, ok := exp.ConConPairs[0].Consequence.Statements[0].(*ast.ExpressionStatement) if !ok { - t.Fatalf("Statements[0] is not ast.ExpressionStatement. got=%T", exp.Consequence.Statements[0]) + t.Fatalf("Statements[0] is not ast.ExpressionStatement. got=%T", exp.ConConPairs[0].Consequence.Statements[0]) } if !testIdentifier(t, consequence.Expression, "x") { From dce7cd567380006bb32969ea7ed18f745e7bf71a Mon Sep 17 00:00:00 2001 From: Markus Freitag Date: Mon, 27 Nov 2023 20:53:54 +0100 Subject: [PATCH 08/11] ast: extend if/elif/else inspecting test --- ast/ast_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ast/ast_test.go b/ast/ast_test.go index 32fef12..352bbdd 100644 --- a/ast/ast_test.go +++ b/ast/ast_test.go @@ -33,8 +33,8 @@ func TestString(t *testing.T) { "foreach i, e in [1, 2, 3] \n puts(i)\nend", }, { - "if (true)\n return (true)\nelse\n puts(false)\nend", - "if (true)\n return (true)\nelse\n puts(false)\nend", + "if (true)\n return (true)\nelif (true)\n return (true)\nelse\n puts(false)\nend", + "if (true)\n return (true)\nelif (true)\n return (true)\nelse\n puts(false)\nend", }, { "while (true)\n puts(true)\nend", From 87fbfd23a9cbdde448312703b7907c748f0d7400 Mon Sep 17 00:00:00 2001 From: Markus Freitag Date: Mon, 27 Nov 2023 21:34:01 +0100 Subject: [PATCH 09/11] follow up --- ast/if.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ast/if.go b/ast/if.go index 15b2aae..5c73d26 100644 --- a/ast/if.go +++ b/ast/if.go @@ -27,7 +27,7 @@ func (ie *If) String() string { out.WriteString(ie.ConConPairs[0].Consequence.String()) for _, pair := range ie.ConConPairs[1:] { - out.WriteString("elif (") + out.WriteString("\nelif (") out.WriteString(pair.Condition.String()) out.WriteString(")\n ") out.WriteString(pair.Consequence.String()) From 6e28eff296844c9c845414907a27fc7791140029 Mon Sep 17 00:00:00 2001 From: Flipez Date: Mon, 27 Nov 2023 22:15:49 +0100 Subject: [PATCH 10/11] docs(if): add documentation for if/elif/else Signed-off-by: Flipez --- docs/docs/control_expressions/if.md | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/docs/docs/control_expressions/if.md b/docs/docs/control_expressions/if.md index 02ecd12..5c268f8 100644 --- a/docs/docs/control_expressions/if.md +++ b/docs/docs/control_expressions/if.md @@ -1,19 +1,26 @@ --- -title: "If" +title: "If / elif / else" menu: docs: parent: "controls" --- +import CodeBlockSimple from '@site/components/CodeBlockSimple' + # If With `if` and `else` keywords the flow of a program can be controlled. -```js -🚀 > if (a.type() == "STRING") - puts("is a string") + + +# Elif +`elif` allows providing of an additional consequence check after `if` and before evaluating the alternative provided by `else`. There is no limit on how many `elif` statements can be used. -// which prints -is a string -``` \ No newline at end of file + \ No newline at end of file From 5c308dff41ca02daaddd1285c4d838ec1a25a851 Mon Sep 17 00:00:00 2001 From: Flipez Date: Mon, 27 Nov 2023 22:20:16 +0100 Subject: [PATCH 11/11] docs(if): add documentation for if/elif/else Signed-off-by: Flipez --- docs/docs/control_expressions/if.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/docs/control_expressions/if.md b/docs/docs/control_expressions/if.md index 5c268f8..2111508 100644 --- a/docs/docs/control_expressions/if.md +++ b/docs/docs/control_expressions/if.md @@ -9,7 +9,8 @@ import CodeBlockSimple from '@site/components/CodeBlockSimple' # If With `if` and `else` keywords the flow of a program can be controlled. - # Elif `elif` allows providing of an additional consequence check after `if` and before evaluating the alternative provided by `else`. There is no limit on how many `elif` statements can be used. - \ No newline at end of file +puts("i have no idea") +end' output='is a string' /> \ No newline at end of file