From 65c608e088544abf3c9a1171a80457b862700265 Mon Sep 17 00:00:00 2001 From: William Bell Date: Tue, 14 Nov 2023 20:27:17 +0000 Subject: [PATCH] allow single line if statements --- src/ifstatement.go | 1 + src/trycatch.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ifstatement.go b/src/ifstatement.go index 960da3a..42d143a 100644 --- a/src/ifstatement.go +++ b/src/ifstatement.go @@ -32,6 +32,7 @@ func parseIfStatement(code UNPARSEcode, index int, codeline []UNPARSEcode) (ifst conditions := []statement{} var ELSE any i := index + codeline[i] = code for i < len(codeline) && (elseifstatmentCompile.MatchString(codeline[i].code) || i == index) { trimmed := strings.TrimSpace(codeline[i].code) trimmed = strings.TrimSpace(trimmed[strings.Index(trimmed, "("):]) diff --git a/src/trycatch.go b/src/trycatch.go index fc13457..c7aef09 100644 --- a/src/trycatch.go +++ b/src/trycatch.go @@ -23,7 +23,7 @@ func isTryCatch(code UNPARSEcode) bool { func parseTryCatch(code UNPARSEcode, index int, codelines []UNPARSEcode) (TryCatch, bool, ArErr, int) { trytrimmed := strings.TrimSpace(code.code) totalIndex := 0 - tryparsed, worked, err, i := translateVal(UNPARSEcode{trytrimmed[4:], code.realcode, code.line, code.path}, index, codelines, 2) + tryparsed, worked, err, i := translateVal(UNPARSEcode{trytrimmed[4:], code.realcode, code.line, code.path}, index, codelines, 3) if !worked { return TryCatch{}, false, err, i } @@ -40,7 +40,7 @@ func parseTryCatch(code UNPARSEcode, index int, codelines []UNPARSEcode) (TryCat catchbracketSplit := strings.SplitN(catchtrimmed, ")", 2) errorName := strings.TrimSpace(strings.TrimSpace(catchbracketSplit[0])[1:]) errcode := catchbracketSplit[1] - catchparsed, worked, err, i := translateVal(UNPARSEcode{errcode, code.realcode, code.line, code.path}, index+totalIndex, codelines, 2) + catchparsed, worked, err, i := translateVal(UNPARSEcode{errcode, code.realcode, code.line, code.path}, index+totalIndex, codelines, 3) if !worked { return TryCatch{}, false, err, i }