parser

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lexer

type Lexer interface {
	SetTypeSystemInput(input []byte) error
	ExtendTypeSystemInput(input []byte) error
	ResetTypeSystemInput()
	SetExecutableInput(input []byte) error
	AppendBytes(input []byte) (err error)
	Read() (tok token.Token)
	Peek(ignoreWhitespace bool) keyword.Keyword
	ByteSlice(reference document.ByteSliceReference) document.ByteSlice
	TextPosition() position.Position
}

Lexer is the interface used by the Parser to lex tokens

type ManualAstMod added in v1.2.0

type ManualAstMod struct {
	// contains filtered or unexported fields
}

ManualAstMod keeps functions to manually modify the parsed ast

func NewManualAstMod added in v1.2.0

func NewManualAstMod(p *Parser) *ManualAstMod

func (*ManualAstMod) AppendFieldToSelectionSet added in v1.2.0

func (m *ManualAstMod) AppendFieldToSelectionSet(fieldRef, setRef int)

func (*ManualAstMod) DeleteFieldFromSelectionSet added in v1.2.0

func (m *ManualAstMod) DeleteFieldFromSelectionSet(fieldRef, setRef int)

func (*ManualAstMod) MergeArgIntoFieldArguments added in v1.3.0

func (m *ManualAstMod) MergeArgIntoFieldArguments(argRef, fieldRef int)

func (*ManualAstMod) PutArgument added in v1.3.0

func (m *ManualAstMod) PutArgument(argument document.Argument) int

func (*ManualAstMod) PutArgumentSet added in v1.3.0

func (m *ManualAstMod) PutArgumentSet(set document.ArgumentSet) int

func (*ManualAstMod) PutField added in v1.2.0

func (m *ManualAstMod) PutField(field document.Field) int

func (*ManualAstMod) PutLiteralBytes added in v1.3.0

func (m *ManualAstMod) PutLiteralBytes(literal []byte) (byteSliceRef document.ByteSliceReference, ref int, err error)

PutLiteralBytes appends a literal to the end of the lexer input storage before appending the lexer will read forward until EOF by doing this we make sure there's no unexpected content at the end of the input this step is necessary because clients like curl end a request by appending a newline ('\n') the parser does not expect a newLine at the end of the input so we have to read over it

func (*ManualAstMod) PutLiteralString added in v1.3.0

func (m *ManualAstMod) PutLiteralString(literal string) (byteSliceRef document.ByteSliceReference, ref int, err error)

func (*ManualAstMod) PutValue added in v1.3.0

func (m *ManualAstMod) PutValue(value document.Value) int

func (*ManualAstMod) SetMutationTypeName added in v1.3.0

func (m *ManualAstMod) SetMutationTypeName(name document.ByteSliceReference)

func (*ManualAstMod) SetQueryTypeName added in v1.3.0

func (m *ManualAstMod) SetQueryTypeName(name document.ByteSliceReference)

func (*ManualAstMod) SetSubscriptionTypeName added in v1.3.0

func (m *ManualAstMod) SetSubscriptionTypeName(name document.ByteSliceReference)

type Option

type Option func(options *Options)

func WithMinimumSliceSize

func WithMinimumSliceSize(size int) Option

func WithPoolSize

func WithPoolSize(poolSize int) Option

type Options

type Options struct {
	// contains filtered or unexported fields
}

type ParsedDefinitions

type ParsedDefinitions struct {
	TypeSystemDefinition document.TypeSystemDefinition
	ExecutableDefinition document.ExecutableDefinition

	OperationDefinitions       document.OperationDefinitions
	FragmentDefinitions        document.FragmentDefinitions
	VariableDefinitions        document.VariableDefinitions
	Fields                     document.Fields
	InlineFragments            document.InlineFragments
	FragmentSpreads            document.FragmentSpreads
	Arguments                  document.Arguments
	ArgumentSets               []document.ArgumentSet
	Directives                 document.Directives
	DirectiveSets              []document.DirectiveSet
	EnumTypeDefinitions        []document.EnumTypeDefinition
	ArgumentsDefinitions       document.ArgumentsDefinitions
	EnumValuesDefinitions      []document.EnumValueDefinition
	FieldDefinitions           []document.FieldDefinition
	InputValueDefinitions      []document.InputValueDefinition
	InputObjectTypeDefinitions document.InputObjectTypeDefinitions
	DirectiveDefinitions       document.DirectiveDefinitions
	InterfaceTypeDefinitions   document.InterfaceTypeDefinitions
	ObjectTypeDefinitions      document.ObjectTypeDefinitions
	ScalarTypeDefinitions      document.ScalarTypeDefinitions
	UnionTypeDefinitions       document.UnionTypeDefinitions
	InputFieldsDefinitions     []document.InputFieldsDefinition
	Values                     []document.Value
	ListValues                 []document.ListValue
	ObjectValues               []document.ObjectValue
	ObjectFields               document.ObjectFields
	Types                      document.Types
	SelectionSets              []document.SelectionSet

	ByteSliceReferences []document.ByteSliceReference
	Integers            []int32
	Floats              []float32
	Booleans            [2]bool
}

ParsedDefinitions contains all parsed definitions to avoid deeply nested data structures while parsing

type Parser

type Parser struct {
	ParsedDefinitions ParsedDefinitions
	// contains filtered or unexported fields
}

Parser holds the lexer and a buffer for writing literals

func NewParser

func NewParser(withOptions ...Option) *Parser

NewParser returns a new parser using a buffered runestringer

func (*Parser) ByteSlice

func (p *Parser) ByteSlice(reference document.ByteSliceReference) document.ByteSlice

func (*Parser) CachedByteSlice

func (p *Parser) CachedByteSlice(i int) document.ByteSlice

func (*Parser) EnumValueDefinition added in v1.5.0

func (p *Parser) EnumValueDefinition(ref int) document.EnumValueDefinition

func (*Parser) ExtendTypeSystemDefinition added in v1.6.0

func (p *Parser) ExtendTypeSystemDefinition(input []byte) (err error)

func (*Parser) FieldDefinition added in v1.5.0

func (p *Parser) FieldDefinition(ref int) document.FieldDefinition

func (*Parser) IndexPoolGet added in v1.4.0

func (p *Parser) IndexPoolGet() []int

func (*Parser) InitDirectiveSet

func (p *Parser) InitDirectiveSet(set *document.DirectiveSet)

func (*Parser) InputValueDefinition added in v1.5.0

func (p *Parser) InputValueDefinition(ref int) document.InputValueDefinition

func (*Parser) ParseExecutableDefinition

func (p *Parser) ParseExecutableDefinition(input []byte) (err error)

ParseExecutableDefinition parses an ExecutableDefinition from an io.Reader

func (*Parser) ParseIntrospectionResponse added in v1.3.0

func (p *Parser) ParseIntrospectionResponse(response *introspection.Response) (err error)

func (*Parser) ParseTypeSystemDefinition

func (p *Parser) ParseTypeSystemDefinition(input []byte) (err error)

ParseTypeSystemDefinition parses a TypeSystemDefinition from an io.Reader

func (*Parser) TextPosition

func (p *Parser) TextPosition() position.Position

Jump to

Keyboard shortcuts

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