syntax

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2026 License: Apache-2.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package syntax parses and formats the compact OpenRealtime graph language. It deliberately contains no type checking or runtime behavior; every frontend lowers into the same elaborator after producing this AST.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(file File) string

Format returns the canonical textual representation of a parsed graph. It preserves declaration order and leading comments while normalizing spacing.

Types

type Boundary

type Boundary struct {
	Direction BoundaryDirection `json:"direction"`
	Name      string            `json:"name"`
	Endpoint  Endpoint          `json:"endpoint"`
	Comments  []string          `json:"comments,omitempty"`
	Span      Span              `json:"span"`
}

Boundary exports an internal port as part of the composite graph contract. Input boundaries bind an internal input; output boundaries bind an internal output. Their types are inferred from that port.

type BoundaryDirection

type BoundaryDirection string

BoundaryDirection is relative to the composite graph.

const (
	BoundaryInput  BoundaryDirection = "input"
	BoundaryOutput BoundaryDirection = "output"
)

type Delivery

type Delivery string

Delivery is the one ordinary edge-level choice exposed by .ortg.

const (
	Lossless Delivery = "lossless"
	Lossy    Delivery = "lossy"
)

type Edge

type Edge struct {
	Name     string   `json:"name,omitempty"`
	From     Endpoint `json:"from"`
	To       Endpoint `json:"to"`
	Delivery Delivery `json:"delivery"`
	Comments []string `json:"comments,omitempty"`
	Span     Span     `json:"span"`
}

Edge connects one output port group to one input port group. Name is empty unless the author needs a stable identity independent of its endpoints.

func (Edge) Identity

func (edge Edge) Identity() string

Identity returns the stable edge identifier emitted into Graph IR. Named edges keep their authored name; unnamed edges are identified by their exact endpoint pair. Keeping this rule on the syntax value prevents compiler and visual-editor mutation paths from inventing subtly different identities.

type Endpoint

type Endpoint struct {
	Node string `json:"node"`
	Port string `json:"port"`
	Span Span   `json:"span"`
}

Endpoint refers to a named port group. Variadic lanes are inferred from edges and therefore never appear in source.

func (Endpoint) String

func (endpoint Endpoint) String() string

type Error

type Error struct {
	Path    string
	Span    Span
	Message string
}

Error is a source-mapped syntax diagnostic.

func (*Error) Error

func (failure *Error) Error() string

type File

type File struct {
	Path    string   `json:"path,omitempty"`
	Imports []Import `json:"imports,omitempty"`
	Graph   Graph    `json:"graph"`
}

File is one parsed .ortg source file.

func Parse

func Parse(path string, source []byte) (File, error)

Parse parses one complete .ortg file.

type Graph

type Graph struct {
	Name             string      `json:"name"`
	Comments         []string    `json:"comments,omitempty"`
	Statements       []Statement `json:"statements,omitempty"`
	TrailingComments []string    `json:"trailing_comments,omitempty"`
	Span             Span        `json:"span"`
}

Graph is a named element graph. Statement order is preserved for readable formatting; semantic identity is established later by canonical Graph IR.

func (Graph) Boundaries

func (graph Graph) Boundaries() []Boundary

Boundaries returns declarations in source order.

func (Graph) Edges

func (graph Graph) Edges() []Edge

Edges returns declarations in source order.

func (Graph) Nodes

func (graph Graph) Nodes() []Node

Nodes returns declarations in source order.

type Import

type Import struct {
	Path     string   `json:"path"`
	Alias    string   `json:"alias,omitempty"`
	Comments []string `json:"comments,omitempty"`
	Span     Span     `json:"span"`
}

Import makes another graph library available to symbolic resolution.

type Node

type Node struct {
	Element  string   `json:"element"`
	Name     string   `json:"name"`
	Comments []string `json:"comments,omitempty"`
	Span     Span     `json:"span"`
}

Node instantiates one symbolic element or subgraph contract.

type Position

type Position struct {
	Offset int `json:"offset"`
	Line   int `json:"line"`
	Column int `json:"column"`
}

Position identifies one byte location in a source file. Line and Column are one-based; Offset is zero-based.

type Recovery

type Recovery struct {
	File        File
	Complete    bool
	Diagnostics []Error
}

Recovery is a best-effort immutable syntax snapshot for language tooling. Complete is true only when the strict parser accepted the entire source. A recovered File must never be passed to the graph compiler.

func Recover

func Recover(path string, source []byte, limits RecoveryLimits) (Recovery, error)

Recover lexes an incomplete .ortg buffer and retains only complete, semicolon-terminated statements. It synchronizes at semicolons and the graph closing brace, so one malformed statement cannot manufacture a neighboring declaration. Strict Parse remains the only compilation boundary.

type RecoveryLimits

type RecoveryLimits struct {
	MaxSourceBytes int
	MaxTokens      int
	MaxStatements  int
	MaxDiagnostics int
}

RecoveryLimits bounds the lexer and synchronization work used for an incomplete editor buffer. Recovery is never used by Parse or compilation.

func DefaultRecoveryLimits

func DefaultRecoveryLimits() RecoveryLimits

DefaultRecoveryLimits returns interactive, independently bounded defaults.

type Span

type Span struct {
	Start Position `json:"start"`
	End   Position `json:"end"`
}

Span is a half-open source range.

type Statement

type Statement struct {
	Node     *Node     `json:"node,omitempty"`
	Edge     *Edge     `json:"edge,omitempty"`
	Boundary *Boundary `json:"boundary,omitempty"`
}

Statement is exactly one node, edge, or exported boundary declaration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL