mirror of
https://github.com/Open-Argon/argon-v3.git
synced 2025-12-06 08:56:07 +00:00
fix bug which would make syntax errors inside functions display the wrong line
This commit is contained in:
@@ -10,8 +10,8 @@ var Args = os.Args[1:]
|
|||||||
|
|
||||||
type stack = []ArObject
|
type stack = []ArObject
|
||||||
|
|
||||||
const VERSION = "3.0.4"
|
const VERSION = "3.0.4-2"
|
||||||
const VERSION_NUM = 0
|
const VERSION_NUM = 1
|
||||||
|
|
||||||
// Example struct
|
// Example struct
|
||||||
type Person struct {
|
type Person struct {
|
||||||
|
|||||||
141
src/translate.go
141
src/translate.go
@@ -11,20 +11,9 @@ type UNPARSEcode struct {
|
|||||||
path string
|
path string
|
||||||
}
|
}
|
||||||
|
|
||||||
var knownFailures = map[string]ArErr{}
|
|
||||||
var QuickKnownFailures = map[string]bool{}
|
var QuickKnownFailures = map[string]bool{}
|
||||||
|
|
||||||
func translateVal(code UNPARSEcode, index int, codelines []UNPARSEcode, isLine int) (any, bool, ArErr, int) {
|
func translateVal(code UNPARSEcode, index int, codelines []UNPARSEcode, isLine int) (any, bool, ArErr, int) {
|
||||||
if knownErr, ok := knownFailures[code.code]; ok {
|
|
||||||
return nil, false, ArErr{
|
|
||||||
knownErr.TYPE,
|
|
||||||
knownErr.message,
|
|
||||||
code.line,
|
|
||||||
code.path,
|
|
||||||
code.realcode,
|
|
||||||
true,
|
|
||||||
}, 1
|
|
||||||
}
|
|
||||||
var (
|
var (
|
||||||
resp any = nil
|
resp any = nil
|
||||||
worked bool = false
|
worked bool = false
|
||||||
@@ -39,79 +28,36 @@ func translateVal(code UNPARSEcode, index int, codelines []UNPARSEcode, isLine i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if isIfStatement(code) {
|
if isIfStatement(code) {
|
||||||
resp, worked, err, i = parseIfStatement(code, index, codelines)
|
return parseIfStatement(code, index, codelines)
|
||||||
if !worked {
|
|
||||||
knownFailures[code.code] = err
|
|
||||||
}
|
|
||||||
return resp, worked, err, i
|
|
||||||
} else if isWhileLoop(code) {
|
} else if isWhileLoop(code) {
|
||||||
resp, worked, err, i = parseWhileLoop(code, index, codelines)
|
return parseWhileLoop(code, index, codelines)
|
||||||
if !worked {
|
|
||||||
knownFailures[code.code] = err
|
|
||||||
}
|
|
||||||
return resp, worked, err, i
|
|
||||||
} else if isForeverLoop(code) {
|
} else if isForeverLoop(code) {
|
||||||
resp, worked, err, i = parseForeverLoop(code, index, codelines)
|
return parseForeverLoop(code, index, codelines)
|
||||||
if !worked {
|
|
||||||
knownFailures[code.code] = err
|
|
||||||
}
|
|
||||||
return resp, worked, err, i
|
|
||||||
} else if isForLoop(code) {
|
} else if isForLoop(code) {
|
||||||
resp, worked, err, i = parseForLoop(code, index, codelines)
|
return parseForLoop(code, index, codelines)
|
||||||
if !worked {
|
|
||||||
knownFailures[code.code] = err
|
|
||||||
}
|
|
||||||
return resp, worked, err, i
|
|
||||||
} else if isGenericImport(code) {
|
} else if isGenericImport(code) {
|
||||||
resp, worked, err, i = parseGenericImport(code, index, codelines)
|
return parseGenericImport(code, index, codelines)
|
||||||
if !worked {
|
|
||||||
knownFailures[code.code] = err
|
|
||||||
}
|
|
||||||
return resp, worked, err, i
|
|
||||||
} else if isTryCatch(code) {
|
} else if isTryCatch(code) {
|
||||||
resp, worked, err, i = parseTryCatch(code, index, codelines)
|
return parseTryCatch(code, index, codelines)
|
||||||
if !worked {
|
|
||||||
knownFailures[code.code] = err
|
|
||||||
}
|
|
||||||
return resp, worked, err, i
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if isLine >= 2 {
|
if isLine >= 2 {
|
||||||
if isReturn(code) {
|
if isReturn(code) {
|
||||||
resp, worked, err, i = parseReturn(code, index, codelines)
|
return parseReturn(code, index, codelines)
|
||||||
if !worked {
|
|
||||||
knownFailures[code.code] = err
|
} else if isBreak(code) {
|
||||||
}
|
return parseBreak(code)
|
||||||
return resp, worked, err, i
|
|
||||||
} else if isBreak(code) {
|
} else if isContinue(code) {
|
||||||
resp, worked, err, i = parseBreak(code)
|
return parseContinue(code)
|
||||||
if !worked {
|
|
||||||
knownFailures[code.code] = err
|
} else if isDeleteVariable(code) {
|
||||||
}
|
return parseDelete(code, index, codelines)
|
||||||
return resp, worked, err, i
|
|
||||||
} else if isContinue(code) {
|
|
||||||
resp, worked, err, i = parseContinue(code)
|
|
||||||
if !worked {
|
|
||||||
knownFailures[code.code] = err
|
|
||||||
}
|
|
||||||
return resp, worked, err, i
|
|
||||||
} else if isDeleteVariable(code) {
|
|
||||||
resp, worked, err, i = parseDelete(code, index, codelines)
|
|
||||||
if !worked {
|
|
||||||
knownFailures[code.code] = err
|
|
||||||
}
|
|
||||||
return resp, worked, err, i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if isLine >= 1 {
|
|
||||||
if isDoWrap(code) {
|
|
||||||
resp, worked, err, i = parseDoWrap(code, index, codelines)
|
|
||||||
if !worked {
|
|
||||||
knownFailures[code.code] = err
|
|
||||||
}
|
|
||||||
return resp, worked, err, i
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +65,9 @@ func translateVal(code UNPARSEcode, index int, codelines []UNPARSEcode, isLine i
|
|||||||
isLine = 1
|
isLine = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if isBoolean(code) {
|
if isDoWrap(code) {
|
||||||
|
return parseDoWrap(code, index, codelines)
|
||||||
|
} else if isBoolean(code) {
|
||||||
return parseBoolean(code)
|
return parseBoolean(code)
|
||||||
} else if !QuickKnownFailures["brackets"+code.code] && isBrackets(code) {
|
} else if !QuickKnownFailures["brackets"+code.code] && isBrackets(code) {
|
||||||
resp, worked, err, i = parseBrackets(code, index, codelines)
|
resp, worked, err, i = parseBrackets(code, index, codelines)
|
||||||
@@ -135,13 +83,6 @@ func translateVal(code UNPARSEcode, index int, codelines []UNPARSEcode, isLine i
|
|||||||
}
|
}
|
||||||
QuickKnownFailures["abs"+code.code] = true
|
QuickKnownFailures["abs"+code.code] = true
|
||||||
}
|
}
|
||||||
if !QuickKnownFailures["setvar"+code.code] && isSetVariable(code) {
|
|
||||||
resp, worked, err, i = parseSetVariable(code, index, codelines, isLine)
|
|
||||||
if worked {
|
|
||||||
return resp, worked, err, i
|
|
||||||
}
|
|
||||||
QuickKnownFailures["setvar"+code.code] = true
|
|
||||||
}
|
|
||||||
if !QuickKnownFailures["autoasign"+code.code] && isAutoAsignVariable(code) {
|
if !QuickKnownFailures["autoasign"+code.code] && isAutoAsignVariable(code) {
|
||||||
resp, worked, err, i = parseAutoAsignVariable(code, index, codelines, isLine)
|
resp, worked, err, i = parseAutoAsignVariable(code, index, codelines, isLine)
|
||||||
if worked {
|
if worked {
|
||||||
@@ -149,18 +90,12 @@ func translateVal(code UNPARSEcode, index int, codelines []UNPARSEcode, isLine i
|
|||||||
}
|
}
|
||||||
QuickKnownFailures["autoasign"+code.code] = true
|
QuickKnownFailures["autoasign"+code.code] = true
|
||||||
}
|
}
|
||||||
if isNumber(code) {
|
if isSetVariable(code) {
|
||||||
resp, worked, err, i = parseNumber(code)
|
return parseSetVariable(code, index, codelines, isLine)
|
||||||
if !worked {
|
} else if isNumber(code) {
|
||||||
knownFailures[code.code] = err
|
return parseNumber(code)
|
||||||
}
|
|
||||||
return resp, worked, err, i
|
|
||||||
} else if isString(code) {
|
} else if isString(code) {
|
||||||
resp, worked, err, i = parseString(code)
|
return parseString(code)
|
||||||
if !worked {
|
|
||||||
knownFailures[code.code] = err
|
|
||||||
}
|
|
||||||
return resp, worked, err, i
|
|
||||||
} else if !QuickKnownFailures["squareroot"+code.code] && issquareroot(code) {
|
} else if !QuickKnownFailures["squareroot"+code.code] && issquareroot(code) {
|
||||||
resp, worked, err, i = parseSquareroot(code, index, codelines)
|
resp, worked, err, i = parseSquareroot(code, index, codelines)
|
||||||
if worked {
|
if worked {
|
||||||
@@ -176,11 +111,7 @@ func translateVal(code UNPARSEcode, index int, codelines []UNPARSEcode, isLine i
|
|||||||
QuickKnownFailures["factorial"+code.code] = true
|
QuickKnownFailures["factorial"+code.code] = true
|
||||||
}
|
}
|
||||||
if isVariable(code) {
|
if isVariable(code) {
|
||||||
resp, worked, err, i = parseVariable(code)
|
return parseVariable(code)
|
||||||
if !worked {
|
|
||||||
knownFailures[code.code] = err
|
|
||||||
}
|
|
||||||
return resp, worked, err, i
|
|
||||||
}
|
}
|
||||||
if !QuickKnownFailures["array"+code.code] && isArray(code) {
|
if !QuickKnownFailures["array"+code.code] && isArray(code) {
|
||||||
resp, worked, err, i = parseArray(code, index, codelines)
|
resp, worked, err, i = parseArray(code, index, codelines)
|
||||||
@@ -216,17 +147,9 @@ func translateVal(code UNPARSEcode, index int, codelines []UNPARSEcode, isLine i
|
|||||||
QuickKnownFailures["call"+code.code] = true
|
QuickKnownFailures["call"+code.code] = true
|
||||||
}
|
}
|
||||||
if isNegative(code) {
|
if isNegative(code) {
|
||||||
resp, worked, err, i = parseNegative(code, index, codelines)
|
return parseNegative(code, index, codelines)
|
||||||
if !worked {
|
|
||||||
knownFailures[code.code] = err
|
|
||||||
}
|
|
||||||
return resp, worked, err, i
|
|
||||||
} else if isMapGet(code) {
|
} else if isMapGet(code) {
|
||||||
resp, worked, err, i = mapGetParse(code, index, codelines)
|
return mapGetParse(code, index, codelines)
|
||||||
if !worked {
|
|
||||||
knownFailures[code.code] = err
|
|
||||||
}
|
|
||||||
return resp, worked, err, i
|
|
||||||
} else if !QuickKnownFailures["indexget"+code.code] && isIndexGet(code) {
|
} else if !QuickKnownFailures["indexget"+code.code] && isIndexGet(code) {
|
||||||
resp, worked, err, i = indexGetParse(code, index, codelines)
|
resp, worked, err, i = indexGetParse(code, index, codelines)
|
||||||
if worked {
|
if worked {
|
||||||
@@ -234,9 +157,7 @@ func translateVal(code UNPARSEcode, index int, codelines []UNPARSEcode, isLine i
|
|||||||
}
|
}
|
||||||
QuickKnownFailures["indexget"+code.code] = true
|
QuickKnownFailures["indexget"+code.code] = true
|
||||||
}
|
}
|
||||||
if !worked {
|
|
||||||
knownFailures[code.code] = err
|
|
||||||
}
|
|
||||||
return resp, worked, err, i
|
return resp, worked, err, i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user