mirror of
https://github.com/Open-Argon/argon-v3.git
synced 2025-12-06 00:46:07 +00:00
Fix indentation and translation errors in doWrap,
forLoop, ifStatement, and whileLoop functions. Also fix syntax error in broken_funcCall test file.
This commit is contained in:
@@ -42,7 +42,7 @@ func parseDoWrap(code UNPARSEcode, index int, codelines []UNPARSEcode) (any, boo
|
||||
for i := 0; i < len(codelines); {
|
||||
indent := len(codelines[i].code) - len(strings.TrimLeft(codelines[i].code, " "))
|
||||
if indent != setindent {
|
||||
return nil, false, ArErr{"Syntax Error", "invalid indent", i, code.path, codelines[i].code, true}, 1
|
||||
return nil, false, ArErr{"Syntax Error", "invalid indent", code.line, code.path, codelines[i].code, true}, 1
|
||||
}
|
||||
|
||||
val, _, err, step := translateVal(codelines[i], i, codelines, 3)
|
||||
@@ -57,9 +57,9 @@ func parseDoWrap(code UNPARSEcode, index int, codelines []UNPARSEcode) (any, boo
|
||||
|
||||
func runDoWrap(d dowrap, Stack stack, stacklevel int) (any, ArErr) {
|
||||
newstack := append(Stack, newscope())
|
||||
newstackCopy := make(stack, len(newstack))
|
||||
copy(newstackCopy, newstack)
|
||||
for _, v := range d.run {
|
||||
newstackCopy := make(stack, len(newstack))
|
||||
copy(newstackCopy, newstack)
|
||||
val, err := runVal(v, newstackCopy, stacklevel+1)
|
||||
if err.EXISTS {
|
||||
return nil, err
|
||||
|
||||
@@ -63,7 +63,7 @@ func parseForLoop(code UNPARSEcode, index int, codelines []UNPARSEcode) (forLoop
|
||||
}
|
||||
innertotalstep += tostep - 1
|
||||
body := strings.Join(tosplit[i:], ")")
|
||||
bodyval, worked, err, bodystep := translateVal(UNPARSEcode{code: body, realcode: code.realcode, line: code.line, path: code.path}, index, codelines, 1)
|
||||
bodyval, worked, err, bodystep := translateVal(UNPARSEcode{code: body, realcode: code.realcode, line: code.line, path: code.path}, index, codelines, 3)
|
||||
if !worked {
|
||||
if i == 0 {
|
||||
return forLoop{}, worked, err, bodystep
|
||||
|
||||
@@ -70,7 +70,7 @@ func parseIfStatement(code UNPARSEcode, index int, codeline []UNPARSEcode) (ifst
|
||||
},
|
||||
i,
|
||||
codeline,
|
||||
2,
|
||||
3,
|
||||
)
|
||||
if err.EXISTS || !worked {
|
||||
return ifstatement{}, worked, err, step
|
||||
@@ -99,7 +99,7 @@ func parseIfStatement(code UNPARSEcode, index int, codeline []UNPARSEcode) (ifst
|
||||
},
|
||||
i,
|
||||
codeline,
|
||||
2,
|
||||
3,
|
||||
)
|
||||
if err.EXISTS {
|
||||
return ifstatement{}, false, err, step
|
||||
|
||||
@@ -96,7 +96,7 @@ func parseForeverLoop(code UNPARSEcode, index int, codeline []UNPARSEcode) (whil
|
||||
},
|
||||
index,
|
||||
codeline,
|
||||
2,
|
||||
3,
|
||||
)
|
||||
return whileLoop{
|
||||
condition: true,
|
||||
@@ -108,13 +108,14 @@ func parseForeverLoop(code UNPARSEcode, index int, codeline []UNPARSEcode) (whil
|
||||
}
|
||||
|
||||
func runWhileLoop(loop whileLoop, stack stack, stacklevel int) (any, ArErr) {
|
||||
|
||||
newstack := append(stack, newscope())
|
||||
for {
|
||||
condition, err := runVal(loop.condition, newstack, stacklevel+1)
|
||||
newbodystack := append(newstack, newscope())
|
||||
if err.EXISTS {
|
||||
return nil, err
|
||||
}
|
||||
newbodystack := append(newstack, newscope())
|
||||
if !anyToBool(condition) {
|
||||
break
|
||||
}
|
||||
|
||||
@@ -9,4 +9,7 @@ let x = do
|
||||
let c = (class.f(path))
|
||||
c.nice(callback)
|
||||
return class.object()
|
||||
x.cool("to", ()=term.log("epic"))
|
||||
|
||||
|
||||
forever do
|
||||
x.cool("to", ()="epic")
|
||||
Reference in New Issue
Block a user