Documentation
¶
Overview ¶
builtins.go installs the MX Script standard library into the global environment. Every native function is registered here so they're available in every .mx program without an import.
Package interpreter is the heart of MX Script. It walks the parsed AST, evaluates expressions, drives the standard library, and (when route declarations are present) starts an HTTP server that dispatches incoming requests to user-defined route bodies.
parse_helper.go wires the interpreter's import statement to the lexer and parser without forcing the consumer of this package to do it themselves.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
type Interpreter ¶
type Interpreter struct {
// contains filtered or unexported fields
}
func (*Interpreter) Run ¶
func (i *Interpreter) Run(prog *parser.Program) error
Run executes a parsed program. If the program declared any routes, it boots an HTTP server and blocks; otherwise it returns once the top-level statements have all been evaluated.
func (*Interpreter) SetFile ¶
func (i *Interpreter) SetFile(path string)
SetFile records the source file path for error messages.
func (*Interpreter) SetPort ¶
func (i *Interpreter) SetPort(p int)
SetPort marks the CLI-provided port. It overrides any port set by the program's `server { port: ... }` block so `mx run --port 3000` always wins.
type OrderedMap ¶
OrderedMap preserves insertion order of object keys for predictable JSON output.
func NewOrderedMap ¶
func NewOrderedMap() *OrderedMap
func (*OrderedMap) Set ¶
func (o *OrderedMap) Set(k string, v Value)
type Value ¶
type Value struct {
Kind ValueKind
Bool bool
Number float64
String string
Array []Value
Object *OrderedMap
Function *Function
Response *Response
}
func ArrayValue ¶
func FunctionValue ¶
func NumberValue ¶
func ObjectValue ¶
func ObjectValue(o *OrderedMap) Value