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 ¶
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.
Click to show internal directories.
Click to hide internal directories.