The Midio textual representation
Midio programs are stored using a textual representation, which maps almost one to one with the visual representation.
Midio Language Syntax
Midio is a declarative programming language with a textual representation, designed for node-based programming. Its primary features include the ability to define modules, functions, events, and properties, as well as supporting native implementation through external functions. This section provides an overview of the syntax used in Midio.
!!! note The midio textual representation is not designed to be written by hand, but is means to at least be understandable by a human. The syntax is easy enough to understand, but it is hard to get a sense of what a program is doing by only looking at the textual representation.
Modules
Modules in Midio are containers for functions and other elements. The hidden attribute determines whether the module should be visible in the editor or not.
module ModuleName {
// Module content (functions, events, types, nodes and arrows)
}
Functions
Functions in Midio can be either user-defined or external (native) functions.
User-defined functions:
func FunctionName {
// input and output and parameter declarations
in trigger execute
out trigger continue
in property input1
out property output1
// function body (node instances and arrows)
}
External functions:
extern func FunctionName {
// only input and output and parameter declarations
}
External functions have a native implementation in Rust and cannot have a body.
Inputs, and Outputs
Inputs, and outputs are defined within functions using the in, out, and event keywords:
in(name: "inputName") property(Type) inputVariableName
out(name: "outputName") property(Type) outputVariableName
Parameters
Parameters provide compile-time information to instances of functions:
func Foo {
parameter paramName
}
instance myFoo Foo { paramName: 123 }
Only compile time known values are supported to parameters, like number, string or complex literals.
Instances
Function nodes are created using the instance
keyword:
import("std", Std)
module Main {
instance foo Std.Std.Log { /* parameters here */ }
}
Attributes
Attributes are enclosed in parentheses, following the element they belong to:
module(attributeName: attributeValue) ModuleName
func(attributeName: attributeValue) FunctionName
event(attributeName: attributeValue) EventName
in(attributeName: attributeValue) property(Type) inputVariableName
out(attributeName: attributeValue) property(Type) outputVariableName
Properties and Types
Properties in Midio are used to store values and are declared with a type:
property(Type) propertyName
Identifiers
Identifiers in Midio follow conventional rules from languages like JavaScript, C, or Rust, which include:
Starting with a letter, underscore
Continuing with any combination of letters, digits, underscores.
Verbatim identifiers are delimited by double backticks, and then support any string - they can start with numbers and contain whitespaces
``1. This is a valid identifier``
Instances and Arrows
In the body of user-defined functions, instances of other functions and arrows are used to connect them:
instance(x: xPosition, y: yPosition, name: "InstanceName") instanceVariableName FunctionType {
}
inputPropertyName -> instanceVariableName.propertyName
instanceVariableName.propertyName -> outputPropertyName
This is a general overview of the syntax used in Midio. The language is designed to support a node-based programming paradigm, allowing for a flexible and visual approach to developing software.
Last updated
Was this helpful?