lang

package
v0.0.0-...-453cd44 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: GPL-3.0 Imports: 21 Imported by: 9

Documentation

Overview

Package lang is the mcl language frontend that implements the reactive DSL that lets users model their desired state over time.

Index

Constants

View Source
const (
	// EngineStartupStatsTimeout is the amount of time in seconds to wait
	// between engine startup, and loaded event before printing some
	// debugging stats. This is useful for finding bugs in the function
	// engine. Set to zero to disable.
	EngineStartupStatsTimeout = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	// UnificationStrategy is a hack to tune unification performance until
	// we have an overall cleaner unification algorithm in place.
	UnificationStrategy map[string]string
}

Data is some data that is passed into the Lang struct. It is presented here as a single struct with room for multiple fields so that it can be changed or extended in the future without having to re-plumb through all the fields it contains

type Lang

type Lang struct {
	Fs    engine.Fs // connected fs where input dir or metadata exists
	FsURI string

	// Input is a string which specifies what the lang should run. It can
	// accept values in several different forms. If is passed a single dash
	// (-), then it will use `os.Stdin`. If it is passed a single .mcl file,
	// then it will attempt to run that. If it is passed a directory path,
	// then it will attempt to run from there. Instead, if it is passed the
	// path to a metadata file, then it will attempt to parse that and run
	// from that specification. If none of those match, it will attempt to
	// run the raw string as mcl code.
	Input string

	// Data is some additional data for the lang struct.
	Data *Data

	Hostname string
	Local    *local.API
	World    engine.World
	Prefix   string
	Debug    bool
	Logf     func(format string, v ...interface{})
	// contains filtered or unexported fields
}

Lang is the main language lexer/parser object.

func (*Lang) Cleanup

func (obj *Lang) Cleanup() error

Cleanup cleans up and frees memory and resources after everything is done.

func (*Lang) Init

func (obj *Lang) Init(ctx context.Context) error

Init initializes the lang struct, and starts up the initial input parsing. NOTE: The trick is that we need to get the list of funcs to watch AND start watching them, *before* we pull their values, that way we'll know if they changed from the values we wanted.

func (*Lang) Interpret

func (obj *Lang) Interpret() (*pgraph.Graph, error)

Interpret runs the interpreter and returns a graph and corresponding error.

func (*Lang) Run

func (obj *Lang) Run(ctx context.Context) (reterr error)

Run kicks off the function engine. Use the context to shut it down.

func (*Lang) Stream

func (obj *Lang) Stream() <-chan error

Stream returns a channel of graph change requests or errors. These are usually sent when a func output changes.

Directories

Path Synopsis
Package ast contains the structs implementing and some utility functions for interacting with the abstract syntax tree for the mcl language.
Package ast contains the structs implementing and some utility functions for interacting with the abstract syntax tree for the mcl language.
Package core contains core functions and other related facilities which are used in programs.
Package core contains core functions and other related facilities which are used in programs.
fmt
net
os
sys
Package download is used for downloading language modules from git.
Package download is used for downloading language modules from git.
Package embedded embeds mcl modules into the system import namespace.
Package embedded embeds mcl modules into the system import namespace.
Package funcs provides a framework for functions that change over time.
Package funcs provides a framework for functions that change over time.
dage
Package dage implements a DAG function engine.
Package dage implements a DAG function engine.
facts
Package facts provides a framework for language values that change over time.
Package facts provides a framework for language values that change over time.
funcgen/util
Package util provides some functions to be imported by the generated file.
Package util provides some functions to be imported by the generated file.
ref
Package ref implements reference counting for the graph API and function engine.
Package ref implements reference counting for the graph API and function engine.
txn
Package txn contains the implementation of the graph transaction system.
Package txn contains the implementation of the graph transaction system.
vars
Package vars provides a framework for language vars.
Package vars provides a framework for language vars.
Package gapi is the Graph API implementation for the mcl language frontend.
Package gapi is the Graph API implementation for the mcl language frontend.
Package inputs contains the input parsing logic for how mcl module entrypoints are handled for the language.
Package inputs contains the input parsing logic for how mcl module entrypoints are handled for the language.
Package interfaces contains the common interfaces used in the mcl language.
Package interfaces contains the common interfaces used in the mcl language.
Package interpolate contains the string interpolation parser and associated structs and code.
Package interpolate contains the string interpolation parser and associated structs and code.
Package interpret contains the implementation of the actual interpret function that takes an AST and returns a resource graph.
Package interpret contains the implementation of the actual interpret function that takes an AST and returns a resource graph.
Package parser contains the lexer and parser for the mcl language.
Package parser contains the lexer and parser for the mcl language.
Package types provides a framework for our mcl language values and types.
Package types provides a framework for our mcl language values and types.
Package unification contains the code related to type unification for the mcl language.
Package unification contains the code related to type unification for the mcl language.
solvers
Package solvers is used to have a central place to import all solvers from.
Package solvers is used to have a central place to import all solvers from.
Package util contains utility functions that are specific to the mcl language.
Package util contains utility functions that are specific to the mcl language.

Jump to

Keyboard shortcuts

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