mirror of
https://github.com/Open-Argon/argon-v3.git
synced 2025-12-06 08:56: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); {
|
for i := 0; i < len(codelines); {
|
||||||
indent := len(codelines[i].code) - len(strings.TrimLeft(codelines[i].code, " "))
|
indent := len(codelines[i].code) - len(strings.TrimLeft(codelines[i].code, " "))
|
||||||
if indent != setindent {
|
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)
|
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) {
|
func runDoWrap(d dowrap, Stack stack, stacklevel int) (any, ArErr) {
|
||||||
newstack := append(Stack, newscope())
|
newstack := append(Stack, newscope())
|
||||||
|
newstackCopy := make(stack, len(newstack))
|
||||||
|
copy(newstackCopy, newstack)
|
||||||
for _, v := range d.run {
|
for _, v := range d.run {
|
||||||
newstackCopy := make(stack, len(newstack))
|
|
||||||
copy(newstackCopy, newstack)
|
|
||||||
val, err := runVal(v, newstackCopy, stacklevel+1)
|
val, err := runVal(v, newstackCopy, stacklevel+1)
|
||||||
if err.EXISTS {
|
if err.EXISTS {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ func parseForLoop(code UNPARSEcode, index int, codelines []UNPARSEcode) (forLoop
|
|||||||
}
|
}
|
||||||
innertotalstep += tostep - 1
|
innertotalstep += tostep - 1
|
||||||
body := strings.Join(tosplit[i:], ")")
|
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 !worked {
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
return forLoop{}, worked, err, bodystep
|
return forLoop{}, worked, err, bodystep
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ func parseIfStatement(code UNPARSEcode, index int, codeline []UNPARSEcode) (ifst
|
|||||||
},
|
},
|
||||||
i,
|
i,
|
||||||
codeline,
|
codeline,
|
||||||
2,
|
3,
|
||||||
)
|
)
|
||||||
if err.EXISTS || !worked {
|
if err.EXISTS || !worked {
|
||||||
return ifstatement{}, worked, err, step
|
return ifstatement{}, worked, err, step
|
||||||
@@ -99,7 +99,7 @@ func parseIfStatement(code UNPARSEcode, index int, codeline []UNPARSEcode) (ifst
|
|||||||
},
|
},
|
||||||
i,
|
i,
|
||||||
codeline,
|
codeline,
|
||||||
2,
|
3,
|
||||||
)
|
)
|
||||||
if err.EXISTS {
|
if err.EXISTS {
|
||||||
return ifstatement{}, false, err, step
|
return ifstatement{}, false, err, step
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ func parseForeverLoop(code UNPARSEcode, index int, codeline []UNPARSEcode) (whil
|
|||||||
},
|
},
|
||||||
index,
|
index,
|
||||||
codeline,
|
codeline,
|
||||||
2,
|
3,
|
||||||
)
|
)
|
||||||
return whileLoop{
|
return whileLoop{
|
||||||
condition: true,
|
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) {
|
func runWhileLoop(loop whileLoop, stack stack, stacklevel int) (any, ArErr) {
|
||||||
|
|
||||||
newstack := append(stack, newscope())
|
newstack := append(stack, newscope())
|
||||||
for {
|
for {
|
||||||
condition, err := runVal(loop.condition, newstack, stacklevel+1)
|
condition, err := runVal(loop.condition, newstack, stacklevel+1)
|
||||||
newbodystack := append(newstack, newscope())
|
|
||||||
if err.EXISTS {
|
if err.EXISTS {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
newbodystack := append(newstack, newscope())
|
||||||
if !anyToBool(condition) {
|
if !anyToBool(condition) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,4 +9,7 @@ let x = do
|
|||||||
let c = (class.f(path))
|
let c = (class.f(path))
|
||||||
c.nice(callback)
|
c.nice(callback)
|
||||||
return class.object()
|
return class.object()
|
||||||
x.cool("to", ()=term.log("epic"))
|
|
||||||
|
|
||||||
|
forever do
|
||||||
|
x.cool("to", ()="epic")
|
||||||
Reference in New Issue
Block a user