ast

package
v0.4.17 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TokenError

func TokenError(t antlr.Token) func(format string, args ...interface{}) error

TokenError printer

Types

type Action

type Action interface {
	fmt.Stringer
	Accept(d ActionDispatcher) error
	// contains filtered or unexported methods
}

Action абстракция действия

type ActionDispatcher

type ActionDispatcher interface {
	DispatchAnonymousOption(a *AnonymousOption) error
	DispatchAtEnd(a AtEnd) error
	DispatchRestLengthCheck(a RestLengthCheck) error
	DispatchErrorMismatch(a ErrorOnMismatch) error
	DispatchMayBeStartChar(a *MayBeStartChar) error
	DispatchMayBeStartString(a *MayBeStartString) error
	DispatchOptional(a *Optional) error
	DispatchOptionalSilent(a *OptionalSilent) error
	DispatchPassHeadingCharacters(a PassHeadingCharacters) error
	DispatchPassFirst(a PassFixed) error
	DispatchPassAfter(a *PassAfter) error
	DispatchPassAfterOrIgnore(a *PassAfterOrIgnore) error
	DispatchPassBefore(a *PassBefore) error
	DispatchPassBeforeOrIgnore(a *PassBeforeOrIgnore) error
	DispatchStartChar(a *StartChar) error
	DispatchStartCharWithoutPass(a *StartCharWithoutPass) error
	DispatchStartString(a *StartString) error
	DispatchStartStringWithoutPass(a *StartStringWithoutPass) error
	DispatchTake(a *Take) error
	DispatchTakeIncluding(a *TakeIncluding) error
	DispatchTakeRest(a *TakeRest) error
	DispatchTakeUntilOrRest(a *TakeUntilOrRest) error
	DispatchTakeUntilIncludingOrRest(a *TakeUntilIncludingOrRest) error
	DispatchRule(a *Rule) error
	DispatchTypeRegistration(a TypeRegistration) error
	DispatchCheckFixedWithoutPass(a *CheckFixedWithoutPass) error
}

ActionDispatcher is to be used by various actions to generate their arbitrary code

type AnonymousOption

type AnonymousOption struct {
	Name    string
	Comment []string
	Actions []Action

	StartToken antlr.Token
	// contains filtered or unexported fields
}

AnonymousOption ...

func Anonymous

func Anonymous(comment []string, opt antlr.Token) *AnonymousOption

Anonymous ...

func (*AnonymousOption) Accept

func (a *AnonymousOption) Accept(d ActionDispatcher) error

Accept ...

func (*AnonymousOption) Append

func (a *AnonymousOption) Append(i Action)

Append ...

func (*AnonymousOption) String

func (a *AnonymousOption) String() string

type AtEnd

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

AtEnd ...

func (AtEnd) Accept

func (a AtEnd) Accept(d ActionDispatcher) error

func (AtEnd) String

func (AtEnd) String() string

type CheckFixedWithoutPass added in v0.1.1

type CheckFixedWithoutPass struct {
	Limit *Target
	// contains filtered or unexported fields
}

CheckFixedWithoutPass ...

func CheckFixedTargetWithoutPass added in v0.1.1

func CheckFixedTargetWithoutPass() *CheckFixedWithoutPass

CheckFixedTargetWithoutPass ...

func (*CheckFixedWithoutPass) Accept added in v0.1.1

func (*CheckFixedWithoutPass) String added in v0.1.1

func (pu *CheckFixedWithoutPass) String() string

type ErrorListener

type ErrorListener struct {
	Line int
	Col  int
	Msg  string
}

ErrorListener representation of evil

func (*ErrorListener) ReportAmbiguity

func (el *ErrorListener) ReportAmbiguity(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex int, exact bool, ambigAlts *antlr.BitSet, configs antlr.ATNConfigSet)

func (*ErrorListener) ReportAttemptingFullContext

func (el *ErrorListener) ReportAttemptingFullContext(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex int, conflictingAlts *antlr.BitSet, configs antlr.ATNConfigSet)

func (*ErrorListener) ReportContextSensitivity

func (el *ErrorListener) ReportContextSensitivity(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex, prediction int, configs antlr.ATNConfigSet)

func (*ErrorListener) SyntaxError

func (el *ErrorListener) SyntaxError(recognizer antlr.Recognizer, offendingSymbol interface{}, line, column int, msg string, e antlr.RecognitionException)

type ErrorOnMismatch

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

ErrorOnMismatch ...

func (ErrorOnMismatch) Accept

func (ErrorOnMismatch) String

func (ErrorOnMismatch) String() string

type Field

type Field struct {
	Name    string
	Type    string
	Meta    FieldMeta
	Comment []string

	NameToken antlr.Token
	TypeToken antlr.Token
}

Field ...

func NewField

func NewField(comment []string, name antlr.Token, typeToken antlr.Token) Field

NewField constructor

type FieldMeta

type FieldMeta struct {
	Precision int
	Scale     int
}

FieldMeta additional type data, introduced specially for decimal types

type MayBeStartChar

type MayBeStartChar struct {
	Value string
	// contains filtered or unexported fields
}

MayBeStartChar ...

func MayBeStartsWithChar

func MayBeStartsWithChar(value antlr.Token) *MayBeStartChar

MayBeStartsWithChar ...

func (*MayBeStartChar) Accept

func (m *MayBeStartChar) Accept(d ActionDispatcher) error

func (*MayBeStartChar) String

func (m *MayBeStartChar) String() string

type MayBeStartString

type MayBeStartString struct {
	Value string
	// contains filtered or unexported fields
}

MayBeStartString ...

func MayBeStartsWithString

func MayBeStartsWithString(value antlr.Token) *MayBeStartString

MayBeStartsWithString ...

func (*MayBeStartString) Accept

func (*MayBeStartString) String

func (m *MayBeStartString) String() string

type Optional

type Optional struct {
	Name    string
	Comment []string
	Actions []Action

	NameToken antlr.Token
	// contains filtered or unexported fields
}

Optional ...

func Option

func Option(comment []string, opt antlr.Token) *Optional

Option ...

func (*Optional) Accept

func (o *Optional) Accept(d ActionDispatcher) error

func (*Optional) Append

func (o *Optional) Append(i Action)

Append ...

func (*Optional) String

func (o *Optional) String() string

type OptionalSilent added in v0.1.1

type OptionalSilent struct {
	Name    string
	Comment []string
	Actions []Action

	NameToken antlr.Token
	// contains filtered or unexported fields
}

OptionalSilent ...

func OptionSilent added in v0.1.1

func OptionSilent(comment []string, opt antlr.Token) *OptionalSilent

OptionSilent ...

func (*OptionalSilent) Accept added in v0.1.1

func (o *OptionalSilent) Accept(d ActionDispatcher) error

func (*OptionalSilent) Append added in v0.1.1

func (o *OptionalSilent) Append(i Action)

Append ...

func (*OptionalSilent) String added in v0.1.1

func (o *OptionalSilent) String() string

type PassAfter

type PassAfter struct {
	Limit *Target
	// contains filtered or unexported fields
}

PassAfter ...

func PassAfterTarget

func PassAfterTarget() *PassAfter

PassAfterTarget ...

func (*PassAfter) Accept

func (pu *PassAfter) Accept(d ActionDispatcher) error

func (*PassAfter) String

func (pu *PassAfter) String() string

type PassAfterOrIgnore

type PassAfterOrIgnore struct {
	Limit *Target
	// contains filtered or unexported fields
}

PassAfterOrIgnore ...

func PassAfterTargetOrIgnore

func PassAfterTargetOrIgnore() *PassAfterOrIgnore

PassAfterTargetOrIgnore ...

func (*PassAfterOrIgnore) Accept

func (*PassAfterOrIgnore) String

func (p *PassAfterOrIgnore) String() string

type PassBefore

type PassBefore struct {
	Limit *Target
	// contains filtered or unexported fields
}

PassBefore ...

func PassBeforeTarget

func PassBeforeTarget() *PassBefore

PassBeforeTarget ...

func (*PassBefore) Accept

func (pu *PassBefore) Accept(d ActionDispatcher) error

func (*PassBefore) String

func (pu *PassBefore) String() string

type PassBeforeOrIgnore

type PassBeforeOrIgnore struct {
	Limit *Target
	// contains filtered or unexported fields
}

PassBeforeOrIgnore ...

func PassBeforeTargetOrIgnore

func PassBeforeTargetOrIgnore() *PassBeforeOrIgnore

PassBeforeTargetOrIgnore ...

func (*PassBeforeOrIgnore) Accept

func (*PassBeforeOrIgnore) String

func (p *PassBeforeOrIgnore) String() string

type PassFixed

type PassFixed int

PassFixed ...

func PassFirst

func PassFirst(field antlr.Token) (res PassFixed, err error)

PassFirst ...

func (PassFixed) Accept

func (pf PassFixed) Accept(d ActionDispatcher) error

func (PassFixed) String

func (pf PassFixed) String() string

type PassHeadingCharacters

type PassHeadingCharacters string

func (PassHeadingCharacters) Accept

func (PassHeadingCharacters) String

func (a PassHeadingCharacters) String() string

type RestLengthCheck

type RestLengthCheck struct {
	Operator string
	Length   int
	// contains filtered or unexported fields
}

func RestCheck

func RestCheck(operator string, length int) RestLengthCheck

func (RestLengthCheck) Accept

func (RestLengthCheck) String

func (a RestLengthCheck) String() string

type Rule

type Rule struct {
	Name    string
	Comment []string
	Actions []Action

	NameToken antlr.Token
	// contains filtered or unexported fields
}

Rule is action as well

func NewRule

func NewRule(comment []string, name antlr.Token) *Rule

NewRule constructor

func (*Rule) Accept

func (r *Rule) Accept(d ActionDispatcher) error

func (*Rule) Append

func (r *Rule) Append(ai Action)

func (*Rule) String

func (r *Rule) String() string

type StartChar

type StartChar struct {
	Value string
	// contains filtered or unexported fields
}

StartChar ...

func StartsWithChar

func StartsWithChar(target antlr.Token) *StartChar

StartsWithChar ...

func (*StartChar) Accept

func (sc *StartChar) Accept(d ActionDispatcher) error

func (*StartChar) String

func (sc *StartChar) String() string

type StartCharWithoutPass

type StartCharWithoutPass struct {
	Value string
	// contains filtered or unexported fields
}

StartCharWithoutPass ...

func StartsWithCharWithoutPass

func StartsWithCharWithoutPass(target antlr.Token) *StartCharWithoutPass

StartsWithCharWithoutPass ...

func (*StartCharWithoutPass) Accept

func (*StartCharWithoutPass) String

func (sc *StartCharWithoutPass) String() string

type StartString

type StartString struct {
	Value string
	// contains filtered or unexported fields
}

StartString ...

func StartsWithString

func StartsWithString(target antlr.Token) *StartString

StartsWithString constructor

func (*StartString) Accept

func (ss *StartString) Accept(d ActionDispatcher) error

func (*StartString) String

func (ss *StartString) String() string

type StartStringWithoutPass

type StartStringWithoutPass struct {
	Value string
	// contains filtered or unexported fields
}

StartStringWithoutPass ...

func StartsWithStringWithoutPass

func StartsWithStringWithoutPass(target antlr.Token) *StartStringWithoutPass

StartsWithStringWithoutPass constructor

func (*StartStringWithoutPass) Accept

func (*StartStringWithoutPass) String

func (ss *StartStringWithoutPass) String() string

type Take

type Take struct {
	Field Field
	Limit *Target
	// contains filtered or unexported fields
}

Take ...

func TakeUntilTarget

func TakeUntilTarget(comment []string, field, fieldType antlr.Token) *Take

TakeUntilTarget ...

func (*Take) Accept

func (t *Take) Accept(d ActionDispatcher) error

func (*Take) String

func (t *Take) String() string

type TakeIncluding

type TakeIncluding struct {
	Field Field
	Limit *Target
	// contains filtered or unexported fields
}

TakeIncluding ...

func TakeUntilTargetIncluding

func TakeUntilTargetIncluding(comment []string, field, fieldType antlr.Token) *TakeIncluding

TakeUntilTargetIncluding ...

func (*TakeIncluding) Accept

func (t *TakeIncluding) Accept(d ActionDispatcher) error

Accept ...

func (*TakeIncluding) String

func (t *TakeIncluding) String() string

type TakeRest

type TakeRest struct {
	Field Field
	// contains filtered or unexported fields
}

TakeRest ...

func TakeTheRest

func TakeTheRest(comment []string, field, fieldType antlr.Token) *TakeRest

TakeTheRest ...

func (*TakeRest) Accept

func (tr *TakeRest) Accept(d ActionDispatcher) error

func (*TakeRest) String

func (tr *TakeRest) String() string

type TakeUntilIncludingOrRest

type TakeUntilIncludingOrRest struct {
	Field Field
	Limit *Target
	// contains filtered or unexported fields
}

TakeUntilOrRest ...

func TakeUntilTargetIncludingOrRest

func TakeUntilTargetIncludingOrRest(comment []string, field antlr.Token, fieldType antlr.Token) *TakeUntilIncludingOrRest

TakeUntilTargetIncludingOrRest ...

func (*TakeUntilIncludingOrRest) Accept

Accept ...

func (*TakeUntilIncludingOrRest) String

func (t *TakeUntilIncludingOrRest) String() string

type TakeUntilOrRest

type TakeUntilOrRest struct {
	Field Field
	Limit *Target
	// contains filtered or unexported fields
}

TakeUntilOrRest ...

func TakeUntilTargetOrRest

func TakeUntilTargetOrRest(comment []string, field antlr.Token, fieldType antlr.Token) *TakeUntilOrRest

TakeUntilTargetOrRest ...

func (*TakeUntilOrRest) Accept

func (t *TakeUntilOrRest) Accept(d ActionDispatcher) error

func (*TakeUntilOrRest) String

func (t *TakeUntilOrRest) String() string

type Target

type Target struct {
	Type  TargetEnum
	Value string
	Lower int
	Upper int
	Close bool
}

Target ...

func NewTarget

func NewTarget() *Target

NewTarget ...

func (*Target) SetBound

func (t *Target) SetBound(lower, upper int)

SetBound sets target bound

func (*Target) SetChar

func (t *Target) SetChar(text string) error

SetChar sets target into Char

func (*Target) SetClose

func (t *Target) SetClose()

SetClose sets target type to close

func (*Target) SetJump

func (t *Target) SetJump(lower int)

SetJump sets target offset jump

func (*Target) SetLimit

func (t *Target) SetLimit(upper int)

SetLimit sets target limit

func (*Target) SetString

func (t *Target) SetString(text string) error

SetString sets target into String

type TargetEnum

type TargetEnum int

TargetEnum ...

const (
	String TargetEnum = iota
	Char
)

func (TargetEnum) String

func (i TargetEnum) String() string

type TypeRegistration added in v0.1.0

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

func NewTypeRegistration added in v0.1.0

func NewTypeRegistration(tr map[string]types.TypeRegistration) TypeRegistration

func (TypeRegistration) Accept added in v0.1.0

func (TypeRegistration) String added in v0.1.0

func (t TypeRegistration) String() string

func (TypeRegistration) Types added in v0.1.0

Jump to

Keyboard shortcuts

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