added _main
This commit is contained in:
+5
-1
@@ -460,5 +460,9 @@ func RunFile(filePath string, libCode string) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil { fmt.Fprintf(os.Stderr, "Error executing %s: %v\n", filePath, r); os.Exit(1) }
|
||||
}()
|
||||
NewClyx("", libCode).Run(string(content))
|
||||
c := NewClyx("", libCode)
|
||||
c.Run(string(content))
|
||||
if c.HasWord("_main") {
|
||||
c.Run("_main")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,11 @@ class Clyx:
|
||||
run = lambda self, code: self._exec_quot(self._tokenize(code))
|
||||
|
||||
def clyx(f):
|
||||
try: Clyx().run(open(f).read())
|
||||
try:
|
||||
c = Clyx()
|
||||
c.run(open(f).read())
|
||||
if '_main' in c._words:
|
||||
c.run('_main')
|
||||
except Exception as e: (sys.stderr.write(f'Error executing {f}: {e}\n'), sys.exit(1))
|
||||
|
||||
repl = lambda: clyx(replpath)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env clyx
|
||||
# Clyx core implementation test suite
|
||||
# Created by Luxferre in 2026, released into the public domain
|
||||
|
||||
:: _main [
|
||||
# 1. Stack Manipulation
|
||||
"Testing stack operations..." puts cr
|
||||
|
||||
@@ -224,4 +224,4 @@ hsargs isquot [ hsargs qlen 0 > ] and if [
|
||||
]
|
||||
|
||||
0 hsexit
|
||||
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user