mirror of
https://github.com/Open-Argon/argon-v3.git
synced 2025-12-06 00:46:07 +00:00
make brackets more efficient
This commit is contained in:
@@ -6,18 +6,11 @@ import (
|
|||||||
|
|
||||||
var bracketsCompile = makeRegex(`( *)\((.|\n)+\)( *)`)
|
var bracketsCompile = makeRegex(`( *)\((.|\n)+\)( *)`)
|
||||||
|
|
||||||
type brackets struct {
|
|
||||||
VAL any
|
|
||||||
line int
|
|
||||||
code string
|
|
||||||
path string
|
|
||||||
}
|
|
||||||
|
|
||||||
func isBrackets(code UNPARSEcode) bool {
|
func isBrackets(code UNPARSEcode) bool {
|
||||||
return bracketsCompile.MatchString(code.code)
|
return bracketsCompile.MatchString(code.code)
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseBrackets(code UNPARSEcode, index int, codeline []UNPARSEcode) (brackets, bool, ArErr, int) {
|
func parseBrackets(code UNPARSEcode, index int, codeline []UNPARSEcode) (any, bool, ArErr, int) {
|
||||||
trimmed := strings.TrimSpace(code.code)
|
trimmed := strings.TrimSpace(code.code)
|
||||||
resp, worked, err, i := translateVal(UNPARSEcode{
|
resp, worked, err, i := translateVal(UNPARSEcode{
|
||||||
code: trimmed[1 : len(trimmed)-1],
|
code: trimmed[1 : len(trimmed)-1],
|
||||||
@@ -25,10 +18,5 @@ func parseBrackets(code UNPARSEcode, index int, codeline []UNPARSEcode) (bracket
|
|||||||
line: code.line,
|
line: code.line,
|
||||||
path: code.path,
|
path: code.path,
|
||||||
}, index, codeline, 0)
|
}, index, codeline, 0)
|
||||||
return brackets{
|
return resp, worked, err, i
|
||||||
VAL: resp,
|
|
||||||
line: code.line,
|
|
||||||
code: code.realcode,
|
|
||||||
path: code.path,
|
|
||||||
}, worked, err, i
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,14 +80,6 @@ func runVal(line any, stack stack, stacklevel int) (any, ArErr) {
|
|||||||
message: "cannot negate a non-number",
|
message: "cannot negate a non-number",
|
||||||
EXISTS: true,
|
EXISTS: true,
|
||||||
}
|
}
|
||||||
case brackets:
|
|
||||||
if stackoverflow {
|
|
||||||
linenum = x.line
|
|
||||||
path = x.path
|
|
||||||
code = x.code
|
|
||||||
break
|
|
||||||
}
|
|
||||||
return runVal(x.VAL, stack, stacklevel+1)
|
|
||||||
case operationType:
|
case operationType:
|
||||||
if stackoverflow {
|
if stackoverflow {
|
||||||
linenum = x.line
|
linenum = x.line
|
||||||
|
|||||||
Reference in New Issue
Block a user