Zimbu

1 program Added 2026-02-05T12:30:45Z Agent: claude-codeModel: sonnetWebSearch: enabled Evidence Report issue View issues
Aliases: —
Provenance: commit 2d91624af5 · authored 2026-02-05T20:45:00+01:00 · agent claude-code · model sonnet

Sources mentioning this language

2 sources · pl_id: pl/zimbu
LLM (this repo) · 1Pldb

Related languages

Zig (0.18)Zing (0.18)ZINC (0.17)ZiziQue (0.14)bJou (0.08)

LLM-contributed programs

Zimbu Compiler Driver

Provenance: commit 2d91624af5 · authored 2026-02-05T20:45:00+01:00 · agent claude-code · model sonnet · WebSearch enabled
code.zu · license: Apache-2.0 · added: 2026-02-05T12:30:45Z
#
# Main file of the Zimbu compiler driver.
#
# This is intentionally a separate, small program, so that when running the C
# compiler and executing the binary the memory used by the actual compiler has
# been released. That matters a lot when doing fork().
#
# Usage:
# zimbu {file}.zu Compile {file}.zu
#
# Options:
# -o {prog} Store executable as {prog}
# -x [arg ...] Execute the compiled program
# -cc {compiler} Use {compiler} for the C compiler
# Options passed on to zimbu2c:
# -q Quick - do not generate a stack backtrace
# -d Debug mode
# -v Verbose
# -vv Very verbose
# -z don't check for undefined symbols
# --manage Manage memory
# --keepunused Do write unused items.
#
# And later:
# zimbu Execute build commands in ZIMBU file
# zimbu BUILD Execute build commands in BUILD file
#
# Copyright 2009 Bram Moolenaar All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# The License can be found it in the LICENSE file, or you may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0

IMPORT "Config.zu"

ARG.StringList execute = NEW("x", "execute", [],
 "Execute the program after compiling it "
 .. "(must come last)")
 .setArgName("arg")
ARG.Bool forceCompileFlag = NEW("f", "force", FALSE,
 "Force compilation even if source is older than executable")

ARG.String progname = NEW("o", "output", "", "Name for the produced program")
 .setArgName("progname")
ARG.String zimbu = NEW(NIL, "zimbu", "", "Name for the zimbu2c program")
 .setArgName("zimbuname")

ARG.Bool undefinedFlag = NEW("z", "zeroundef", TRUE,
 "Skip resolving symbols if there are no undefined symbols")
ARG.Bool writeZuiFlag = NEW(NIL, "zui", FALSE, "Write .zui files")
ARG.Bool keepunusedFlag = NEW(NIL, "keepunused", FALSE, "Do write unused items")
ARG.String manageFlag = NEW(NIL, "manage", "default",
 "Memory management method; one of: "
 .. "default, none, linked")
ARG.Bool exitclean = NEW(NIL, "exitclean", FALSE,
 "Run the garbage collector on exit")

ARG.Usage usage = NEW("Usage: %0% [--help] [flags] source.zu [-x arg ...]")

FUNC Main() int
 IF ARG.Size() < 1
 IO.print("Missing source file argument")
 IO.print(usage.get())
 EXIT 1
 }
 IF ARG.Size() > 1
 LOG.fatal("Only one .zu file allowed")
 }

 # Catch common mistakes in arguments.
 string inFileName = ARG.get(0)
 IF inFileName.slice(-3) != ".zu"
 LOG.fatal("Input name must end in '.zu': \(inFileName)")
 }

 # Run auto-configuration. Fills in values for the Config module.
 IF Config.run() != OK
 LOG.fatal("Config failed, cannot compile a program")
 }

 string rootName = inFileName.slice(0, -4) # without ".zu"
 string rootTail = IO.tail(rootName)
 string dirName = IO.directory(rootName)
 string zudirName = IO.concatPath(dirName, Config.zudirName)
 string outFileName = IO.concatPath(zudirName, rootTail .. ".c")
 string ecaFileName = IO.concatPath(zudirName, rootTail .. ".eca")

 string progName
 IF progname.present()
 progName = progname.get()
 IF Config.exeSuffix != ""
 && !progName.toLower().endsWith(Config.exeSuffix.toLower())
 progName ..= Config.exeSuffix
 }
 ELSE
 progName = rootName .. Config.exeSuffix
 }

 # Compile the .zu file in one of these cases:
 # - There is no -x flag
 # - There is a -f flag
 # - There is a -x flag and the source is older than the executable
 bool build
 IF !execute.present() || forceCompileFlag.present()
 build = TRUE
 ELSE
 IO.FileInfo inFileInfo = IO.fileInfo(inFileName)
 IO.FileInfo progNameInfo = IO.fileInfo(progName)
 build = inFileInfo.time > progNameInfo.time
 }

 int retval = 0
 IF build
 # STEP 1: Run zimbu2c to convert {file}.zu to ZUDIR/{file}.c.

 string cmd
 IF zimbu.present()
 # Use the command line argument for zimbu2c.
 cmd = zimbu.get()
 ELSE
 # The zimbu2c executable name is the same as this executable.
 # some/path/zimbu -> some/path/zimbu2c
 # some/path/zimbu.exe -> some/path/zimbu2c.exe
 # path/zimbu_test_test -> path/zimbu_test_test2c
 # path/zimbu_test -> path/zimbu_test2c
 string zimbu2c = "zimbu2c"
 IF ARG.exeName.find("zimbu_test_test") >= 0
 zimbu2c = "zimbu_test_test2c"
 ELSEIF ARG.exeName.find("zimbu_test") >= 0
 zimbu2c = "zimbu_test2c"
 }
 cmd = IO.modifyExeName(ARG.exeName, zimbu2c)
 IF cmd.find(' ') >= 0
 # Command contains a space, put it in quotes.
 cmd = ""(cmd)""
 }
 }

 # Pass some of the arguments.
 IF Config.quick.get()
 cmd ..= " -q"
 }
 cmd ..= LOG.getFlags()
 IF !undefinedFlag.get()
 cmd ..= " -z"
 }
 IF writeZuiFlag.get()
 cmd ..= " --zui"
 }
 IF keepunusedFlag.get()
 cmd ..= " --keepunused"
 }
 IF Config.portableFlag.get()
 cmd ..= " --portable"
 }
 cmd ..= " --manage=" .. manageFlag.get()
 IF exitclean.get()
 cmd ..= " --exitclean"
 }

 retval = SYS.shell(cmd .. " \"" .. inFileName .. "\"")

 IF retval == 0
 # Even when the command failed the exit value may be zero, check that the
 # C file was actually generated.
 IO.FileInfo fileInfo = IO.fileInfo(outFileName)
 IF fileInfo.status == FAIL || fileInfo.size == 0
 IO.print("ERROR: C program not written")
 retval = 1
 }
 ELSE
 # Avoid retval 256, make sees it as zero.
 retval = 1
 }

 IF retval == 0
 #
 # STEP 2: Compile the produced C code.
 #
 # Not all C compilers return a non-zero value for failure.
 # Delete the binary and check that it was updated and has some size.
 IO.delete(progName)
 IO.FileInfo before = IO.fileInfo(progName)
 string ccCmd = Config.compilerCmd(outFileName, progName)

 # Read the .eca file and append it to the compiler command (omitting
 # line breaks).
 # Libraries must come last, the compiler may only pick up methods that
 # were used in the srcName.
 ccCmd ..= IO.readFile(ecaFileName).replaceAll('\n', ' ')

 # Add the tcmalloc library if zimbuConfig could find it.
 IF Config.mallocArg != NIL
 ccCmd ..= " " .. Config.mallocArg
 }

 LOG.info("Executing compiler: \(ccCmd)")
 retval = SYS.shell(ccCmd)
 IO.FileInfo after = IO.fileInfo(progName)
 IF after.size == 0
 IO.print("ERROR: Compiled program is zero size")
 retval = 1
 ELSEIF before.size == after.size && before.time == after.time
 IO.print("ERROR: Compiled program was not updated")
 retval = 1
 ELSEIF retval != 0
 # Avoid retval 256, make sees it as zero.
 retval = 1
 }
 }
 }

 #
 # STEP 3: Execute the program if "-x" was given
 #
 IF retval == 0 && execute.present()
 IF progName[0] != '/'
 progName = Config.exePrefix .. progName
 }
 string executeArgs = ""
 FOR arg IN execute.get()
 # TODO: better escaping
 executeArgs ..= " '" .. arg .. "'"
 }
 LOG.info("Executing program: \(progName)\(executeArgs)")
 retval = SYS.shell(progName .. executeArgs)
 }

 RETURN retval
}

Real programs from Software Heritage

No SWH evidence indexed yet for this language. (Either the SWH mining hasn't reached this language's extensions, or no matching files exist in the archive.)

Contribute — propose a file extension

Tell us where to find evidence about Zimbu (mapped to pl/zimbu). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/Zimbu/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← zim-format Zimpl →