mirror of
https://github.com/Open-Argon/argon-v3.git
synced 2025-12-06 00:46:07 +00:00
get rid of circular imports
This commit is contained in:
@@ -85,11 +85,11 @@ func __runTranslatedImport(translatedImport translatedImport, global ArObject, m
|
||||
"main": main,
|
||||
}),
|
||||
})
|
||||
imported[translatedImport.p] = local
|
||||
_, runimeErr := run(translatedImport.translated, stack{global, localvars, local})
|
||||
if runimeErr.EXISTS {
|
||||
return ArObject{}, runimeErr
|
||||
}
|
||||
imported[translatedImport.p] = local
|
||||
return local, ArErr{}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
var genericImportCompiled = makeRegex(`import( )+(.|\n)+(( )+as( )+([a-zA-Z_]|(\p{L}\p{M}*))([a-zA-Z0-9_]|(\p{L}\p{M}*))*)?( *)`)
|
||||
var genericImportCompiled = makeRegex(`( *)import( )+(.|\n)+(( )+as( )+([a-zA-Z_]|(\p{L}\p{M}*))([a-zA-Z0-9_]|(\p{L}\p{M}*))*)?( *)`)
|
||||
|
||||
type ArImport struct {
|
||||
pretranslated bool
|
||||
@@ -80,20 +80,10 @@ func parseGenericImport(code UNPARSEcode, index int, codeline []UNPARSEcode) (Ar
|
||||
}
|
||||
|
||||
if str, ok := toImport.(string); ok {
|
||||
resp, err := translateImport(str, filepath.Dir(filepath.ToSlash(code.path)))
|
||||
if !err.EXISTS {
|
||||
importOBJ.translated = resp
|
||||
importOBJ.pretranslated = true
|
||||
var err ArErr
|
||||
importOBJ.translated, err = translateImport(str, filepath.Dir(filepath.ToSlash(code.path)))
|
||||
if err.EXISTS {
|
||||
if err.line == 0 {
|
||||
err.line = importOBJ.Line
|
||||
}
|
||||
if err.path == "" {
|
||||
err.path = importOBJ.Path
|
||||
}
|
||||
if err.code == "" {
|
||||
err.code = importOBJ.Code
|
||||
}
|
||||
return importOBJ, false, err, i
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ func translateVal(code UNPARSEcode, index int, codelines []UNPARSEcode, isLine i
|
||||
err ArErr = ArErr{"Syntax Error", "invalid syntax", code.line, code.path, code.realcode, true}
|
||||
i int = 1
|
||||
)
|
||||
if isLine == 3 {
|
||||
if isLine >= 3 {
|
||||
if isComment(code) {
|
||||
resp, worked, err, i = parseComment(code, index, codelines)
|
||||
if worked {
|
||||
@@ -251,7 +251,7 @@ func translate(codelines []UNPARSEcode) ([]any, ArErr) {
|
||||
if currentindent != 0 {
|
||||
return nil, ArErr{"Syntax Error", "invalid indent", codelines[i].line, codelines[i].path, codelines[i].realcode, true}
|
||||
}
|
||||
val, _, err, step := translateVal(codelines[i], i, codelines, 3)
|
||||
val, _, err, step := translateVal(codelines[i], i, codelines, 4)
|
||||
i += step
|
||||
if err.EXISTS {
|
||||
return nil, err
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
|
||||
term.log("hello")
|
||||
import "circular_import"
|
||||
Reference in New Issue
Block a user