golang

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package golang provides a golang codegen backend for the asyncpi package.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(p asyncpi.Process, w io.Writer) error

Generate writes Go code of the Process to w.

Example

This example shows how to generate code from a Process.

package main

import (
	"fmt"
	"os"
	"strings"

	"go.nickng.io/asyncpi"
	"go.nickng.io/asyncpi/codegen/golang"
	"go.nickng.io/asyncpi/types"
)

func main() {
	p, err := asyncpi.Parse(strings.NewReader("(new a)(new b)(a<b> | a(x).x<> | b().0)"))
	if err != nil {
		fmt.Println(err) // Parse failed
	}
	if err := asyncpi.Bind(&p); err != nil {
		fmt.Println(err)
	}
	types.Infer(p)
	err = types.Unify(p)
	if err != nil {
		fmt.Println(err) // Unify failed
	}
	golang.Generate(p, os.Stdout)
}
Output:

a := make(chan chan struct{}); b := make(chan struct{}); go func(){ go func(){ a <- b; }()
x := <-a;x <- struct{}{}; }()
<-b;/* end */

Types

This section is empty.

Jump to

Keyboard shortcuts

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