bytecode

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: MIT Imports: 9 Imported by: 0

README

Bytecode query parser

This is a test to improve the query parsing and resolve speed.

Currently this is no-where used and still a WIP.

How to understand it?

Currently the best way to understand the bytecode is to read:

  • bytecode_test.go and testing_framework.go to see what query results in what bytecode
  • bytecode_instructions.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action = byte

Action defines an action that should be taken based when parsing the schema

const (
	ActionEnd              Action = 'e'
	ActionOperator         Action = 'o'
	ActionOperatorArgs     Action = 'A'
	ActionOperatorArg      Action = 'a'
	ActionField            Action = 'f'
	ActionSpread           Action = 's'
	ActionFragment         Action = 'F'
	ActionValue            Action = 'v'
	ActionObjectValueField Action = 'u'
	ActionDirective        Action = 'd'
)

All possible actions

type ErrorWLocation

type ErrorWLocation struct {
	Err    error
	Line   uint
	Column uint
}

ErrorWLocation is an error with a location in a file

func (ErrorWLocation) Error

func (e ErrorWLocation) Error() string

Error implements the error interface

type OperatorKind

type OperatorKind = byte

OperatorKind defines the kind of operation

const (
	OperatorQuery        OperatorKind = 'q'
	OperatorMutation     OperatorKind = 'm'
	OperatorSubscription OperatorKind = 's'
)

All possible operators

type ParserCtx

type ParserCtx struct {
	Res               []byte
	FragmentLocations []int
	Query             []byte

	Errors []error

	TargetIdx int // -1 = no matching target was found, >= 0 = res index of target
	Hasher    hash.Hash32

	CacheableQueryMinLen int // Default = 300
	// contains filtered or unexported fields
}

ParserCtx has all the information needed to parse a query

func NewParserCtx

func NewParserCtx() *ParserCtx

NewParserCtx returns a new instance of ParserCtx

func (*ParserCtx) ParseQueryToBytecode

func (ctx *ParserCtx) ParseQueryToBytecode(target *string)

ParseQueryToBytecode parses (*ParserCtx).Query into (*ParserCtx).Res target is a optional string that can be set to define a operator target

type ValueKind

type ValueKind = byte

ValueKind defines a input value kind

const (
	ValueVariable ValueKind = '$'
	ValueInt      ValueKind = 'i'
	ValueFloat    ValueKind = 'f'
	ValueString   ValueKind = 's'
	ValueBoolean  ValueKind = 'b'
	ValueNull     ValueKind = 'n'
	ValueEnum     ValueKind = 'e'
	ValueList     ValueKind = 'l'
	ValueObject   ValueKind = 'o'
)

All possible value kinds

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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