constraint

package
v1.6.69 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAllOrEmpty

func IsAllOrEmpty(c Constraint) bool

func IsBlank

func IsBlank(c Constraint) bool

func IsBlankLimit

func IsBlankLimit(l Limit) bool

func IsGeneric

func IsGeneric(c Constraint) bool

func IsGenericLimit

func IsGenericLimit(c Limit) bool

func IsNull

func IsNull(c Constraint) bool

func IsNullLimit

func IsNullLimit(l Limit) bool

func Parse

func Parse(filename string, b []byte, opts ...Option) (any, error)

Parse parses the data from b using filename as information in the error messages.

func ParseFile

func ParseFile(filename string, opts ...Option) (i any, err error)

ParseFile parses the file identified by filename.

func ParseReader

func ParseReader(filename string, r io.Reader, opts ...Option) (any, error)

ParseReader parses the data from r using filename as information in the error messages.

Types

type AllConstraint

type AllConstraint struct {
	Value string `json:"value"`
}

func NewAllConstraint

func NewAllConstraint(value string) *AllConstraint

func (*AllConstraint) ASCIIDocString

func (c *AllConstraint) ASCIIDocString(dataType *types.DataType) string

func (*AllConstraint) Clone

func (c *AllConstraint) Clone() Constraint

func (*AllConstraint) Equal

func (c *AllConstraint) Equal(o Constraint) bool

func (*AllConstraint) Fallback

func (c *AllConstraint) Fallback(cc Context) (max types.DataTypeExtreme)

func (*AllConstraint) MarshalJSON

func (c *AllConstraint) MarshalJSON() ([]byte, error)

func (*AllConstraint) Max

func (c *AllConstraint) Max(cc Context) (max types.DataTypeExtreme)

func (*AllConstraint) Min

func (c *AllConstraint) Min(cc Context) (min types.DataTypeExtreme)

func (*AllConstraint) NeedsParens

func (c *AllConstraint) NeedsParens(topLevel bool) bool

func (*AllConstraint) Type

func (c *AllConstraint) Type() Type

type BooleanLimit

type BooleanLimit struct {
	Value bool `json:"value"`
}

func (*BooleanLimit) ASCIIDocString

func (c *BooleanLimit) ASCIIDocString(dataType *types.DataType) string

func (*BooleanLimit) Clone

func (c *BooleanLimit) Clone() Limit

func (*BooleanLimit) DataModelString

func (c *BooleanLimit) DataModelString(dataType *types.DataType) string

func (*BooleanLimit) Equal

func (c *BooleanLimit) Equal(o Limit) bool

func (*BooleanLimit) Fallback

func (c *BooleanLimit) Fallback(cc Context) (max types.DataTypeExtreme)

func (*BooleanLimit) MarshalJSON

func (c *BooleanLimit) MarshalJSON() ([]byte, error)

func (*BooleanLimit) Max

func (c *BooleanLimit) Max(cc Context) (max types.DataTypeExtreme)

func (*BooleanLimit) Min

func (c *BooleanLimit) Min(cc Context) (min types.DataTypeExtreme)

func (*BooleanLimit) NeedsParens

func (c *BooleanLimit) NeedsParens(topLevel bool) bool

type CharacterLimit

type CharacterLimit struct {
	ByteCount      Limit `json:"byteCount"`
	CodepointCount Limit `json:"codepointCount"`
}

func (*CharacterLimit) ASCIIDocString

func (c *CharacterLimit) ASCIIDocString(dataType *types.DataType) string

func (*CharacterLimit) Clone

func (c *CharacterLimit) Clone() Limit

func (*CharacterLimit) DataModelString

func (c *CharacterLimit) DataModelString(dataType *types.DataType) string

func (*CharacterLimit) Equal

func (c *CharacterLimit) Equal(o Limit) bool

func (*CharacterLimit) Fallback

func (c *CharacterLimit) Fallback(cc Context) (max types.DataTypeExtreme)

func (*CharacterLimit) MarshalJSON

func (c *CharacterLimit) MarshalJSON() ([]byte, error)

func (*CharacterLimit) Max

func (c *CharacterLimit) Max(cc Context) (max types.DataTypeExtreme)

func (*CharacterLimit) Min

func (c *CharacterLimit) Min(cc Context) (min types.DataTypeExtreme)

func (*CharacterLimit) NeedsParens

func (c *CharacterLimit) NeedsParens(topLevel bool) bool

type Constraint

type Constraint interface {
	Type() Type
	ASCIIDocString(dataType *types.DataType) string
	Equal(o Constraint) bool
	Min(c Context) (min types.DataTypeExtreme)
	Max(c Context) (max types.DataTypeExtreme)
	NeedsParens(topLevel bool) bool
	Clone() Constraint
}

func AppendConstraint

func AppendConstraint(c Constraint, n ...Constraint) Constraint

func ParseString

func ParseString(constraint string) Constraint

func TryParseString

func TryParseString(constraint string) (Constraint, error)

func UnmarshalConstraint

func UnmarshalConstraint(raw json.RawMessage) (c Constraint, err error)

type Context

type Context interface {
	DataType() *types.DataType
	Nullable() bool
	Fallback(entity types.Entity, field Limit) types.DataTypeExtreme
	MinEntityValue(entity types.Entity, field Limit) types.DataTypeExtreme
	MaxEntityValue(entity types.Entity, field Limit) types.DataTypeExtreme
}

type DescribedConstraint

type DescribedConstraint struct {
}

func (*DescribedConstraint) ASCIIDocString

func (c *DescribedConstraint) ASCIIDocString(dataType *types.DataType) string

func (*DescribedConstraint) Clone

func (c *DescribedConstraint) Clone() Constraint

func (*DescribedConstraint) Equal

func (c *DescribedConstraint) Equal(o Constraint) bool

func (*DescribedConstraint) Fallback

func (c *DescribedConstraint) Fallback(cc Context) (max types.DataTypeExtreme)

func (*DescribedConstraint) MarshalJSON

func (c *DescribedConstraint) MarshalJSON() ([]byte, error)

func (*DescribedConstraint) Max

func (*DescribedConstraint) Min

func (*DescribedConstraint) NeedsParens

func (c *DescribedConstraint) NeedsParens(topLevel bool) bool

func (*DescribedConstraint) Type

func (c *DescribedConstraint) Type() Type

type DescribedLimit added in v1.6.0

type DescribedLimit struct {
}

func (*DescribedLimit) ASCIIDocString added in v1.6.0

func (gl *DescribedLimit) ASCIIDocString(dataType *types.DataType) string

func (*DescribedLimit) Clone added in v1.6.0

func (gl *DescribedLimit) Clone() Limit

func (*DescribedLimit) DataModelString added in v1.6.0

func (gl *DescribedLimit) DataModelString(dataType *types.DataType) string

func (*DescribedLimit) Equal added in v1.6.0

func (gl *DescribedLimit) Equal(o Limit) bool

func (*DescribedLimit) Fallback added in v1.6.0

func (gl *DescribedLimit) Fallback(c Context) (max types.DataTypeExtreme)

func (*DescribedLimit) Max added in v1.6.0

func (gl *DescribedLimit) Max(c Context) (max types.DataTypeExtreme)

func (*DescribedLimit) Min added in v1.6.0

func (gl *DescribedLimit) Min(c Context) (min types.DataTypeExtreme)

func (*DescribedLimit) NeedsParens added in v1.6.0

func (gl *DescribedLimit) NeedsParens(topLevel bool) bool

type EmptyLimit

type EmptyLimit struct {
}

func (*EmptyLimit) ASCIIDocString

func (c *EmptyLimit) ASCIIDocString(dataType *types.DataType) string

func (*EmptyLimit) Clone

func (c *EmptyLimit) Clone() Limit

func (*EmptyLimit) DataModelString

func (c *EmptyLimit) DataModelString(dataType *types.DataType) string

func (*EmptyLimit) Equal

func (c *EmptyLimit) Equal(o Limit) bool

func (*EmptyLimit) Fallback

func (c *EmptyLimit) Fallback(cc Context) (max types.DataTypeExtreme)

func (*EmptyLimit) MarshalJSON

func (c *EmptyLimit) MarshalJSON() ([]byte, error)

func (*EmptyLimit) Max

func (c *EmptyLimit) Max(cc Context) (max types.DataTypeExtreme)

func (*EmptyLimit) Min

func (c *EmptyLimit) Min(cc Context) (min types.DataTypeExtreme)

func (*EmptyLimit) NeedsParens

func (c *EmptyLimit) NeedsParens(topLevel bool) bool

type ExactConstraint

type ExactConstraint struct {
	Value Limit `json:"value"`
}

func (*ExactConstraint) ASCIIDocString

func (c *ExactConstraint) ASCIIDocString(dataType *types.DataType) string

func (*ExactConstraint) Clone

func (c *ExactConstraint) Clone() Constraint

func (*ExactConstraint) Equal

func (c *ExactConstraint) Equal(o Constraint) bool

func (*ExactConstraint) Fallback

func (c *ExactConstraint) Fallback(cc Context) (max types.DataTypeExtreme)

func (*ExactConstraint) MarshalJSON

func (c *ExactConstraint) MarshalJSON() ([]byte, error)

func (*ExactConstraint) Max

func (c *ExactConstraint) Max(cc Context) (max types.DataTypeExtreme)

func (*ExactConstraint) Min

func (c *ExactConstraint) Min(cc Context) (min types.DataTypeExtreme)

func (*ExactConstraint) NeedsParens

func (c *ExactConstraint) NeedsParens(topLevel bool) bool

func (*ExactConstraint) Type

func (c *ExactConstraint) Type() Type

func (*ExactConstraint) UnmarshalJSON

func (c *ExactConstraint) UnmarshalJSON(data []byte) (err error)

type ExpLimit

type ExpLimit struct {
	Value int64 `json:"value"`
	Exp   int64 `json:"exp"`
}

func (*ExpLimit) ASCIIDocString

func (c *ExpLimit) ASCIIDocString(dataType *types.DataType) string

func (*ExpLimit) Clone

func (c *ExpLimit) Clone() Limit

func (*ExpLimit) DataModelString

func (c *ExpLimit) DataModelString(dataType *types.DataType) string

func (*ExpLimit) Equal

func (c *ExpLimit) Equal(o Limit) bool

func (*ExpLimit) Fallback

func (c *ExpLimit) Fallback(cc Context) (max types.DataTypeExtreme)

func (*ExpLimit) MarshalJSON

func (c *ExpLimit) MarshalJSON() ([]byte, error)

func (*ExpLimit) Max

func (c *ExpLimit) Max(cc Context) (max types.DataTypeExtreme)

func (*ExpLimit) Min

func (c *ExpLimit) Min(cc Context) (min types.DataTypeExtreme)

func (*ExpLimit) NeedsParens

func (c *ExpLimit) NeedsParens(topLevel bool) bool

type GenericConstraint

type GenericConstraint struct {
	Value string `json:"value"`
}

func (*GenericConstraint) ASCIIDocString

func (c *GenericConstraint) ASCIIDocString(dataType *types.DataType) string

func (*GenericConstraint) Clone

func (c *GenericConstraint) Clone() Constraint

func (*GenericConstraint) Equal

func (c *GenericConstraint) Equal(o Constraint) bool

func (*GenericConstraint) Fallback

func (c *GenericConstraint) Fallback(cc Context) (max types.DataTypeExtreme)

func (*GenericConstraint) MarshalJSON

func (c *GenericConstraint) MarshalJSON() ([]byte, error)

func (*GenericConstraint) Max

func (*GenericConstraint) Min

func (*GenericConstraint) NeedsParens

func (c *GenericConstraint) NeedsParens(topLevel bool) bool

func (*GenericConstraint) Type

func (c *GenericConstraint) Type() Type

type GenericLimit

type GenericLimit struct {
	Value string `json:"value"`
}

func (*GenericLimit) ASCIIDocString

func (gl *GenericLimit) ASCIIDocString(dataType *types.DataType) string

func (*GenericLimit) Clone

func (gl *GenericLimit) Clone() Limit

func (*GenericLimit) DataModelString

func (gl *GenericLimit) DataModelString(dataType *types.DataType) string

func (*GenericLimit) Equal

func (gl *GenericLimit) Equal(o Limit) bool

func (*GenericLimit) Fallback

func (gl *GenericLimit) Fallback(c Context) (max types.DataTypeExtreme)

func (*GenericLimit) Max

func (gl *GenericLimit) Max(c Context) (max types.DataTypeExtreme)

func (*GenericLimit) Min

func (gl *GenericLimit) Min(c Context) (min types.DataTypeExtreme)

func (*GenericLimit) NeedsParens

func (gl *GenericLimit) NeedsParens(topLevel bool) bool

type HexLimit

type HexLimit struct {
	Value uint64 `json:"value"`
}

func (*HexLimit) ASCIIDocString

func (c *HexLimit) ASCIIDocString(dataType *types.DataType) string

func (*HexLimit) Clone

func (c *HexLimit) Clone() Limit

func (*HexLimit) DataModelString

func (c *HexLimit) DataModelString(dataType *types.DataType) string

func (*HexLimit) Equal

func (c *HexLimit) Equal(o Limit) bool

func (*HexLimit) Fallback

func (c *HexLimit) Fallback(cc Context) (max types.DataTypeExtreme)

func (*HexLimit) MarshalJSON

func (c *HexLimit) MarshalJSON() ([]byte, error)

func (*HexLimit) Max

func (c *HexLimit) Max(cc Context) (max types.DataTypeExtreme)

func (*HexLimit) Min

func (c *HexLimit) Min(cc Context) (min types.DataTypeExtreme)

func (*HexLimit) NeedsParens

func (c *HexLimit) NeedsParens(topLevel bool) bool

type IdentifierLimit

type IdentifierLimit struct {
	ID     string `json:"id"`
	Not    bool   `json:"not,omitempty"`
	Entity types.Entity
	Field  Limit `json:"field,omitempty"`
}

func (*IdentifierLimit) ASCIIDocString

func (c *IdentifierLimit) ASCIIDocString(dataType *types.DataType) string

func (*IdentifierLimit) Clone

func (c *IdentifierLimit) Clone() Limit

func (*IdentifierLimit) DataModelString

func (c *IdentifierLimit) DataModelString(dataType *types.DataType) string

func (*IdentifierLimit) Equal

func (c *IdentifierLimit) Equal(o Limit) bool

func (*IdentifierLimit) Fallback

func (c *IdentifierLimit) Fallback(cc Context) (def types.DataTypeExtreme)

func (*IdentifierLimit) MarshalJSON

func (c *IdentifierLimit) MarshalJSON() ([]byte, error)

func (*IdentifierLimit) Max

func (c *IdentifierLimit) Max(cc Context) (max types.DataTypeExtreme)

func (*IdentifierLimit) Min

func (c *IdentifierLimit) Min(cc Context) (min types.DataTypeExtreme)

func (*IdentifierLimit) NeedsParens

func (c *IdentifierLimit) NeedsParens(topLevel bool) bool

type IntLimit

type IntLimit struct {
	Value int64 `json:"value"`
}

func (*IntLimit) ASCIIDocString

func (c *IntLimit) ASCIIDocString(dataType *types.DataType) string

func (*IntLimit) Clone

func (c *IntLimit) Clone() Limit

func (*IntLimit) DataModelString

func (c *IntLimit) DataModelString(dataType *types.DataType) string

func (*IntLimit) Equal

func (c *IntLimit) Equal(o Limit) bool

func (*IntLimit) Fallback

func (c *IntLimit) Fallback(cc Context) (max types.DataTypeExtreme)

func (*IntLimit) MarshalJSON

func (c *IntLimit) MarshalJSON() ([]byte, error)

func (*IntLimit) Max

func (c *IntLimit) Max(cc Context) (max types.DataTypeExtreme)

func (*IntLimit) Min

func (c *IntLimit) Min(cc Context) (min types.DataTypeExtreme)

func (*IntLimit) NeedsParens

func (c *IntLimit) NeedsParens(topLevel bool) bool

type LengthLimit

type LengthLimit struct {
	Reference Limit `json:"ref"`
}

func (*LengthLimit) ASCIIDocString

func (ll *LengthLimit) ASCIIDocString(dataType *types.DataType) string

func (*LengthLimit) Clone

func (ll *LengthLimit) Clone() Limit

func (*LengthLimit) DataModelString

func (ll *LengthLimit) DataModelString(dataType *types.DataType) string

func (*LengthLimit) Equal

func (ll *LengthLimit) Equal(o Limit) bool

func (*LengthLimit) Fallback

func (ll *LengthLimit) Fallback(cc Context) (def types.DataTypeExtreme)

func (*LengthLimit) MarshalJSON

func (ll *LengthLimit) MarshalJSON() ([]byte, error)

func (*LengthLimit) Max

func (ll *LengthLimit) Max(cc Context) (max types.DataTypeExtreme)

func (*LengthLimit) Min

func (ll *LengthLimit) Min(cc Context) (min types.DataTypeExtreme)

func (*LengthLimit) NeedsParens

func (ll *LengthLimit) NeedsParens(topLevel bool) bool

type Limit

type Limit interface {
	ASCIIDocString(dataType *types.DataType) string
	DataModelString(dataType *types.DataType) string
	Equal(o Limit) bool
	Min(c Context) (min types.DataTypeExtreme)
	Max(c Context) (max types.DataTypeExtreme)
	Fallback(c Context) (max types.DataTypeExtreme)
	NeedsParens(topLevel bool) bool
	Clone() Limit
}

func ParseLimit

func ParseLimit(limit string) Limit

func TryParseLimit

func TryParseLimit(limit string) (Limit, error)

func UnmarshalLimit

func UnmarshalLimit(raw json.RawMessage) (cl Limit, err error)

type LimitSet

type LimitSet []Limit

func (LimitSet) ASCIIDocString

func (ls LimitSet) ASCIIDocString(dataType *types.DataType, sb *strings.Builder)

func (LimitSet) Clone

func (ls LimitSet) Clone() LimitSet

func (LimitSet) DataModelString

func (ls LimitSet) DataModelString(dataType *types.DataType, sb *strings.Builder)

func (LimitSet) Equal

func (ls LimitSet) Equal(o LimitSet) bool

func (LimitSet) Max

func (ls LimitSet) Max(c Context) (max types.DataTypeExtreme)

func (LimitSet) Min

func (ls LimitSet) Min(c Context) (min types.DataTypeExtreme)

func (*LimitSet) UnmarshalJSON

func (ls *LimitSet) UnmarshalJSON(data []byte) (err error)

type ListConstraint

type ListConstraint struct {
	Constraint      Constraint
	EntryConstraint Constraint
}

func (*ListConstraint) ASCIIDocString

func (c *ListConstraint) ASCIIDocString(dataType *types.DataType) string

func (*ListConstraint) Clone

func (c *ListConstraint) Clone() Constraint

func (*ListConstraint) Equal

func (c *ListConstraint) Equal(o Constraint) bool

func (*ListConstraint) Fallback

func (c *ListConstraint) Fallback(cc Context) (max types.DataTypeExtreme)

func (*ListConstraint) MarshalJSON

func (c *ListConstraint) MarshalJSON() ([]byte, error)

func (*ListConstraint) Max

func (c *ListConstraint) Max(cc Context) (max types.DataTypeExtreme)

func (*ListConstraint) Min

func (c *ListConstraint) Min(cc Context) (min types.DataTypeExtreme)

func (*ListConstraint) NeedsParens

func (c *ListConstraint) NeedsParens(topLevel bool) bool

func (*ListConstraint) Type

func (c *ListConstraint) Type() Type

func (*ListConstraint) UnmarshalJSON

func (c *ListConstraint) UnmarshalJSON(data []byte) (err error)

type LogicalConstraint

type LogicalConstraint struct {
	Operand string
	Left    Constraint
	Right   []Constraint
	Not     bool
}

func NewLogicalConstraint

func NewLogicalConstraint(operand string, left Constraint, right []any) (*LogicalConstraint, error)

func (*LogicalConstraint) ASCIIDocString

func (lc *LogicalConstraint) ASCIIDocString(dataType *types.DataType) string

func (*LogicalConstraint) Clone

func (lc *LogicalConstraint) Clone() Constraint

func (*LogicalConstraint) Equal

func (lc *LogicalConstraint) Equal(c Constraint) bool

func (*LogicalConstraint) Max

func (*LogicalConstraint) Min

func (*LogicalConstraint) NeedsParens

func (lc *LogicalConstraint) NeedsParens(topLevel bool) bool

func (*LogicalConstraint) Type

func (lc *LogicalConstraint) Type() Type

type LogicalLimit

type LogicalLimit struct {
	Operand string
	Left    Limit
	Right   []Limit
	Not     bool
}

func NewLogicalLimit

func NewLogicalLimit(operand string, left Limit, right []any) (*LogicalLimit, error)

func (*LogicalLimit) ASCIIDocString

func (ll *LogicalLimit) ASCIIDocString(dataType *types.DataType) string

func (*LogicalLimit) Clone

func (ll *LogicalLimit) Clone() Limit

func (*LogicalLimit) DataModelString

func (ll *LogicalLimit) DataModelString(dataType *types.DataType) string

func (*LogicalLimit) Equal

func (ll *LogicalLimit) Equal(l Limit) bool

func (*LogicalLimit) Fallback

func (ll *LogicalLimit) Fallback(cc Context) (max types.DataTypeExtreme)

func (*LogicalLimit) MarshalJSON

func (le *LogicalLimit) MarshalJSON() ([]byte, error)

func (*LogicalLimit) Max

func (ll *LogicalLimit) Max(cc Context) (max types.DataTypeExtreme)

func (*LogicalLimit) Min

func (ll *LogicalLimit) Min(cc Context) (min types.DataTypeExtreme)

func (*LogicalLimit) NeedsParens

func (ll *LogicalLimit) NeedsParens(topLevel bool) bool

type ManufacturerLimit

type ManufacturerLimit struct {
	Value string `json:"value,omitempty"`
}

func (*ManufacturerLimit) ASCIIDocString

func (c *ManufacturerLimit) ASCIIDocString(dataType *types.DataType) string

func (*ManufacturerLimit) Clone

func (c *ManufacturerLimit) Clone() Limit

func (*ManufacturerLimit) DataModelString

func (c *ManufacturerLimit) DataModelString(dataType *types.DataType) string

func (*ManufacturerLimit) Equal

func (c *ManufacturerLimit) Equal(o Limit) bool

func (*ManufacturerLimit) Fallback

func (c *ManufacturerLimit) Fallback(cc Context) (max types.DataTypeExtreme)

func (*ManufacturerLimit) MarshalJSON

func (c *ManufacturerLimit) MarshalJSON() ([]byte, error)

func (*ManufacturerLimit) Max

func (*ManufacturerLimit) Min

func (*ManufacturerLimit) NeedsParens

func (c *ManufacturerLimit) NeedsParens(topLevel bool) bool

type MathExpressionLimit

type MathExpressionLimit struct {
	Operand string
	Left    Limit
	Right   Limit
}

func (*MathExpressionLimit) ASCIIDocString

func (c *MathExpressionLimit) ASCIIDocString(dataType *types.DataType) string

func (*MathExpressionLimit) Clone

func (c *MathExpressionLimit) Clone() Limit

func (*MathExpressionLimit) DataModelString

func (c *MathExpressionLimit) DataModelString(dataType *types.DataType) string

func (*MathExpressionLimit) Equal

func (c *MathExpressionLimit) Equal(o Limit) bool

func (*MathExpressionLimit) Fallback

func (c *MathExpressionLimit) Fallback(cc Context) (max types.DataTypeExtreme)

func (*MathExpressionLimit) MarshalJSON

func (c *MathExpressionLimit) MarshalJSON() ([]byte, error)

func (*MathExpressionLimit) Max

func (*MathExpressionLimit) Min

func (*MathExpressionLimit) NeedsParens

func (c *MathExpressionLimit) NeedsParens(topLevel bool) bool

func (*MathExpressionLimit) UnmarshalJSON

func (c *MathExpressionLimit) UnmarshalJSON(data []byte) (err error)

type MaxConstraint

type MaxConstraint struct {
	Maximum Limit
}

func (*MaxConstraint) ASCIIDocString

func (c *MaxConstraint) ASCIIDocString(dataType *types.DataType) string

func (*MaxConstraint) Clone

func (c *MaxConstraint) Clone() Constraint

func (*MaxConstraint) Equal

func (c *MaxConstraint) Equal(o Constraint) bool

func (*MaxConstraint) Fallback

func (c *MaxConstraint) Fallback(cc Context) (max types.DataTypeExtreme)

func (*MaxConstraint) MarshalJSON

func (c *MaxConstraint) MarshalJSON() ([]byte, error)

func (*MaxConstraint) Max

func (c *MaxConstraint) Max(cc Context) (max types.DataTypeExtreme)

func (*MaxConstraint) Min

func (c *MaxConstraint) Min(cc Context) (min types.DataTypeExtreme)

func (*MaxConstraint) NeedsParens

func (c *MaxConstraint) NeedsParens(topLevel bool) bool

func (*MaxConstraint) Type

func (c *MaxConstraint) Type() Type

func (*MaxConstraint) UnmarshalJSON

func (c *MaxConstraint) UnmarshalJSON(data []byte) (err error)

type MaxOfLimit

type MaxOfLimit struct {
	Maximums LimitSet `json:"maximums"`
}

func (*MaxOfLimit) ASCIIDocString

func (c *MaxOfLimit) ASCIIDocString(dataType *types.DataType) string

func (*MaxOfLimit) Clone

func (c *MaxOfLimit) Clone() Limit

func (*MaxOfLimit) DataModelString

func (c *MaxOfLimit) DataModelString(dataType *types.DataType) string

func (*MaxOfLimit) Equal

func (c *MaxOfLimit) Equal(o Limit) bool

func (*MaxOfLimit) Fallback

func (c *MaxOfLimit) Fallback(cc Context) (max types.DataTypeExtreme)

func (*MaxOfLimit) MarshalJSON

func (c *MaxOfLimit) MarshalJSON() ([]byte, error)

func (*MaxOfLimit) Max

func (c *MaxOfLimit) Max(cc Context) (max types.DataTypeExtreme)

func (*MaxOfLimit) Min

func (c *MaxOfLimit) Min(cc Context) (min types.DataTypeExtreme)

func (*MaxOfLimit) NeedsParens

func (c *MaxOfLimit) NeedsParens(topLevel bool) bool

func (*MaxOfLimit) UnmarshalJSON

func (c *MaxOfLimit) UnmarshalJSON(data []byte) (err error)

type MinConstraint

type MinConstraint struct {
	Minimum Limit `json:"min"`
}

func (*MinConstraint) ASCIIDocString

func (c *MinConstraint) ASCIIDocString(dataType *types.DataType) string

func (*MinConstraint) Clone

func (c *MinConstraint) Clone() Constraint

func (*MinConstraint) Equal

func (c *MinConstraint) Equal(o Constraint) bool

func (*MinConstraint) Fallback

func (c *MinConstraint) Fallback(cc Context) (max types.DataTypeExtreme)

func (*MinConstraint) MarshalJSON

func (c *MinConstraint) MarshalJSON() ([]byte, error)

func (*MinConstraint) Max

func (c *MinConstraint) Max(cc Context) (max types.DataTypeExtreme)

func (*MinConstraint) Min

func (c *MinConstraint) Min(cc Context) (min types.DataTypeExtreme)

func (*MinConstraint) NeedsParens

func (c *MinConstraint) NeedsParens(topLevel bool) bool

func (*MinConstraint) Type

func (c *MinConstraint) Type() Type

func (*MinConstraint) UnmarshalJSON

func (c *MinConstraint) UnmarshalJSON(data []byte) (err error)

type MinOfLimit

type MinOfLimit struct {
	Minimums LimitSet `json:"minimums"`
}

func (*MinOfLimit) ASCIIDocString

func (c *MinOfLimit) ASCIIDocString(dataType *types.DataType) string

func (*MinOfLimit) Clone

func (c *MinOfLimit) Clone() Limit

func (*MinOfLimit) DataModelString

func (c *MinOfLimit) DataModelString(dataType *types.DataType) string

func (*MinOfLimit) Equal

func (c *MinOfLimit) Equal(o Limit) bool

func (*MinOfLimit) Fallback

func (c *MinOfLimit) Fallback(cc Context) (max types.DataTypeExtreme)

func (*MinOfLimit) MarshalJSON

func (c *MinOfLimit) MarshalJSON() ([]byte, error)

func (*MinOfLimit) Max

func (c *MinOfLimit) Max(cc Context) (max types.DataTypeExtreme)

func (*MinOfLimit) Min

func (c *MinOfLimit) Min(cc Context) (min types.DataTypeExtreme)

func (*MinOfLimit) NeedsParens

func (c *MinOfLimit) NeedsParens(topLevel bool) bool

func (*MinOfLimit) UnmarshalJSON

func (c *MinOfLimit) UnmarshalJSON(data []byte) (err error)

type NullLimit

type NullLimit struct {
}

func (*NullLimit) ASCIIDocString

func (c *NullLimit) ASCIIDocString(dataType *types.DataType) string

func (*NullLimit) Clone

func (c *NullLimit) Clone() Limit

func (*NullLimit) DataModelString

func (c *NullLimit) DataModelString(dataType *types.DataType) string

func (*NullLimit) Equal

func (c *NullLimit) Equal(o Limit) bool

func (*NullLimit) Fallback

func (c *NullLimit) Fallback(cc Context) (max types.DataTypeExtreme)

func (*NullLimit) MarshalJSON

func (c *NullLimit) MarshalJSON() ([]byte, error)

func (*NullLimit) Max

func (c *NullLimit) Max(cc Context) (max types.DataTypeExtreme)

func (*NullLimit) Min

func (c *NullLimit) Min(cc Context) (min types.DataTypeExtreme)

func (*NullLimit) NeedsParens

func (c *NullLimit) NeedsParens(topLevel bool) bool

type Number

type Number interface {
	int64 | uint64
}

type Option

type Option func(*parser) Option

Option is a function that can set an option on the parser. It returns the previous setting as an Option.

func AllowInvalidUTF8

func AllowInvalidUTF8(b bool) Option

AllowInvalidUTF8 creates an Option to allow invalid UTF-8 bytes. Every invalid UTF-8 byte is treated as a utf8.RuneError (U+FFFD) by character class matchers and is matched by the any matcher. The returned matched value, c.text and c.offset are NOT affected.

The default is false.

func Entrypoint

func Entrypoint(ruleName string) Option

Entrypoint creates an Option to set the rule name to use as entrypoint. The rule name must have been specified in the -alternate-entrypoints if generating the parser with the -optimize-grammar flag, otherwise it may have been optimized out. Passing an empty string sets the entrypoint to the first rule in the grammar.

The default is to start parsing at the first rule in the grammar.

func GlobalStore

func GlobalStore(key string, value any) Option

GlobalStore creates an Option to set a key to a certain value in the globalStore.

func MaxExpressions

func MaxExpressions(maxExprCnt uint64) Option

MaxExpressions creates an Option to stop parsing after the provided number of expressions have been parsed, if the value is 0 then the parser will parse for as many steps as needed (possibly an infinite number).

The default for maxExprCnt is 0.

func Recover

func Recover(b bool) Option

Recover creates an Option to set the recover flag to b. When set to true, this causes the parser to recover from panics and convert it to an error. Setting it to false can be useful while debugging to access the full stack trace.

The default is true.

type PercentLimit

type PercentLimit struct {
	Value      decimal.Decimal `json:"value"`
	Hundredths bool            `json:"hundredths,omitempty"`
}

func (*PercentLimit) ASCIIDocString

func (c *PercentLimit) ASCIIDocString(dataType *types.DataType) string

func (*PercentLimit) Clone

func (c *PercentLimit) Clone() Limit

func (*PercentLimit) DataModelString

func (c *PercentLimit) DataModelString(dataType *types.DataType) string

func (*PercentLimit) Equal

func (c *PercentLimit) Equal(o Limit) bool

func (*PercentLimit) Fallback

func (c *PercentLimit) Fallback(cc Context) (max types.DataTypeExtreme)

func (*PercentLimit) MarshalJSON

func (c *PercentLimit) MarshalJSON() ([]byte, error)

func (*PercentLimit) Max

func (c *PercentLimit) Max(cc Context) (max types.DataTypeExtreme)

func (*PercentLimit) Min

func (c *PercentLimit) Min(cc Context) (min types.DataTypeExtreme)

func (*PercentLimit) NeedsParens

func (c *PercentLimit) NeedsParens(topLevel bool) bool

type RangeConstraint

type RangeConstraint struct {
	Minimum Limit `json:"min"`
	Maximum Limit `json:"max"`
}

func (*RangeConstraint) ASCIIDocString

func (c *RangeConstraint) ASCIIDocString(dataType *types.DataType) string

func (*RangeConstraint) Clone

func (c *RangeConstraint) Clone() Constraint

func (*RangeConstraint) Equal

func (c *RangeConstraint) Equal(o Constraint) bool

func (*RangeConstraint) Fallback

func (c *RangeConstraint) Fallback(cc Context) (max types.DataTypeExtreme)

func (*RangeConstraint) MarshalJSON

func (c *RangeConstraint) MarshalJSON() ([]byte, error)

func (*RangeConstraint) Max

func (c *RangeConstraint) Max(cc Context) (to types.DataTypeExtreme)

func (*RangeConstraint) Min

func (c *RangeConstraint) Min(cc Context) (from types.DataTypeExtreme)

func (*RangeConstraint) NeedsParens

func (c *RangeConstraint) NeedsParens(topLevel bool) bool

func (*RangeConstraint) Type

func (c *RangeConstraint) Type() Type

func (*RangeConstraint) UnmarshalJSON

func (c *RangeConstraint) UnmarshalJSON(data []byte) (err error)

type ReferenceLimit

type ReferenceLimit struct {
	Reference string `json:"reference"`
	Not       bool   `json:"not,omitempty"`
	Entity    types.Entity
	Label     string `json:"label"`
	Field     Limit  `json:"field,omitempty"`
}

func (*ReferenceLimit) ASCIIDocString

func (c *ReferenceLimit) ASCIIDocString(dataType *types.DataType) string

func (*ReferenceLimit) Clone

func (c *ReferenceLimit) Clone() Limit

func (*ReferenceLimit) DataModelString

func (c *ReferenceLimit) DataModelString(dataType *types.DataType) string

func (*ReferenceLimit) Equal

func (c *ReferenceLimit) Equal(o Limit) bool

func (*ReferenceLimit) Fallback

func (c *ReferenceLimit) Fallback(cc Context) (def types.DataTypeExtreme)

func (*ReferenceLimit) MarshalJSON

func (c *ReferenceLimit) MarshalJSON() ([]byte, error)

func (*ReferenceLimit) Max

func (c *ReferenceLimit) Max(cc Context) (max types.DataTypeExtreme)

func (*ReferenceLimit) Min

func (c *ReferenceLimit) Min(cc Context) (min types.DataTypeExtreme)

func (*ReferenceLimit) NeedsParens

func (c *ReferenceLimit) NeedsParens(topLevel bool) bool

type Set

type Set []Constraint

func UnmarshalConstraintSetJSON

func UnmarshalConstraintSetJSON(list []json.RawMessage) (set Set, err error)

func (Set) ASCIIDocString

func (cs Set) ASCIIDocString(dataType *types.DataType) string

func (Set) Clone

func (cs Set) Clone() Constraint

func (Set) Equal

func (cs Set) Equal(o Constraint) bool

func (Set) Fallback

func (cs Set) Fallback(cc Context) (max types.DataTypeExtreme)

func (Set) Max

func (cs Set) Max(c Context) (max types.DataTypeExtreme)

func (Set) Min

func (cs Set) Min(c Context) (min types.DataTypeExtreme)

func (Set) NeedsParens

func (cs Set) NeedsParens(topLevel bool) bool

func (Set) Type

func (cs Set) Type() Type

func (*Set) UnmarshalJSON

func (cs *Set) UnmarshalJSON(data []byte) (err error)

type Stats

type Stats struct {
	// ExprCnt counts the number of expressions processed during parsing
	// This value is compared to the maximum number of expressions allowed
	// (set by the MaxExpressions option).
	ExprCnt uint64

	// ChoiceAltCnt is used to count for each ordered choice expression,
	// which alternative is used how may times.
	// These numbers allow to optimize the order of the ordered choice expression
	// to increase the performance of the parser
	//
	// The outer key of ChoiceAltCnt is composed of the name of the rule as well
	// as the line and the column of the ordered choice.
	// The inner key of ChoiceAltCnt is the number (one-based) of the matching alternative.
	// For each alternative the number of matches are counted. If an ordered choice does not
	// match, a special counter is incremented. The name of this counter is set with
	// the parser option Statistics.
	// For an alternative to be included in ChoiceAltCnt, it has to match at least once.
	ChoiceAltCnt map[string]map[string]int
}

Stats stores some statistics, gathered during parsing

type StatusCodeLimit

type StatusCodeLimit struct {
	StatusCode types.StatusCode
}

func (*StatusCodeLimit) ASCIIDocString

func (c *StatusCodeLimit) ASCIIDocString(dataType *types.DataType) string

func (*StatusCodeLimit) Clone

func (c *StatusCodeLimit) Clone() Limit

func (*StatusCodeLimit) DataModelString

func (c *StatusCodeLimit) DataModelString(dataType *types.DataType) string

func (*StatusCodeLimit) Equal

func (c *StatusCodeLimit) Equal(o Limit) bool

func (*StatusCodeLimit) Fallback

func (c *StatusCodeLimit) Fallback(cc Context) (max types.DataTypeExtreme)

func (*StatusCodeLimit) MarshalJSON

func (c *StatusCodeLimit) MarshalJSON() ([]byte, error)

func (*StatusCodeLimit) Max

func (c *StatusCodeLimit) Max(cc Context) (max types.DataTypeExtreme)

func (*StatusCodeLimit) Min

func (c *StatusCodeLimit) Min(cc Context) (min types.DataTypeExtreme)

func (*StatusCodeLimit) NeedsParens

func (c *StatusCodeLimit) NeedsParens(topLevel bool) bool

type StringLimit

type StringLimit struct {
	Value string `json:"value"`
}

func (*StringLimit) ASCIIDocString

func (c *StringLimit) ASCIIDocString(dataType *types.DataType) string

func (*StringLimit) Clone

func (c *StringLimit) Clone() Limit

func (*StringLimit) DataModelString

func (c *StringLimit) DataModelString(dataType *types.DataType) string

func (*StringLimit) Equal

func (c *StringLimit) Equal(o Limit) bool

func (*StringLimit) Fallback

func (c *StringLimit) Fallback(cc Context) (max types.DataTypeExtreme)

func (*StringLimit) MarshalJSON

func (c *StringLimit) MarshalJSON() ([]byte, error)

func (*StringLimit) Max

func (c *StringLimit) Max(cc Context) (max types.DataTypeExtreme)

func (*StringLimit) Min

func (c *StringLimit) Min(cc Context) (min types.DataTypeExtreme)

func (*StringLimit) NeedsParens

func (c *StringLimit) NeedsParens(topLevel bool) bool

type TagIdentifierLimit

type TagIdentifierLimit struct {
	Tag    string `json:"tag"`
	Entity types.Entity
}

func (*TagIdentifierLimit) ASCIIDocString

func (c *TagIdentifierLimit) ASCIIDocString(dataType *types.DataType) string

func (*TagIdentifierLimit) Clone

func (c *TagIdentifierLimit) Clone() Limit

func (*TagIdentifierLimit) DataModelString

func (c *TagIdentifierLimit) DataModelString(dataType *types.DataType) string

func (*TagIdentifierLimit) Equal

func (c *TagIdentifierLimit) Equal(o Limit) bool

func (*TagIdentifierLimit) Fallback

func (c *TagIdentifierLimit) Fallback(cc Context) (def types.DataTypeExtreme)

func (*TagIdentifierLimit) MarshalJSON

func (c *TagIdentifierLimit) MarshalJSON() ([]byte, error)

func (*TagIdentifierLimit) Max

func (*TagIdentifierLimit) Min

func (*TagIdentifierLimit) NeedsParens

func (c *TagIdentifierLimit) NeedsParens(topLevel bool) bool

type TagListConstraint

type TagListConstraint struct {
	Tags Limit
}

func (*TagListConstraint) ASCIIDocString

func (tlc *TagListConstraint) ASCIIDocString(dataType *types.DataType) string

func (*TagListConstraint) Clone

func (tlc *TagListConstraint) Clone() Constraint

func (*TagListConstraint) Equal

func (tlc *TagListConstraint) Equal(o Constraint) bool

func (*TagListConstraint) Max

func (tlc *TagListConstraint) Max(c Context) (max types.DataTypeExtreme)

func (*TagListConstraint) Min

func (tlc *TagListConstraint) Min(c Context) (min types.DataTypeExtreme)

func (*TagListConstraint) NeedsParens

func (tlc *TagListConstraint) NeedsParens(topLevel bool) bool

func (*TagListConstraint) Type

func (tlc *TagListConstraint) Type() Type

type TemperatureLimit

type TemperatureLimit struct {
	Value decimal.Decimal `json:"value"`
}

func (*TemperatureLimit) ASCIIDocString

func (c *TemperatureLimit) ASCIIDocString(dataType *types.DataType) string

func (*TemperatureLimit) Clone

func (c *TemperatureLimit) Clone() Limit

func (*TemperatureLimit) DataModelString

func (c *TemperatureLimit) DataModelString(dataType *types.DataType) string

func (*TemperatureLimit) Equal

func (c *TemperatureLimit) Equal(o Limit) bool

func (*TemperatureLimit) Fallback

func (c *TemperatureLimit) Fallback(cc Context) (max types.DataTypeExtreme)

func (*TemperatureLimit) MarshalJSON

func (c *TemperatureLimit) MarshalJSON() ([]byte, error)

func (*TemperatureLimit) Max

func (c *TemperatureLimit) Max(cc Context) (max types.DataTypeExtreme)

func (*TemperatureLimit) Min

func (c *TemperatureLimit) Min(cc Context) (min types.DataTypeExtreme)

func (*TemperatureLimit) NeedsParens

func (c *TemperatureLimit) NeedsParens(topLevel bool) bool

type Type

type Type uint8
const (
	ConstraintTypeUnknown Type = iota
	ConstraintTypeAll          // Special section type for everything that comes before any known sections
	ConstraintTypeDescribed
	ConstraintTypeExact
	ConstraintTypeGeneric
	ConstraintTypeList
	ConstraintTypeMax
	ConstraintTypeMin
	ConstraintTypeRange
	ConstraintTypeSet
	ConstraintTypeTagList
)

func (Type) MarshalJSON

func (ct Type) MarshalJSON() ([]byte, error)

func (*Type) UnmarshalJSON

func (ct *Type) UnmarshalJSON(bytes []byte) error

type UnspecifiedLimit

type UnspecifiedLimit struct {
}

func (*UnspecifiedLimit) ASCIIDocString

func (c *UnspecifiedLimit) ASCIIDocString(dataType *types.DataType) string

func (*UnspecifiedLimit) Clone

func (c *UnspecifiedLimit) Clone() Limit

func (*UnspecifiedLimit) DataModelString

func (c *UnspecifiedLimit) DataModelString(dataType *types.DataType) string

func (*UnspecifiedLimit) Equal

func (c *UnspecifiedLimit) Equal(o Limit) bool

func (*UnspecifiedLimit) Fallback

func (c *UnspecifiedLimit) Fallback(cc Context) (max types.DataTypeExtreme)

func (*UnspecifiedLimit) MarshalJSON

func (c *UnspecifiedLimit) MarshalJSON() ([]byte, error)

func (*UnspecifiedLimit) Max

func (c *UnspecifiedLimit) Max(cc Context) (max types.DataTypeExtreme)

func (*UnspecifiedLimit) Min

func (c *UnspecifiedLimit) Min(cc Context) (min types.DataTypeExtreme)

func (*UnspecifiedLimit) NeedsParens

func (c *UnspecifiedLimit) NeedsParens(topLevel bool) bool

Jump to

Keyboard shortcuts

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