Categorygithub.com/2dprototype/tender
modulepackage
0.0.1
Repository: https://github.com/2dprototype/tender.git
Documentation: pkg.go.dev

# README

Tender

Tender is a general-purpose programming language specially designed for image processing, 2D graphics, scripting, and more!

Overview

Tender is compiled and executed as bytecode on a stack-based virtual machine (VM) written in native Golang.

Features

  • Simple and highly readable syntax
  • Compiles into bytecode
  • Supports rich built-in modules
  • Optimized for 2D graphics

Quick Start

  1. Install Tender on your machine.
  2. Copy the sample code below:
// Basic example
str1 := "hello"
str2 := "world"

println(str1 + " " + str2)
// Canvas drawing example (similar to JS Canvas)
import "canvas"
	
var ctx = canvas.new_context(100, 100)
ctx.hex("#0f0")        // Set color to green
ctx.dash(4, 2)         // Define dashed stroke
ctx.rect(25, 25, 50, 50)  // Draw a rectangle
ctx.stroke()

ctx.save_png("out.png")  // Save output as PNG
  1. Save your code as hello.td (use the .td extension).
  2. Run your script using the following command:
tender hello.td

Installation

  1. Download the repository.
  2. Run the install.sh script to install Tender on your system.

Windows (Manual Installation)

  1. Download the tender.exe binary for your system from the bin directory, along with the pkg folder from pkg.
  2. Copy the files to your desired location with the following structure:
├───bin
│   └───tender.exe
└───pkg
    │   ansi.td
    │   cinf.td
    │   console.td
    │   enum.td
    │   fs.td
    │   matrix.td
    │   messagebox.td
    │   utf8.td
    │   vec2.td
    │   xml.td
    └───helper
  1. Add the path to the bin folder to your system's environment variables.

Documentation

Examples

Explore various examples demonstrating Tender’s features in the examples directory.


Dependencies

Tender uses the following dependencies:


Syntax Highlighting

Syntax highlighting is currently available only for Notepad++. Download the configuration file from here.


License

Tender is distributed under the MIT License. Additional licenses for third-party dependencies are provided in LICENSE_GOLANG and LICENSE_TENGO.


Acknowledgments

Tender is written in Go and inspired by Tengo. We extend our gratitude to the contributors of Tengo for their valuable work.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

CountObjects returns the number of objects that a given object o contains.
Format is like fmt.Sprintf but using Objects.
FormatInstructions returns string representation of bytecode instructions.
No description provided by the author
FromInterface will attempt to convert an interface{} v to a tender Object.
GetAllBuiltinFunctions returns all builtin function objects.
MakeInstruction returns a bytecode for an opcode and the operands.
NewCompiler creates a Compiler.
NewModuleMap creates a new module map.
NewScript creates a Script instance with an input script.
NewSymbolTable creates a SymbolTable.
NewVariable creates a Variable.
NewVM creates a VM.
ToBigFloat will try to convert an object o to a *big.Float value.
ToBigInt will try to convert an object o to a *big.Int value.
ToBool will try to convert object o to bool value.
No description provided by the author
ToByteSlice will try to convert object o to []byte value.
ToFloat64 will try to convert object o to float64 value.
ToInt will try to convert object o to int value.
ToInt will try to convert object o to int32 value.
ToInt64 will try to convert object o to int64 value.
ToInterface attempts to convert an object o to an interface{} value.
ToRune will try to convert object o to rune value.
ToString will try to convert object o to string value.
ToString will try to convert object o to string value.
No description provided by the author
No description provided by the author
ToTime will try to convert object o to time.Time value.
ToUint will try to convert object o to uint value.
ToUint8 will try to convert object o to uint8 value.
No description provided by the author

# Constants

GlobalsSize is the maximum number of global variables for a VM.
MaxFrames is the maximum number of function frames for a VM.
List of symbol scopes.
List of symbol scopes.
List of symbol scopes.
List of symbol scopes.
SourceFileExtDefault is the default extension for source files.
StackSize is the maximum stack size for a VM.

# Variables

ErrBytesLimit represents an error where the size of bytes value exceeds the limit.
No description provided by the author
ErrIndexOutOfBounds is an error where a given index is out of the bounds.
ErrInvalidIndexOnError represents an invalid index on error.
ErrInvalidIndexType represents an invalid index type.
ErrInvalidIndexValueType represents an invalid index value type.
ErrInvalidOperator represents an error for invalid operator usage.
ErrInvalidRangeStep is an error where the step parameter is less than or equal to 0 when using builtin range function.
No description provided by the author
ErrNotImplemented is an error where an Object has not implemented a required method.
ErrNotIndexable is an error where an Object is not indexable.
ErrNotIndexAssignable is an error where an Object is not index assignable.
ErrObjectAllocLimit is an objects allocation limit error.
ErrStackOverflow is a stack overflow error.
ErrStringLimit represents an error where the size of string value exceeds the limit.
ErrVMAborted is an error to denote the VM was forcibly terminated without proper exit.
ErrWrongNumArguments represents a wrong number of arguments error.
ErrWrongNumArguments represents a wrong number of arguments error.
FalseValue represents a false value.
MaxBytesLen is the maximum length for bytes value.
MaxStringLen is the maximum byte-length for string value.
NullValue represents an null value.
TrueValue represents a true value.

# Structs

Array represents an array of objects.
ArrayIterator is an iterator for an array.
BigFloat represents an arbitrary-precision floating-point value.
BigInt represents an arbitrary-precision integer value.
Bool represents a boolean value.
BuiltinFunction represents a builtin function.
BuiltinModule is an importable module that's written in Go.
Bytecode is a compiled instructions and constants.
Bytes represents a byte array.
BytesIterator represents an iterator for a string.
Char represents a character value.
Compiled is a compiled instance of the user script.
CompiledFunction represents a compiled function.
Compiler compiles the AST into a bytecode.
CompilerError represents a compiler error.
ErrInvalidArgumentType represents an invalid argument value type error.
Error represents an error value.
ErrPanic is an error where panic happended in the VM.
Float represents a floating point number value.
ImmutableArray represents an immutable array of objects.
ImmutableMap represents an immutable map object.
Int represents an integer value.
Map represents a map of objects.
MapIterator represents an iterator for the map.
ModuleMap represents a set of named modules.
Null represents an null value.
ObjectImpl represents a default Object Implementation.
ObjectPtr represents a free variable.
Script can simplify compilation and execution of embedded scripts.
SourceModule is an importable module that's written in Tengo.
String represents a string value.
StringIterator represents an iterator for a string.
Symbol represents a symbol in the symbol table.
SymbolTable represents a symbol table.
Time represents a time value.
UserFunction represents a user function.
Variable is a user-defined variable for the script.
VM is a virtual machine that executes the bytecode compiled by Compiler.
VMObj exports VM.

# Interfaces

Importable interface represents importable module instance.
Iterator represents an iterator for underlying data type.
Object represents an object in the VM.

# Type aliases

CallableFunc is a function signature for the callable functions.
SymbolScope represents a symbol scope.