grammar

package
v1.40.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SPACE_RULE = `" "?`

	PRIMITIVE_RULES = map[string]string{
		"boolean": `("true" | "false") space`,
		"number":  `("-"? ([0-9] | [1-9] [0-9]*)) ("." [0-9]+)? ([eE] [-+]? [0-9]+)? space`,
		"integer": `("-"? ([0-9] | [1-9] [0-9]*)) space`,
		"string": `"\"" (
			[^"\\] |
			"\\" (["\\/bfnrt] | "u" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F])
		  )* "\"" space`,
		"null": `"null" space`,
	}

	INVALID_RULE_CHARS_RE     = regexp.MustCompile(`[^a-zA-Z0-9-]+`)
	GRAMMAR_LITERAL_ESCAPE_RE = regexp.MustCompile(`[\r\n"]`)
	GRAMMAR_LITERAL_ESCAPES   = map[string]string{
		"\r": `\r`,
		"\n": `\n`,
		`"`:  `\"`,
	}
)

Functions

This section is empty.

Types

type Argument

type Argument struct {
	Type       string                 `json:"type"`
	Properties map[string]interface{} `json:"properties"`
}

type Function

type Function struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Parameters  map[string]interface{} `json:"parameters"`
}

type FunctionName

type FunctionName struct {
	Const string `json:"const"`
}

type Functions

type Functions []Function

func (Functions) Select

func (f Functions) Select(name string) Functions

Select returns a list of functions containing the function with the given name

func (Functions) ToJSONStructure

func (f Functions) ToJSONStructure() JSONFunctionStructure

type Item

type Item struct {
	Type       string     `json:"type"`
	Properties Properties `json:"properties"`
}

type JSONFunctionStructure

type JSONFunctionStructure struct {
	OneOf []Item                 `json:"oneOf,omitempty"`
	AnyOf []Item                 `json:"anyOf,omitempty"`
	Defs  map[string]interface{} `json:"$defs,omitempty"`
}

func (JSONFunctionStructure) Grammar

func (j JSONFunctionStructure) Grammar(propOrder string) string

type JSONSchemaConverter

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

func NewJSONSchemaConverter

func NewJSONSchemaConverter(propOrder string) *JSONSchemaConverter

func (*JSONSchemaConverter) Grammar

func (sc *JSONSchemaConverter) Grammar(schema map[string]interface{}) string

func (*JSONSchemaConverter) GrammarFromBytes

func (sc *JSONSchemaConverter) GrammarFromBytes(b []byte) string

type Properties

type Properties struct {
	Function  FunctionName `json:"function"`
	Arguments Argument     `json:"arguments"`
}

Jump to

Keyboard shortcuts

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