lang

package
v0.0.0-...-88a1d00 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TagNull     = TagValue{Value: "#null"}
	TagComplete = TagValue{Value: "#complete"}
	TagContinue = TagValue{Value: "#continue"}
	TagBreak    = TagValue{Value: "#break"}
)
View Source
var (
	PlusOpMap = [TypeCount]func(any, any) any{
		TypeFloat:   func(a, b any) any { return FloatValue(a.(FloatValue) + b.(FloatValue)) },
		TypeInteger: func(a, b any) any { return IntegerValue(a.(IntegerValue) + b.(IntegerValue)) },
		TypeString:  func(a, b any) any { return StringValue(a.(StringValue) + b.(StringValue)) },
	}
	MinusOpMap = [TypeCount]func(any, any) any{
		TypeFloat:   func(a, b any) any { return FloatValue(a.(FloatValue) - b.(FloatValue)) },
		TypeInteger: func(a, b any) any { return IntegerValue(a.(IntegerValue) - b.(IntegerValue)) },
	}
	MultOpMap = [TypeCount]func(any, any) any{
		TypeFloat:   func(a, b any) any { return FloatValue(a.(FloatValue) * b.(FloatValue)) },
		TypeInteger: func(a, b any) any { return IntegerValue(a.(IntegerValue) * b.(IntegerValue)) },
	}
	DivOpMap = [TypeCount]func(any, any) any{
		TypeFloat:   func(a, b any) any { return FloatValue(a.(FloatValue) / b.(FloatValue)) },
		TypeInteger: func(a, b any) any { return IntegerValue(a.(IntegerValue) / b.(IntegerValue)) },
	}
	ModuloOpMap = [TypeCount]func(any, any) any{
		TypeInteger: func(a, b any) any { return IntegerValue(a.(IntegerValue) % b.(IntegerValue)) },
	}
	EqualOpMap = [TypeCount]func(any, any) BoolValue{
		TypeBool:    func(a, b any) BoolValue { return BoolValue(a.(BoolValue) == b.(BoolValue)) },
		TypeFloat:   func(a, b any) BoolValue { return BoolValue(a.(FloatValue) == b.(FloatValue)) },
		TypeInteger: func(a, b any) BoolValue { return BoolValue(a.(IntegerValue) == b.(IntegerValue)) },
		TypeString:  func(a, b any) BoolValue { return BoolValue(a.(StringValue) == b.(StringValue)) },
		TypeTag:     func(a, b any) BoolValue { return BoolValue(a.(TagValue).Value == b.(TagValue).Value) },
	}
	NotEqualOpMap = [TypeCount]func(any, any) BoolValue{
		TypeBool:    func(a, b any) BoolValue { return BoolValue(a.(BoolValue) != b.(BoolValue)) },
		TypeFloat:   func(a, b any) BoolValue { return BoolValue(a.(FloatValue) != b.(FloatValue)) },
		TypeInteger: func(a, b any) BoolValue { return BoolValue(a.(IntegerValue) != b.(IntegerValue)) },
		TypeString:  func(a, b any) BoolValue { return BoolValue(a.(StringValue) != b.(StringValue)) },
		TypeTag:     func(a, b any) BoolValue { return BoolValue(a.(TagValue).Value != b.(TagValue).Value) },
	}
	LessThanOpMap = [TypeCount]func(any, any) BoolValue{
		TypeFloat:   func(a, b any) BoolValue { return BoolValue(a.(FloatValue) < b.(FloatValue)) },
		TypeInteger: func(a, b any) BoolValue { return BoolValue(a.(IntegerValue) < b.(IntegerValue)) },
		TypeString:  func(a, b any) BoolValue { return BoolValue(a.(StringValue) < b.(StringValue)) },
	}
	LessThanOrEqualOpMap = [TypeCount]func(any, any) BoolValue{
		TypeFloat:   func(a, b any) BoolValue { return BoolValue(a.(FloatValue) <= b.(FloatValue)) },
		TypeInteger: func(a, b any) BoolValue { return BoolValue(a.(IntegerValue) <= b.(IntegerValue)) },
		TypeString:  func(a, b any) BoolValue { return BoolValue(a.(StringValue) <= b.(StringValue)) },
	}
	GreaterThanOpMap = [TypeCount]func(any, any) BoolValue{
		TypeFloat:   func(a, b any) BoolValue { return BoolValue(a.(FloatValue) > b.(FloatValue)) },
		TypeInteger: func(a, b any) BoolValue { return BoolValue(a.(IntegerValue) > b.(IntegerValue)) },
		TypeString:  func(a, b any) BoolValue { return BoolValue(a.(StringValue) > b.(StringValue)) },
	}
	GreaterThanOrEqualOpMap = [TypeCount]func(any, any) BoolValue{
		TypeFloat:   func(a, b any) BoolValue { return BoolValue(a.(FloatValue) >= b.(FloatValue)) },
		TypeInteger: func(a, b any) BoolValue { return BoolValue(a.(IntegerValue) >= b.(IntegerValue)) },
		TypeString:  func(a, b any) BoolValue { return BoolValue(a.(StringValue) >= b.(StringValue)) },
	}
)
View Source
var (
	NoErrors = CompileErrors{}
)
View Source
var (
	PipelineLexer = lexer.MustSimple([]lexer.SimpleRule{
		{
			Name:    "Scriptor",
			Pattern: `^#![^\n]*`,
		},
		{
			Name:    "Comment",
			Pattern: `//[^\n]*`,
		},
		{
			Name:    "DotDot",
			Pattern: `\.\.`,
		},
		{
			Name:    "AndAnd",
			Pattern: `&&`,
		},
		{
			Name:    "OrOr",
			Pattern: `\|\|`,
		},
		{
			Name:    "PlusEqual",
			Pattern: `\+=`,
		},
		{
			Name:    "Plus",
			Pattern: `\+`,
		},
		{
			Name:    "Minus",
			Pattern: `-`,
		},
		{
			Name:    "Star",
			Pattern: `\*`,
		},
		{
			Name:    "Slash",
			Pattern: `/`,
		},
		{
			Name:    "Percent",
			Pattern: `%`,
		},
		{
			Name:    "EqualEqual",
			Pattern: `==`,
		},
		{
			Name:    "BangEqual",
			Pattern: `!=`,
		},
		{
			Name:    "Bang",
			Pattern: `!`,
		},
		{
			Name:    "MoreMoreMore",
			Pattern: `>>>`,
		},
		{
			Name:    "MoreMore",
			Pattern: `>>`,
		},
		{
			Name:    "LessEqual",
			Pattern: `<=`,
		},
		{
			Name:    "MoreEqual",
			Pattern: `>=`,
		},
		{
			Name:    "Less",
			Pattern: `<`,
		},
		{
			Name:    "More",
			Pattern: `>`,
		},
		{
			Name:    "Bang",
			Pattern: `!`,
		},
		{
			Name:    "ColonEqual",
			Pattern: `:=`,
		},
		{
			Name:    "Colon",
			Pattern: `:`,
		},
		{
			Name:    "String",
			Pattern: `"(\\"|[^"])*"`,
		},
		{
			Name:    "Function",
			Pattern: `fn`,
		},
		{
			Name:    "FTail",
			Pattern: `ƒ`,
		},
		{
			Name:    "Tag",
			Pattern: `#[a-zA-Z0-9_][a-zA-Z0-9_-]*`,
		},
		{
			Name:    "Ident",
			Pattern: `[a-zA-Z_\$]\w*`,
		},
		{
			Name:    "Punct",
			Pattern: `[-[!@#$%^&*()+_={}\|:;"'<,>.?/]|]`,
		},
		{
			Name:    "EOL",
			Pattern: `[\n\r]+`,
		},
		{
			Name:    "whitespace",
			Pattern: `[ \t]+`,
		},
		{

			Name:    "DateTime",
			Pattern: `\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?([+-]\d\d:\d\d)?`,
		},
		{

			Name:    "Date",
			Pattern: `\d\d\d\d-\d\d-\d\d`,
		},
		{

			Name:    "Time",
			Pattern: `\d\d:\d\d:\d\d(\.\d+)?`,
		},
		{

			Name:    "TimeSpan",
			Pattern: `(\d+[ymdhs])+`,
		},
		{
			Name:    "Float",
			Pattern: `[-+]?\d+\.\d+`,
		},
		{
			Name:    "Integer",
			Pattern: `[-+]?\d\d*`,
		},
	})
)

Functions

func IsIdentifier

func IsIdentifier(e Executable) bool

Types

type Addition

type Addition struct {
	Pos lexer.Position

	Multiplication *Multiplication `parser:"@@"`
	Operations     []*OpAddition   `parser:"@@*"`
}

func (*Addition) Compile

func (a *Addition) Compile(typeMap TypeMap) (Executable, CompileErrors)

func (Addition) String

func (a Addition) String() string

type Assignment

type Assignment struct {
	Pos lexer.Position

	Pipe      *Pipe         `parser:"@@"`
	Operation *OpAssignment `parser:"@@?"`
}

func (*Assignment) Compile

func (a *Assignment) Compile(typeMap TypeMap) (Executable, CompileErrors)

func (Assignment) String

func (a Assignment) String() string

type AssignmentExecute

type AssignmentExecute struct {
	Assignment *Assignment
	Left       IdentifierValue
	Right      Executable
}

func (AssignmentExecute) Execute

func (AssignmentExecute) ListRep

func (ae AssignmentExecute) ListRep() []any

func (AssignmentExecute) Type

func (ae AssignmentExecute) Type(typeMap TypeMap) Type

type Base

type Base struct {
	Pos lexer.Position

	Subexpression   *Expression      `parser:"  '(' @@ ')' "`
	List            *List            `parser:"| @@"`
	UnnamedFunction *UnnamedFunction `parser:"| @@ "`
	Invocation      *Invocation      `parser:"| @@ "`
	StringValue     *string          `parser:"| @String "`
	Bool            *string          `parser:"| @('true' | 'false')"`
	Tag             *string          `parser:"| @Tag"`
	Ident           *string          `parser:"| @Ident "`
	// DateTime      *string      `parser:"| @DateTime"`
	// Date          *string      `parser:"| @Date"`
	// Time          *string      `parser:"| @Time"`
	Float   *float64 `parser:"| @Float"`
	Integer *int64   `parser:"| @Integer"`
}

func (*Base) Compile

func (b *Base) Compile(typeMap TypeMap) (Executable, CompileErrors)

func (Base) String

func (b Base) String() string

type BinaryOperation

type BinaryOperation struct {
	Pos lexer.Position

	Name        string
	Func        func(any, any) any
	Left, Right Executable
	TypeVal     Type
}

func (BinaryOperation) Execute

func (BinaryOperation) ListRep

func (bo BinaryOperation) ListRep() []any

func (BinaryOperation) Type

func (bo BinaryOperation) Type(typeMap TypeMap) Type

type BoolValue

type BoolValue bool

func (BoolValue) Execute

func (BoolValue) ListRep

func (b BoolValue) ListRep() []any

func (BoolValue) Type

func (b BoolValue) Type(typeMap TypeMap) Type

type Command

type Command struct {
	Pos lexer.Position

	Scriptor      *string        `parser:"  @Scriptor "`
	Comment       *Comment       `parser:"| @@ "`
	EOL           *string        `parser:"| @EOL "`
	NamedFunction *NamedFunction `parser:"| @@ "` // named functions only allowed at top level
	Expression    *Expression    `parser:"| @@ (EOL|EOF|(Comment (EOL|EOF))) "`
}

Command is basically a line, or a multi-line.

func (Command) String

func (c Command) String() string

type Comment

type Comment struct {
	Pos lexer.Position

	Comment string `parser:" @Comment (EOL|EOF) "`
}

func (Comment) String

func (c Comment) String() string

type Comparison

type Comparison struct {
	Pos lexer.Position

	Series     *Series         `parser:"@@"`
	Operations []*OpComparison `parser:"@@*"`
}

func (*Comparison) Compile

func (c *Comparison) Compile(typeMap TypeMap) (Executable, CompileErrors)

func (Comparison) String

func (c Comparison) String() string

type ComparisonOperation

type ComparisonOperation struct {
	Pos lexer.Position

	Name        string
	Func        func(any, any) BoolValue
	Left, Right Executable
}

func (ComparisonOperation) Execute

func (ComparisonOperation) ListRep

func (co ComparisonOperation) ListRep() []any

func (ComparisonOperation) Type

func (co ComparisonOperation) Type(typeMap TypeMap) Type

type CompileErrors

type CompileErrors struct {
	Errs *[]error
}

func NewError

func NewError(err error) CompileErrors

func (*CompileErrors) Append

func (ce *CompileErrors) Append(err ...error) CompileErrors

func (*CompileErrors) Collect

func (ce *CompileErrors) Collect(e Executable, errs CompileErrors) Executable

func (CompileErrors) Len

func (ce CompileErrors) Len() int

type Executable

type Executable interface {
	Execute(*ExecutionEnvironment) ExecutionResult
	Type(TypeMap) Type
	ListRep() []any
}

type ExecutableBlock

type ExecutableBlock struct {
	Commands []Executable
}

func (ExecutableBlock) Execute

func (ExecutableBlock) ListRep

func (b ExecutableBlock) ListRep() []any

func (ExecutableBlock) Type

func (b ExecutableBlock) Type(typeMap TypeMap) Type

type ExecutionEnvironment

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

func NewExecutionEnvironment

func NewExecutionEnvironment() *ExecutionEnvironment

func (*ExecutionEnvironment) Get

func (ee *ExecutionEnvironment) Get(key string) any

func (*ExecutionEnvironment) GlobalExists

func (ee *ExecutionEnvironment) GlobalExists(key string) bool

func (*ExecutionEnvironment) NewLocalEnvironment

func (ee *ExecutionEnvironment) NewLocalEnvironment() *ExecutionEnvironment

func (*ExecutionEnvironment) Set

func (ee *ExecutionEnvironment) Set(key string, value any)

func (*ExecutionEnvironment) SetGlobal

func (ee *ExecutionEnvironment) SetGlobal(key string, value any)

type ExecutionResult

type ExecutionResult any

type Expression

type Expression struct {
	Pos lexer.Position

	Assignment *Assignment `parser:"@@"`
}

func (Expression) Compile

func (e Expression) Compile(typeMap TypeMap) (Executable, CompileErrors)

func (Expression) String

func (e Expression) String() string

type FloatValue

type FloatValue float64

func (FloatValue) Execute

func (FloatValue) ListRep

func (f FloatValue) ListRep() []any

func (FloatValue) Type

func (f FloatValue) Type(typeMap TypeMap) Type

type FunctionExecute

type FunctionExecute struct {
	*NamedFunction
	*UnnamedFunction
	ExecutableBlock
}

func (FunctionExecute) Apply

func (FunctionExecute) Execute

func (FunctionExecute) ListRep

func (fe FunctionExecute) ListRep() []any

func (FunctionExecute) ParameterNames

func (fe FunctionExecute) ParameterNames() []string

func (FunctionExecute) Type

func (fe FunctionExecute) Type(typeMap TypeMap) Type

type IdentifierValue

type IdentifierValue struct {
	Base  *Base
	Value string
}

func (IdentifierValue) Execute

func (IdentifierValue) ListRep

func (i IdentifierValue) ListRep() []any

func (IdentifierValue) Type

func (i IdentifierValue) Type(typeMap TypeMap) Type

type InnerFunctionExecute

type InnerFunctionExecute struct {
	Pos lexer.Position

	Function func() ExecutionResult
}

func (InnerFunctionExecute) Apply

func (InnerFunctionExecute) Execute

func (InnerFunctionExecute) ListRep

func (ife InnerFunctionExecute) ListRep() []any

func (InnerFunctionExecute) ParameterNames

func (ife InnerFunctionExecute) ParameterNames() []string

func (InnerFunctionExecute) Type

func (ife InnerFunctionExecute) Type(typeMap TypeMap) Type

type IntegerValue

type IntegerValue int64

func (IntegerValue) Execute

func (IntegerValue) ListRep

func (i IntegerValue) ListRep() []any

func (IntegerValue) Type

func (i IntegerValue) Type(typeMap TypeMap) Type

type Invocation

type Invocation struct {
	Pos lexer.Position

	Name      *string       `parser:" @Ident "`
	Arguments []*Expression `parser:" '(' @@? ( ',' @@ )* ')' "`
}

func (*Invocation) Compile

func (i *Invocation) Compile(typeMap TypeMap) (Executable, CompileErrors)

func (Invocation) String

func (i Invocation) String() string

type InvocationExecute

type InvocationExecute struct {
	*Invocation
	ProducerExecutable  Executable
	ExecutableArguments []Executable
}

func (InvocationExecute) Execute

func (InvocationExecute) ListRep

func (i InvocationExecute) ListRep() []any

func (InvocationExecute) Type

func (i InvocationExecute) Type(typeMap TypeMap) Type

type KeyValue

type KeyValue struct {
	Pos lexer.Position

	Addition   *Addition `parser:"@@"`
	RightValue *Addition `parser:"( Colon (EOL|Comment EOL)* @@ )?"`
}

KeyValue parses a key-value pair. If there is no colon, then it's just a value.

func (*KeyValue) Compile

func (kv *KeyValue) Compile(typeMap TypeMap) (Executable, CompileErrors)

func (KeyValue) String

func (kv KeyValue) String() string

type KeyValueExecute

type KeyValueExecute struct {
	KeyValue *KeyValue

	Key   Executable
	Value Executable
}

func (KeyValueExecute) Execute

func (KeyValueExecute) ListRep

func (kve KeyValueExecute) ListRep() []any

func (KeyValueExecute) Type

func (kve KeyValueExecute) Type(typeMap TypeMap) Type

type KeyValueResult

type KeyValueResult struct {
	Key   any
	Value any
}

type List

type List struct {
	Pos lexer.Position

	Items []*Expression `parser:"'[' (EOL|Comment EOL)* @@? ( ',' (EOL|Comment EOL)* @@ )* (EOL|Comment EOL)* ']' "`
}

func (List) Compile

func (l List) Compile(typeMap TypeMap) (Executable, CompileErrors)

func (List) String

func (l List) String() string

type ListExecute

type ListExecute struct {
	List *List

	Items []Executable
}

func (ListExecute) Execute

func (ListExecute) ListRep

func (le ListExecute) ListRep() []any

func (ListExecute) Type

func (le ListExecute) Type(typeMap TypeMap) Type

type ListResult

type ListResult struct {
	Items []any
}

type ListValue

type ListValue []Executable

func (ListValue) Execute

func (ListValue) Type

func (l ListValue) Type(typeMap TypeMap) Type

type Logical

type Logical struct {
	Pos lexer.Position

	Comparison *Comparison  `parser:"@@"`
	Operations []*OpLogical `parser:"@@*"`
}

func (*Logical) Compile

func (l *Logical) Compile(typeMap TypeMap) (Executable, CompileErrors)

func (Logical) String

func (l Logical) String() string

type Multiplication

type Multiplication struct {
	Pos lexer.Position

	Unary      *Unary              `parser:"@@"`
	Operations []*OpMultiplication `parser:"@@*"`
}

func (*Multiplication) Compile

func (m *Multiplication) Compile(typeMap TypeMap) (Executable, CompileErrors)

func (Multiplication) String

func (x Multiplication) String() string

type NamedFunction

type NamedFunction struct {
	Pos lexer.Position

	Func   *string        `parser:" @Function "`
	Name   *string        `parser:" @Ident "`
	Params []string       `parser:" '(' @Ident? (',' @Ident)* ')' "`
	Body   *RequiredBlock `parser:"@@"`
}

func (*NamedFunction) Compile

func (nf *NamedFunction) Compile(typeMap TypeMap) (Executable, CompileErrors)

func (NamedFunction) String

func (f NamedFunction) String() string

type OpAddition

type OpAddition struct {
	Pos lexer.Position

	Op      string          `parser:"@( Plus | Minus ) (EOL|Comment EOL)*"`
	Operand *Multiplication `parser:"@@"`
}

type OpAssignment

type OpAssignment struct {
	Pos lexer.Position

	Op      string `parser:"@( ColonEqual | PlusEqual ) (EOL|Comment EOL)*"`
	Operand *Pipe  `parser:"@@"`
}

type OpComparison

type OpComparison struct {
	Pos lexer.Position

	Op      string  `parser:"@( EqualEqual | BangEqual | LessEqual | MoreEqual | Less | More ) (EOL|Comment EOL)*"`
	Operand *Series `parser:"@@"`
}

type OpLogical

type OpLogical struct {
	Pos lexer.Position

	Op      string      `parser:"@( AndAnd | OrOr ) (EOL|Comment EOL)*"`
	Operand *Comparison `parser:"@@"`
}

type OpMultiplication

type OpMultiplication struct {
	Pos lexer.Position

	Op      string `parser:"@( Star | Slash | Percent ) (EOL|Comment EOL)*"`
	Operand *Unary `parser:"@@"`
}

type OpPipe

type OpPipe struct {
	Pos lexer.Position

	Op      string   `parser:"@( MoreMore | MoreMoreMore ) (EOL|Comment EOL)*"`
	Operand *Logical `parser:"@@"`
}

type Operator

type Operator string

type Parameterized

type Parameterized interface {
	Executable
	ParameterNames() []string
	Apply(*ExecutionEnvironment) ExecutionResult
}

type Pipe

type Pipe struct {
	Pos lexer.Position

	Logical    *Logical  `parser:"@@"`
	Operations []*OpPipe `parser:"@@*"`
}

func (*Pipe) Compile

func (p *Pipe) Compile(typeMap TypeMap) (Executable, CompileErrors)

func (Pipe) String

func (p Pipe) String() string

type PipeExecute

type PipeExecute struct {
	Pipe *Pipe

	DoComplete []bool
	Commands   []Executable
}

func (PipeExecute) Execute

func (PipeExecute) ListRep

func (pe PipeExecute) ListRep() []any

func (PipeExecute) Type

func (pe PipeExecute) Type(typeMap TypeMap) Type

type PlusAssignmentExecute

type PlusAssignmentExecute struct {
	Assignment *Assignment
	Left       IdentifierValue
	Right      Executable
}

func (PlusAssignmentExecute) Execute

func (PlusAssignmentExecute) ListRep

func (pae PlusAssignmentExecute) ListRep() []any

func (PlusAssignmentExecute) Type

func (pae PlusAssignmentExecute) Type(typeMap TypeMap) Type

type Program

type Program struct {
	Pos lexer.Position

	Commands []*Command `parser:"@@*"`
}

func (Program) Compile

func (p Program) Compile(typeMap TypeMap) (ProgramExecute, CompileErrors)

func (Program) String

func (p Program) String() string

type ProgramExecute

type ProgramExecute struct {
	Program        Program
	NamedFunctions []FunctionExecute
	ExecutableBlock
}

func (ProgramExecute) DumpFunctions

func (pe ProgramExecute) DumpFunctions()

func (ProgramExecute) DumpProgram

func (pe ProgramExecute) DumpProgram()

func (ProgramExecute) ExecuteProgram

func (pe ProgramExecute) ExecuteProgram() ExecutionResult

type RequiredBlock

type RequiredBlock struct {
	Pos lexer.Position

	LeftBrace  *string       `parser:" @'{' "`
	Statements []*Expression `parser:" (@@ | Comment EOL | EOL)* "`
	RightBrace *string       `parser:" @'}' "`
}

func (*RequiredBlock) Compile

func (rb *RequiredBlock) Compile(typeMap TypeMap) (Executable, CompileErrors)

func (RequiredBlock) String

func (rb RequiredBlock) String() string

type Series

type Series struct {
	Pos lexer.Position

	FromValue *KeyValue `parser:" @@ "`
	ToValue   *KeyValue `parser:" ( DotDot @@ )? "`
}

Series parses a n..m series.

func (*Series) Compile

func (s *Series) Compile(typeMap TypeMap) (Executable, CompileErrors)

func (Series) String

func (s Series) String() string

type SeriesExecute

type SeriesExecute struct {
	Series *Series

	From Executable
	To   Executable
}

func (SeriesExecute) Execute

func (SeriesExecute) ListRep

func (se SeriesExecute) ListRep() []any

func (SeriesExecute) Type

func (se SeriesExecute) Type(typeMap TypeMap) Type

type ShortCircuitAnd

type ShortCircuitAnd struct {
	Left, Right Executable
}

func (ShortCircuitAnd) Execute

Execute returns the result of the left expression if it is false, otherwise it returns the result of the right expression.

func (ShortCircuitAnd) ListRep

func (sca ShortCircuitAnd) ListRep() []any

func (ShortCircuitAnd) Type

func (sca ShortCircuitAnd) Type(typeMap TypeMap) Type

type ShortCircuitOr

type ShortCircuitOr struct {
	Left, Right Executable
}

func (ShortCircuitOr) Execute

Execute returns the result of the left expression if it is true, otherwise it returns the result of the right expression.

func (ShortCircuitOr) ListRep

func (sco ShortCircuitOr) ListRep() []any

func (ShortCircuitOr) Type

func (sco ShortCircuitOr) Type(typeMap TypeMap) Type

type StatementBlock

type StatementBlock struct {
	Pos lexer.Position

	Statements []*Expression `parser:" (@@ | Comment EOL | EOL)* "`
}

func (StatementBlock) String

func (s StatementBlock) String() string

type StringValue

type StringValue string

func (StringValue) Execute

func (StringValue) ListRep

func (s StringValue) ListRep() []any

func (StringValue) Type

func (s StringValue) Type(typeMap TypeMap) Type

type TagValue

type TagValue struct {
	Base  *Base
	Value string
}

func (TagValue) Execute

func (TagValue) ListRep

func (t TagValue) ListRep() []any

func (TagValue) Type

func (t TagValue) Type(typeMap TypeMap) Type

type Type

type Type uint
const (
	TypeUnknown Type = iota
	TypeTag
	TypeIdentifier
	TypeBool
	TypeFloat
	TypeInteger
	TypeString
	TypeList
	TypeKeyValue
	TypeFunction
	TypeCount
)

func TypeOf

func TypeOf(x any) Type

func (Type) String

func (t Type) String() string

type TypeMap

type TypeMap map[string]Type

type Unary

type Unary struct {
	Pos lexer.Position

	Op    *string `parser:"  ( @( Bang | Minus )"`
	Unary *Unary  `parser:"    @@ )"`
	Base  *Base   `parser:"| @@"`
}

func (*Unary) Compile

func (u *Unary) Compile(typeMap TypeMap) (Executable, CompileErrors)

func (Unary) String

func (x Unary) String() string

type UnaryExecuteMinusInteger

type UnaryExecuteMinusInteger struct {
	Unary   *Unary
	Operand Executable
}

func (UnaryExecuteMinusInteger) Execute

func (UnaryExecuteMinusInteger) ListRep

func (uemi UnaryExecuteMinusInteger) ListRep() []any

func (UnaryExecuteMinusInteger) Type

func (uemi UnaryExecuteMinusInteger) Type(typeMap TypeMap) Type

type UnaryExecuteNot

type UnaryExecuteNot struct {
	Unary   *Unary
	Operand Executable
}

func (UnaryExecuteNot) Execute

func (UnaryExecuteNot) ListRep

func (uen UnaryExecuteNot) ListRep() []any

func (UnaryExecuteNot) Type

func (uen UnaryExecuteNot) Type(typeMap TypeMap) Type

type UnaryExecuteSubtractFloat

type UnaryExecuteSubtractFloat struct {
	Unary   *Unary
	Operand Executable
}

func (UnaryExecuteSubtractFloat) Execute

func (UnaryExecuteSubtractFloat) ListRep

func (uemf UnaryExecuteSubtractFloat) ListRep() []any

func (UnaryExecuteSubtractFloat) Type

func (uemf UnaryExecuteSubtractFloat) Type(typeMap TypeMap) Type

type UnnamedFunction

type UnnamedFunction struct {
	Pos lexer.Position

	Func   *string        `parser:" Function "`
	Params []string       `parser:" '(' @Ident? (',' @Ident)* ')' "`
	Body   *RequiredBlock `parser:"@@"`
}

func (*UnnamedFunction) Compile

func (uf *UnnamedFunction) Compile(typeMap TypeMap) (Executable, CompileErrors)

func (UnnamedFunction) String

func (f UnnamedFunction) String() string

Jump to

Keyboard shortcuts

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