diff --git a/README.md b/README.md index a5386d3..d38ba77 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,38 @@ -# WebAssembly Interface Definition Language (WIDL) for Golang +# Apex Language support for Golang -WIDL is a schema format for describing [waPC](https://github.com/wapc) modules and used by the [CLI](https://github.com/wapc/cli) to generate code for the supported guest languages. It heavily resembles [GraphQL schema](https://graphql.org/learn/schema/) but with some variations to fit better in the WebAssembly ecosystem. +TODO -* Built-in WebAssembly numeric types (i8-64, i8-64, f32, f64) - no scalars required -* Scalars explicitly alias a known type -* Functions can return `void` instead of returning `Boolean` as a workaround -* Fields are required by default instead of optional and `?` is used after the field name to denote that it is optional -* Support for maps -* Operations are defined in a single interface instead of separating query and mutation operations -* Removed the concepts that do not apply from GraphQL schema (e.g. Queries vs. Mutations, Field arguments, Variables, Fragments) +```golang +package main -Everything in this package was borrowed and retrofitted from the awesome [Golang GraphQL library](https://github.com/graphql-go/graphql). We thank the 70+ contributors to this project! It has enabled us to provide a succinct interface definition language to our users with minimal effort. \ No newline at end of file +import ( + "encoding/json" + "fmt" + "os" + + "github.com/apexlang/apex-go/parser" +) + +func main() { + schema, err := os.ReadFile("schema.apex") + if err != nil { + panic(err) + } + doc, err := parser.Parse(parser.ParseParams{ + Source: string(schema), + Options: parser.ParseOptions{ + NoLocation: true, + NoSource: true, + }, + }) + if err != nil { + panic(err) + } + + jsonBytes, err := json.MarshalIndent(doc, "", " ") + if err != nil { + panic(err) + } + fmt.Println(string(jsonBytes)) +} +``` \ No newline at end of file diff --git a/ast/definitions.go b/ast/definitions.go index ae34ac3..6ec1dbe 100644 --- a/ast/definitions.go +++ b/ast/definitions.go @@ -1,6 +1,6 @@ package ast -import "github.com/wapc/widl-go/kinds" +import "github.com/apexlang/apex-go/kinds" type ( Definition interface { diff --git a/ast/document.go b/ast/document.go index ac71ae8..331d528 100644 --- a/ast/document.go +++ b/ast/document.go @@ -1,7 +1,7 @@ package ast import ( - "github.com/wapc/widl-go/kinds" + "github.com/apexlang/apex-go/kinds" ) // Document implements Node diff --git a/ast/location.go b/ast/location.go index be88fd1..ec0811b 100644 --- a/ast/location.go +++ b/ast/location.go @@ -1,7 +1,7 @@ package ast import ( - "github.com/wapc/widl-go/source" + "github.com/apexlang/apex-go/source" ) type Location struct { diff --git a/ast/nodes.go b/ast/nodes.go index 8d8a887..f33018a 100644 --- a/ast/nodes.go +++ b/ast/nodes.go @@ -1,6 +1,6 @@ package ast -import "github.com/wapc/widl-go/kinds" +import "github.com/apexlang/apex-go/kinds" type Node interface { GetKind() kinds.Kind diff --git a/ast/types.go b/ast/types.go index c91dadc..7abe2f6 100644 --- a/ast/types.go +++ b/ast/types.go @@ -1,7 +1,7 @@ package ast import ( - "github.com/wapc/widl-go/kinds" + "github.com/apexlang/apex-go/kinds" ) type Type interface { diff --git a/ast/values.go b/ast/values.go index 2bc9ffe..ef79dba 100644 --- a/ast/values.go +++ b/ast/values.go @@ -1,6 +1,6 @@ package ast -import "github.com/wapc/widl-go/kinds" +import "github.com/apexlang/apex-go/kinds" type Value interface { Node diff --git a/errors/error.go b/errors/error.go index e7261be..681f2b9 100644 --- a/errors/error.go +++ b/errors/error.go @@ -4,9 +4,9 @@ import ( "fmt" "reflect" - "github.com/wapc/widl-go/ast" - "github.com/wapc/widl-go/location" - "github.com/wapc/widl-go/source" + "github.com/apexlang/apex-go/ast" + "github.com/apexlang/apex-go/location" + "github.com/apexlang/apex-go/source" ) type Error struct { diff --git a/errors/syntax.go b/errors/syntax.go index 3ed2cd2..6951db2 100644 --- a/errors/syntax.go +++ b/errors/syntax.go @@ -5,9 +5,9 @@ import ( "regexp" "strings" - "github.com/wapc/widl-go/ast" - "github.com/wapc/widl-go/location" - "github.com/wapc/widl-go/source" + "github.com/apexlang/apex-go/ast" + "github.com/apexlang/apex-go/location" + "github.com/apexlang/apex-go/source" ) func NewSyntaxError(s *source.Source, position uint, description string) *Error { diff --git a/go.mod b/go.mod index 06c7366..b24a86c 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/wapc/widl-go +module github.com/apexlang/apex-go go 1.16 diff --git a/lexer/lexer.go b/lexer/lexer.go index f214e3d..66785c4 100644 --- a/lexer/lexer.go +++ b/lexer/lexer.go @@ -7,8 +7,8 @@ import ( "strings" "unicode/utf8" - "github.com/wapc/widl-go/errors" - "github.com/wapc/widl-go/source" + "github.com/apexlang/apex-go/errors" + "github.com/apexlang/apex-go/source" ) const ( diff --git a/location/location.go b/location/location.go index dec4055..c352b90 100644 --- a/location/location.go +++ b/location/location.go @@ -3,7 +3,7 @@ package location import ( "regexp" - "github.com/wapc/widl-go/source" + "github.com/apexlang/apex-go/source" ) type SourceLocation struct { diff --git a/parser/parser.go b/parser/parser.go index f112102..58a410e 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -4,10 +4,10 @@ import ( "fmt" "strconv" - "github.com/wapc/widl-go/ast" - "github.com/wapc/widl-go/errors" - "github.com/wapc/widl-go/lexer" - "github.com/wapc/widl-go/source" + "github.com/apexlang/apex-go/ast" + "github.com/apexlang/apex-go/errors" + "github.com/apexlang/apex-go/lexer" + "github.com/apexlang/apex-go/source" ) type parseFn func(parser *Parser) (interface{}, error)