2023-10-27 09:20:02 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-10-31 12:17:08 +00:00
|
|
|
_ "cfg"
|
2023-10-27 09:20:02 +00:00
|
|
|
"fmt"
|
|
|
|
"os"
|
2023-10-31 12:17:08 +00:00
|
|
|
|
|
|
|
hcl "code.miflux.com/hyung-hwan/hcl/go"
|
2023-10-27 09:20:02 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
/*
|
|
|
|
var src []uint16 = utf16.Encode(([]rune)(
|
|
|
|
`(printf ">>>>>>>>> [%d]\n" (+ 30 455))
|
|
|
|
|
|
|
|
(printf ">>>>>>>>> [%d]\n" (+ 11 455))
|
|
|
|
#include "a.hcl"
|
|
|
|
(printf ">>>>>>>>> [%d]\n" (+ 20 455))
|
|
|
|
`))
|
|
|
|
*/
|
|
|
|
func main() {
|
|
|
|
|
2023-10-29 12:40:05 +00:00
|
|
|
var x *hcl.HCL = nil
|
|
|
|
var err error = nil
|
2023-10-27 09:20:02 +00:00
|
|
|
|
2023-10-31 12:17:08 +00:00
|
|
|
var rfh hcl.ReadFileHandler
|
|
|
|
var sfh hcl.ScanFileHandler
|
|
|
|
var pfh hcl.PrintFileHandler
|
2023-10-27 09:20:02 +00:00
|
|
|
|
2023-10-29 12:40:05 +00:00
|
|
|
x, err = hcl.New()
|
2023-10-27 09:20:02 +00:00
|
|
|
if err != nil {
|
2023-11-01 07:06:28 +00:00
|
|
|
fmt.Printf("Error: failed to instantiate hcl - %s\n", err.Error())
|
2023-10-27 09:20:02 +00:00
|
|
|
os.Exit(1)
|
|
|
|
}
|
2023-11-01 07:06:28 +00:00
|
|
|
|
|
|
|
x.SetLogMask (^hcl.BitMask(0))
|
|
|
|
x.SetLogTarget ("/dev/stderr")
|
|
|
|
|
2023-10-29 12:40:05 +00:00
|
|
|
err = x.Ignite(1000000)
|
2023-10-27 09:20:02 +00:00
|
|
|
if err != nil {
|
2023-11-01 07:06:28 +00:00
|
|
|
fmt.Printf("Error: failed to ignite - %s\n", err.Error())
|
2023-10-29 12:40:05 +00:00
|
|
|
goto oops
|
2023-10-27 09:20:02 +00:00
|
|
|
}
|
2023-10-29 12:40:05 +00:00
|
|
|
err = x.AddBuiltinPrims()
|
|
|
|
if err != nil {
|
2023-11-01 07:06:28 +00:00
|
|
|
fmt.Printf("Error: failed to add builtin primitives - %s\n", err.Error())
|
2023-10-29 12:40:05 +00:00
|
|
|
goto oops
|
|
|
|
}
|
|
|
|
|
2023-10-31 16:42:47 +00:00
|
|
|
err = x.AttachIO(&rfh, &sfh, &pfh)
|
2023-10-31 12:17:08 +00:00
|
|
|
if err != nil {
|
2023-11-01 07:06:28 +00:00
|
|
|
fmt.Printf("Error: %s\n", err.Error())
|
|
|
|
goto oops
|
2023-10-31 12:17:08 +00:00
|
|
|
}
|
2023-11-01 07:06:28 +00:00
|
|
|
|
|
|
|
err = x.FeedString(`(printf ">>>>>>>>> [%d]\n" (+ 30 455))
|
2023-10-29 12:40:05 +00:00
|
|
|
(printf ">>>>>>>>> [%d]\n" (+ 11 455))
|
|
|
|
#include "a.hcl"
|
2023-11-01 07:06:28 +00:00
|
|
|
(printf ">>>>>>>>> [%d]\n" (+ 20 455))`)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("Error: %s\n", err.Error())
|
|
|
|
goto oops
|
|
|
|
}
|
|
|
|
|
|
|
|
err = x.EndFeed()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("Error: %s\n", err.Error())
|
|
|
|
goto oops
|
|
|
|
}
|
|
|
|
|
|
|
|
x.Decode()
|
|
|
|
x.SetLogMask (0)
|
2023-10-29 12:40:05 +00:00
|
|
|
|
2023-11-01 07:06:28 +00:00
|
|
|
err = x.Execute()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("Error: %s\n", err.Error())
|
|
|
|
goto oops
|
|
|
|
}
|
2023-10-29 12:40:05 +00:00
|
|
|
|
2023-10-27 09:20:02 +00:00
|
|
|
x.Close()
|
2023-10-29 12:40:05 +00:00
|
|
|
|
|
|
|
os.Exit(0)
|
|
|
|
|
|
|
|
oops:
|
|
|
|
if x != nil {
|
|
|
|
x.Close()
|
|
|
|
x = nil
|
|
|
|
}
|
|
|
|
os.Exit(1)
|
2023-10-27 09:20:02 +00:00
|
|
|
}
|