Documentation
¶
Overview ¶
Copyright 2021 Lee R. Boynton
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 Lee R. Boynton
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 Lee R. Boynton
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 Lee R. Boynton
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 Lee R. Boynton
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 Lee R. Boynton
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 Lee R. Boynton
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 Lee R. Boynton
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func Capitalize(s string) string
- func Debug(args ...interface{})
- func FormatComment(indent, prefix, comment string, maxcol int, extraPad bool) string
- func FormattedAnnotation(filename string, source string, prefix string, msg string, tok *Token, ...) string
- func IsDigit(ch rune) bool
- func IsLetter(ch rune) bool
- func IsLowercaseLetter(ch rune) bool
- func IsPreludeType(name string) bool
- func IsSymbolChar(ch rune, first bool) bool
- func IsUppercaseLetter(ch rune) bool
- func IsWhitespace(ch rune) bool
- func StripNamespace(target string) string
- func TrimLeftSpace(s string) string
- func TrimRightSpace(s string) string
- func TrimSpace(s string) string
- func Uncapitalize(s string) string
- func WithCommentTrait(traits *data.Object, namespace string, val string) (*data.Object, string)
- func WithTrait(traits *data.Object, key string, val interface{}) *data.Object
- type AST
- func (ast *AST) AssemblyVersion() int
- func (ast *AST) ExternalRefs(ns string) []string
- func (ast *AST) Filter(tags []string)
- func (ast *AST) GetShape(id string) *Shape
- func (ast *AST) IDL(ns string) string
- func (ast *AST) Merge(src *AST) error
- func (ast *AST) NamespaceAndServiceVersion() (string, string, string)
- func (ast *AST) Namespaces() []string
- func (ast *AST) PutShape(id string, shape *Shape)
- func (ast *AST) RequiresDocumentType() bool
- func (ast *AST) ShapeNames() []string
- func (ast *AST) Validate() error
- func (ast *AST) ValidateDefined(id string, alreadyChecked map[string]*Shape) error
- type ASTParser
- func (p *ASTParser) EndOfFileError() error
- func (p *ASTParser) EnsureNamespaced(name string) string
- func (p *ASTParser) Error(msg string) error
- func (p *ASTParser) Expect(tokenType TokenType) error
- func (p *ASTParser) ExpectIdentifier() (string, error)
- func (p *ASTParser) ExpectIdentifierArray() ([]string, error)
- func (p *ASTParser) ExpectIdentifierMap() (map[string]string, error)
- func (p *ASTParser) ExpectInt() (int, error)
- func (p *ASTParser) ExpectNumber() (*data.Decimal, error)
- func (p *ASTParser) ExpectString() (string, error)
- func (p *ASTParser) ExpectStringArray() ([]string, error)
- func (p *ASTParser) ExpectText() (string, error)
- func (p *ASTParser) GetToken() *Token
- func (p *ASTParser) MergeComment(comment1 string, comment2 string) string
- func (p *ASTParser) Parse() error
- func (p *ASTParser) ParseTraitArgs() (*data.Object, interface{}, error)
- func (p *ASTParser) SyntaxError() error
- func (p *ASTParser) UngetToken()
- func (p *ASTParser) Warning(msg string)
- type AstGenerator
- type BaseGenerator
- func (gen *BaseGenerator) Configure(conf *data.Object) error
- func (gen *BaseGenerator) Emit(text string, filename string, separator string) error
- func (gen *BaseGenerator) FileExists(path string) bool
- func (gen *BaseGenerator) FileName(ns string, suffix string) string
- func (gen *BaseGenerator) WriteFile(path string, content string) error
- type Generator
- type IdlGenerator
- type IdlWriter
- func (w *IdlWriter) Begin()
- func (w *IdlWriter) Emit(format string, args ...interface{})
- func (w *IdlWriter) EmitBlobShape(name string, shape *Shape)
- func (w *IdlWriter) EmitBooleanShape(name string, shape *Shape)
- func (w *IdlWriter) EmitBooleanTrait(b bool, tname, indent string)
- func (w *IdlWriter) EmitCollectionShape(shapeName, name string, shape *Shape)
- func (w *IdlWriter) EmitCustomTrait(k string, v interface{}, indent string)
- func (w *IdlWriter) EmitDeprecatedTrait(v interface{}, indent string)
- func (w *IdlWriter) EmitDocumentation(doc, indent string)
- func (w *IdlWriter) EmitEnumShape(enumType string, name string, shape *Shape)
- func (w *IdlWriter) EmitExamplesTrait(opname string, raw interface{})
- func (w *IdlWriter) EmitHttpErrorTrait(rv interface{}, indent string)
- func (w *IdlWriter) EmitHttpTrait(rv interface{}, indent string)
- func (w *IdlWriter) EmitLengthTrait(v interface{}, indent string)
- func (w *IdlWriter) EmitMapShape(name string, shape *Shape)
- func (w *IdlWriter) EmitNumericShape(shapeName, name string, shape *Shape)
- func (w *IdlWriter) EmitOperationShape(name string, shape *Shape, emitted map[string]bool)
- func (w *IdlWriter) EmitPaginatedTrait(d interface{})
- func (w *IdlWriter) EmitRangeTrait(v interface{}, indent string)
- func (w *IdlWriter) EmitResourceShape(name string, shape *Shape)
- func (w *IdlWriter) EmitServiceShape(name string, shape *Shape)
- func (w *IdlWriter) EmitShape(name string, shape *Shape)
- func (w *IdlWriter) EmitSimpleShape(shapeName, name string, shape *Shape)
- func (w *IdlWriter) EmitStringShape(name string, shape *Shape)
- func (w *IdlWriter) EmitStringTrait(v, tname, indent string)
- func (w *IdlWriter) EmitStructureShape(name string, shape *Shape)
- func (w *IdlWriter) EmitTagsTrait(v interface{}, indent string)
- func (w *IdlWriter) EmitTimestampShape(name string, shape *Shape)
- func (w *IdlWriter) EmitTraitTrait(v interface{})
- func (w *IdlWriter) EmitTraits(traits *data.Object, indent string)
- func (w *IdlWriter) EmitUnionShape(name string, shape *Shape)
- func (w *IdlWriter) End() string
- type Member
- type Members
- type Parser
- type ParserOption
- type SadlGenerator
- type SadlWriter
- func (w *SadlWriter) Begin()
- func (w *SadlWriter) Emit(format string, args ...interface{})
- func (w *SadlWriter) EmitBlobShape(name string, shape *Shape)
- func (w *SadlWriter) EmitBooleanShape(name string, shape *Shape)
- func (w *SadlWriter) EmitCollectionShape(shapeName, name string, shape *Shape)
- func (w *SadlWriter) EmitEnumShape(name string, shape *Shape)
- func (w *SadlWriter) EmitExample(shape *Shape, obj *data.Object)
- func (w *SadlWriter) EmitMapShape(name string, shape *Shape)
- func (w *SadlWriter) EmitNumericShape(shapeName, name string, shape *Shape)
- func (w *SadlWriter) EmitOperationShape(name string, shape *Shape, opts []string)
- func (w *SadlWriter) EmitShape(name string, shape *Shape)
- func (w *SadlWriter) EmitShapeComment(shape *Shape)
- func (w *SadlWriter) EmitStringShape(name string, shape *Shape)
- func (w *SadlWriter) EmitStructureShape(name string, shape *Shape, opts []string)
- func (w *SadlWriter) EmitTimestampShape(name string, shape *Shape)
- func (w *SadlWriter) EmitUnionShape(name string, shape *Shape)
- func (w *SadlWriter) End() string
- type Scanner
- type Shape
- type ShapeRef
- type Shapes
- type Token
- type TokenType
- type Trait
- type TraitDeprecated
- type TraitGeneric
- type TraitInt
- type TraitMarker
- type TraitString
- type TraitTag
- type TraitVisitor
- type TraitWithArgs
- type TraitWithLiteral
Constants ¶
const BLACK = "\033[0;0m"
const BLUE = "\033[94m"
const GREEN = "\033[92m"
const IndentAmount = " "
const RED = "\033[0;31m"
const UnspecifiedNamespace = "example"
const UnspecifiedVersion = "0.0"
const YELLOW = "\033[0;33m"
Variables ¶
var AnnotateSources = false
var ToolVersion string = "development version"
var Verbose bool
Functions ¶
func Capitalize ¶
func FormatComment ¶
func FormattedAnnotation ¶
func IsLowercaseLetter ¶
func IsPreludeType ¶
func IsSymbolChar ¶
func IsUppercaseLetter ¶
func IsWhitespace ¶
func StripNamespace ¶
func TrimLeftSpace ¶
func TrimRightSpace ¶
func Uncapitalize ¶
func WithCommentTrait ¶
Types ¶
type AST ¶
type AST struct {
Smithy string `json:"smithy"`
Metadata *data.Object `json:"metadata,omitempty"`
Shapes *Shapes `json:"shapes,omitempty"`
}
func ParseString ¶ added in v0.5.3
func ParseString(s string, opts ...ParserOption) (*AST, error)
func (*AST) AssemblyVersion ¶
func (*AST) ExternalRefs ¶
func (*AST) NamespaceAndServiceVersion ¶
ASTs don't have a preferred namespace, but IDL files do. When going back to IDL, getting the preferred namespace is desirable. The algorithm here is to prefer the first service's namespace, if present, or the first non-smithy, non-aws namespace encountered.
func (*AST) Namespaces ¶
func (*AST) RequiresDocumentType ¶
func (*AST) ShapeNames ¶
type ASTParser ¶
type ASTParser struct {
// contains filtered or unexported fields
}
func (*ASTParser) EndOfFileError ¶
func (*ASTParser) EnsureNamespaced ¶
func (*ASTParser) ExpectIdentifier ¶
func (*ASTParser) ExpectIdentifierArray ¶
func (*ASTParser) ExpectIdentifierMap ¶
func (*ASTParser) ExpectString ¶
func (*ASTParser) ExpectStringArray ¶
func (*ASTParser) ExpectText ¶
func (*ASTParser) MergeComment ¶
func (*ASTParser) ParseTraitArgs ¶
func (*ASTParser) SyntaxError ¶
func (*ASTParser) UngetToken ¶
func (p *ASTParser) UngetToken()
type AstGenerator ¶
type AstGenerator struct {
BaseGenerator
}
type BaseGenerator ¶
type BaseGenerator struct {
Config *data.Object
OutDir string
ForceOverwrite bool
Err error
// contains filtered or unexported fields
}
func (*BaseGenerator) Emit ¶
func (gen *BaseGenerator) Emit(text string, filename string, separator string) error
func (*BaseGenerator) FileExists ¶
func (gen *BaseGenerator) FileExists(path string) bool
type IdlGenerator ¶
type IdlGenerator struct {
BaseGenerator
}
type IdlWriter ¶
type IdlWriter struct {
// contains filtered or unexported fields
}
func (*IdlWriter) EmitBlobShape ¶
func (*IdlWriter) EmitBooleanShape ¶
func (*IdlWriter) EmitBooleanTrait ¶
func (*IdlWriter) EmitCollectionShape ¶
func (*IdlWriter) EmitCustomTrait ¶
func (*IdlWriter) EmitDeprecatedTrait ¶
func (*IdlWriter) EmitDocumentation ¶
func (*IdlWriter) EmitEnumShape ¶
func (*IdlWriter) EmitExamplesTrait ¶
func (*IdlWriter) EmitHttpErrorTrait ¶
func (*IdlWriter) EmitHttpTrait ¶
func (*IdlWriter) EmitLengthTrait ¶
func (*IdlWriter) EmitMapShape ¶
func (*IdlWriter) EmitNumericShape ¶
func (*IdlWriter) EmitOperationShape ¶
func (*IdlWriter) EmitPaginatedTrait ¶
func (w *IdlWriter) EmitPaginatedTrait(d interface{})
func (*IdlWriter) EmitRangeTrait ¶
func (*IdlWriter) EmitResourceShape ¶
func (*IdlWriter) EmitServiceShape ¶
func (*IdlWriter) EmitSimpleShape ¶
func (*IdlWriter) EmitStringShape ¶
func (*IdlWriter) EmitStringTrait ¶
func (*IdlWriter) EmitStructureShape ¶
func (*IdlWriter) EmitTagsTrait ¶
func (*IdlWriter) EmitTimestampShape ¶
func (*IdlWriter) EmitTraitTrait ¶
func (w *IdlWriter) EmitTraitTrait(v interface{})
func (*IdlWriter) EmitUnionShape ¶
type Members ¶
type Members struct {
// contains filtered or unexported fields
}
Members object is a map from string to *Member. It preserves the order of its keys, unlike a Go map
func NewMembers ¶
func NewMembers() *Members
func (Members) MarshalJSON ¶
func (*Members) UnmarshalJSON ¶
type ParserOption ¶
type ParserOption func(*ASTParser)
func WithTraitVisitors ¶
func WithTraitVisitors(visitors ...TraitVisitor) ParserOption
type SadlGenerator ¶
type SadlGenerator struct {
BaseGenerator
}
type SadlWriter ¶
type SadlWriter struct {
// contains filtered or unexported fields
}
func (*SadlWriter) Begin ¶
func (w *SadlWriter) Begin()
func (*SadlWriter) Emit ¶
func (w *SadlWriter) Emit(format string, args ...interface{})
func (*SadlWriter) EmitBlobShape ¶
func (w *SadlWriter) EmitBlobShape(name string, shape *Shape)
func (*SadlWriter) EmitBooleanShape ¶
func (w *SadlWriter) EmitBooleanShape(name string, shape *Shape)
func (*SadlWriter) EmitCollectionShape ¶
func (w *SadlWriter) EmitCollectionShape(shapeName, name string, shape *Shape)
func (*SadlWriter) EmitEnumShape ¶
func (w *SadlWriter) EmitEnumShape(name string, shape *Shape)
func (*SadlWriter) EmitExample ¶
func (w *SadlWriter) EmitExample(shape *Shape, obj *data.Object)
func (*SadlWriter) EmitMapShape ¶
func (w *SadlWriter) EmitMapShape(name string, shape *Shape)
func (*SadlWriter) EmitNumericShape ¶
func (w *SadlWriter) EmitNumericShape(shapeName, name string, shape *Shape)
func (*SadlWriter) EmitOperationShape ¶
func (w *SadlWriter) EmitOperationShape(name string, shape *Shape, opts []string)
func (*SadlWriter) EmitShape ¶
func (w *SadlWriter) EmitShape(name string, shape *Shape)
func (*SadlWriter) EmitShapeComment ¶
func (w *SadlWriter) EmitShapeComment(shape *Shape)
func (*SadlWriter) EmitStringShape ¶
func (w *SadlWriter) EmitStringShape(name string, shape *Shape)
func (*SadlWriter) EmitStructureShape ¶
func (w *SadlWriter) EmitStructureShape(name string, shape *Shape, opts []string)
func (*SadlWriter) EmitTimestampShape ¶
func (w *SadlWriter) EmitTimestampShape(name string, shape *Shape)
func (*SadlWriter) EmitUnionShape ¶
func (w *SadlWriter) EmitUnionShape(name string, shape *Shape)
func (*SadlWriter) End ¶
func (w *SadlWriter) End() string
type Shape ¶
type Shape struct {
Type string `json:"type"`
Traits *data.Object `json:"traits,omitempty"` //service, resource, operation, apply
//List and Set
Member *Member `json:"member,omitempty"`
//Map
Key *Member `json:"key,omitempty"`
Value *Member `json:"value,omitempty"`
//Structure and Union
Members *Members `json:"members,omitempty"` //keys must be case-insensitively unique. For union, len(Members) > 0,
Mixins []*ShapeRef `json:"mixins,omitempty"` //mixins for the shape
//Resource
Identifiers map[string]*ShapeRef `json:"identifiers,omitempty"`
//FIXME preserve resource identifier order?
Create *ShapeRef `json:"create,omitempty"`
Put *ShapeRef `json:"put,omitempty"`
Read *ShapeRef `json:"read,omitempty"`
Update *ShapeRef `json:"update,omitempty"`
Delete *ShapeRef `json:"delete,omitempty"`
List *ShapeRef `json:"list,omitempty"`
CollectionOperations []*ShapeRef `json:"collectionOperations,omitempty"`
//Resource and Service
Operations []*ShapeRef `json:"operations,omitempty"`
Resources []*ShapeRef `json:"resources,omitempty"`
//Operation
Input *ShapeRef `json:"input,omitempty"`
Output *ShapeRef `json:"output,omitempty"`
Errors []*ShapeRef `json:"errors,omitempty"`
//Service
Version string `json:"version,omitempty"`
}
type Shapes ¶
type Shapes struct {
// contains filtered or unexported fields
}
Shapes object is a map from Shape ID to *Shape. It preserves the order of its keys, unlike a Go map
func (Shapes) MarshalJSON ¶
func (*Shapes) UnmarshalJSON ¶
type TraitDeprecated ¶
type TraitDeprecated struct {
// contains filtered or unexported fields
}
func DeprecatedTrait ¶
func DeprecatedTrait(other TraitVisitor) TraitDeprecated
func (TraitDeprecated) Accepts ¶
func (t TraitDeprecated) Accepts() []string
type TraitGeneric ¶
type TraitGeneric struct{}
func NewTraitGeneric ¶
func NewTraitGeneric() TraitGeneric
func (TraitGeneric) Accepts ¶
func (t TraitGeneric) Accepts() []string
type TraitMarker ¶
type TraitMarker struct {
Trait
}
func NewTraitMarker ¶
func NewTraitMarker(namespace string, accepts ...string) TraitMarker
type TraitString ¶
type TraitString struct {
Trait
// contains filtered or unexported fields
}
func NewTraitString ¶
func NewTraitString(namespace string, comments bool, accepts ...string) TraitString
type TraitVisitor ¶
type TraitVisitor interface {
Accepts() []string
Parse(p Parser, name string, traits *data.Object) (*data.Object, error)
}
func DefaultTraitVisitors ¶
func DefaultTraitVisitors() []TraitVisitor
type TraitWithArgs ¶
type TraitWithArgs struct {
Trait
}
func NewTraitWithArgs ¶
func NewTraitWithArgs(namespace string, accepts ...string) TraitWithArgs
type TraitWithLiteral ¶
type TraitWithLiteral struct {
Trait
}
func NewTraitWithLiteral ¶
func NewTraitWithLiteral(namespace string, accepts ...string) TraitWithLiteral