Skip to content
/ tater Public

The tater scripting language. Everyone loves tots.

License

Notifications You must be signed in to change notification settings

jaos/tater

Repository files navigation

tater

Simple scripting language based upon the great work of Robert Nystrom

example.tot:

#!/usr/bin/tater

type WorkSites {
    let RESIDENTIAL = 0x1;
    let COMMERCIAL = 0x2;
    let INDUSTRIAL = 0x4;
}

type WorkCounter {
    let name;
    let counter = 0;
    fn init(name) {
        self.name = name;
    }

    fn work(locations) {
        for (let i = 0; i < locations.len(); i++) {
            self.counter++;

            let work = locations[i];
            print(self.name + ", location counter " + str(self.counter));
            print(work);
            let start_point = work["start"];
            let end_point = work["end"];

            let log = file("work-" + str(self.counter) + ".data", "w");

            switch (work["site"]) {
                case WorkSites.RESIDENTIAL: {
                    print("setting up residential drone.");
                    // start flying
                    while (start_point[0] < end_point[0]) {
                        start_point[0]++; # simulation
                    }
                    log.write("residential complete\n");
                }
                case WorkSites.COMMERCIAL: {
                    # more here
                    log.write("commercial todo\n");
                }
                case WorkSites.INDUSTRIAL: {
                    # more here
                    log.write("industrial todo\n");
                }
            }

            log.close();
        }
    }
}

let b = true;
let wc = WorkCounter("phase1");
let workorder = [
    {"start": [900,100], "end": [920, 80], "site": WorkSites.RESIDENTIAL},
    {"start": [1_360,1_800], "end": [1_390, 2_000], "site": WorkSites.COMMERCIAL},
    {"start": [3_490,3_400], "end": [3_700, 3_550], "site": WorkSites.INDUSTRIAL}
];

wc.work(workorder);

Building

Requires:

  • libcheck (build time only, unit tests)
meson setup build -Ddebugging=enabled -Db_coverage=true --prefix=/usr --sysconfdir=/etc
meson compile -C build

Testing

meson test -C build && ninja coverage-html -C build

Run the REPL

meson devenv -C build ./src/tater

Run the benchmark

meson devenv -C build ./src/tater $PWD/t/bench.tot

Translations

# edit po/LINGUAS etc
meson compile tater-pot -C build
meson compile tater-update-po -C build

About

The tater scripting language. Everyone loves tots.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages