aladino

package
v3.27.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: LGPL-3.0 Imports: 24 Imported by: 0

README

Aladino language

Documentation

Index

Constants

View Source
const (
	BOOL_CONST          string = "BoolConst"
	INT_CONST           string = "IntConst"
	STRING_CONST        string = "StringConst"
	TIME_CONST          string = "TimeConst"
	VARIABLE_CONST      string = "Variable"
	UNARY_OP_CONST      string = "UnaryOp"
	BINARY_OP_CONST     string = "BinaryOp"
	FUNCTION_CALL_CONST string = "FunctionCall"
	LAMBDA_CONST        string = "Lambda"
	TYPED_EXPR          string = "TypedExpr"
	ARRAY_CONST         string = "Array"
	NOT_OP              string = "!"
	EQ_OP               string = "=="
	NEQ_OP              string = "!="
	AND_OP              string = "&&"
	OR_OP               string = "||"
	LESS_THAN_OP        string = "<"
	LESS_EQ_THAN_OP     string = "<="
	GREATER_THAN_OP     string = ">"
	GREATER_EQ_THAN_OP  string = ">="
)
View Source
const (
	BOOL_TYPE          string = "BoolType"
	INT_TYPE           string = "IntType"
	STRING_TYPE        string = "StringType"
	FUNCTION_TYPE      string = "FunctionType"
	ARRAY_TYPE         string = "ArrayType"
	ARRAY_OF_TYPE      string = "ArrayOfType"
	JSON_TYPE          string = "JSONType"
	DYNAMIC_ARRAY_TYPE string = "DynamicArrayType"
)
View Source
const (
	INT_VALUE      string = "IntValue"
	BOOL_VALUE     string = "BoolValue"
	STRING_VALUE   string = "StringValue"
	TIME_VALUE     string = "TimeValue"
	ARRAY_VALUE    string = "ArrayValue"
	FUNCTION_VALUE string = "FunctionValue"
	JSON_VALUE     string = "JSONValue"
)
View Source
const AladinoEofCode = 1
View Source
const AladinoErrCode = 2
View Source
const AladinoFlag = -1000
View Source
const AladinoInitialStackSize = 16
View Source
const AladinoLast = 106
View Source
const AladinoPrivate = 57344
View Source
const DefaultMockEntityNodeID = "test"
View Source
const DefaultMockEventAction = "opened"
View Source
const DefaultMockEventName = "pull_request"
View Source
const DefaultMockPrID = 1234
View Source
const DefaultMockPrNum = 6
View Source
const DefaultMockPrOwner = "foobar"
View Source
const DefaultMockPrRepoName = "default-mock-repo"
View Source
const EOF = 0
View Source
const FALSE = 57362
View Source
const IDENTIFIER = 57348
View Source
const NUMBER = 57360
View Source
const RELATIVETIMESTAMP = 57347
View Source
const ReviewpadMetricReportCommentAnnotation = "<!--@annotation-reviewpad-metric-report-->"
View Source
const ReviewpadReportCommentAnnotation = "<!--@annotation-reviewpad-report-->"
View Source
const STRINGLITERAL = 57349
View Source
const TIMESTAMP = 57346
View Source
const TK_AND = 57364
View Source
const TK_BOOL_ARRAY_TYPE = 57358
View Source
const TK_BOOL_TYPE = 57355
View Source
const TK_CMPOP = 57350
View Source
const TK_EQ = 57365
View Source
const TK_FUNCTION_TYPE = 57359
View Source
const TK_INT_ARRAY_TYPE = 57357
View Source
const TK_INT_TYPE = 57354
View Source
const TK_LAMBDA = 57351
View Source
const TK_NEQ = 57366
View Source
const TK_NOT = 57367
View Source
const TK_OR = 57363
View Source
const TK_STRING_ARRAY_TYPE = 57356
View Source
const TK_STRING_TYPE = 57353
View Source
const TK_TYPE = 57352
View Source
const TRUE = 57361

Variables

View Source
var (
	AladinoDebug        = 0
	AladinoErrorVerbose = false
)
View Source
var AladinoAct = [...]int{}/* 106 elements not displayed */
View Source
var AladinoChk = [...]int{
	-1000, -6, -1, 25, 26, 4, 5, 18, 7, 28,
	30, 19, 20, 22, 21, 23, 24, 8, -1, -1,
	-3, -2, -1, 6, -1, -1, -1, -1, -1, 27,
	32, 9, 29, 31, 26, -4, 11, 12, 13, 28,
	17, -1, -2, -2, 31, 29, 26, 27, 27, -3,
	-1, -4, -5, -4, 27, 31, -4, -5,
}
View Source
var AladinoDef = [...]int{
	0, -2, 1, 0, 28, 9, 10, 11, 12, 31,
	0, 15, 16, 0, 0, 0, 0, 0, 2, 0,
	0, 0, 30, 14, 3, 4, 5, 6, 7, 8,
	0, 0, 13, 31, 31, 27, 19, 20, 21, 0,
	0, 0, 29, 0, 28, 0, 0, 18, 17, 26,
	0, 22, 0, 25, 0, 0, 23, 24,
}
View Source
var AladinoErrorMessages = [...]struct {
	state int
	token int
	msg   string
}{}
View Source
var AladinoExca = [...]int{
	-1, 1,
	1, -1,
	-2, 0,
}
View Source
var AladinoPact = [...]int{
	7, -1000, 75, 7, 7, -1000, -1000, -1000, -1000, 7,
	22, -1000, -1000, 7, 7, 7, 7, 7, -1000, 21,
	15, -16, 46, -3, 28, 81, -1000, -1000, -1000, -1000,
	67, 7, -1000, 7, 7, -22, -1000, -1000, -1000, -19,
	-4, 64, -1000, -6, 7, 67, 67, -1000, -1000, -1000,
	42, -1000, -12, -23, 67, 67, -1000, -1000,
}
View Source
var AladinoPgo = [...]int{
	0, 2, 5, 4, 0, 1, 30,
}
View Source
var AladinoR1 = [...]int{
	0, 6, 1, 1, 1, 1, 1, 1, 1, 1,
	1, 1, 1, 1, 1, 1, 1, 1, 1, 4,
	4, 4, 4, 4, 5, 5, 3, 3, 3, 2,
	2, 2,
}
View Source
var AladinoR2 = [...]int{
	0, 1, 2, 3, 3, 3, 3, 3, 3, 1,
	1, 1, 1, 3, 2, 1, 1, 5, 5, 1,
	1, 1, 3, 5, 3, 1, 5, 3, 0, 3,
	1, 0,
}
View Source
var AladinoStatenames = [...]string{}
View Source
var AladinoTok1 = [...]int{
	1, 3, 3, 3, 3, 3, 3, 3, 3, 3,
	3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
	3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
	3, 3, 3, 3, 3, 3, 30, 3, 3, 3,
	26, 27, 3, 3, 31, 3, 3, 3, 3, 3,
	3, 3, 3, 3, 3, 3, 3, 3, 32, 3,
	3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
	3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
	3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
	3, 28, 3, 29,
}
View Source
var AladinoTok2 = [...]int{
	2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
	12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
	22, 23, 24, 25,
}
View Source
var AladinoTok3 = [...]int{
	0,
}
View Source
var AladinoToknames = [...]string{
	"$end",
	"error",
	"$unk",
	"TIMESTAMP",
	"RELATIVETIMESTAMP",
	"IDENTIFIER",
	"STRINGLITERAL",
	"TK_CMPOP",
	"TK_LAMBDA",
	"TK_TYPE",
	"TK_STRING_TYPE",
	"TK_INT_TYPE",
	"TK_BOOL_TYPE",
	"TK_STRING_ARRAY_TYPE",
	"TK_INT_ARRAY_TYPE",
	"TK_BOOL_ARRAY_TYPE",
	"TK_FUNCTION_TYPE",
	"NUMBER",
	"TRUE",
	"FALSE",
	"TK_OR",
	"TK_AND",
	"TK_EQ",
	"TK_NEQ",
	"TK_NOT",
	"'('",
	"')'",
	"'['",
	"']'",
	"'$'",
	"','",
	"':'",
}
View Source
var DefaultMockCollector, _ = collector.NewCollector("", "distinctId", "pull_request", "runnerName", nil)
View Source
var DefaultMockContext = context.Background()
View Source
var DefaultMockEventDetails = &handler.EventDetails{
	EventName:   DefaultMockEventName,
	EventAction: DefaultMockEventAction,
}
View Source
var DefaultMockLogger = logrus.NewEntry(logrus.New()).WithField("prefix", "[aladino]")
View Source
var DefaultMockPrDate = time.Date(2009, 11, 17, 20, 34, 58, 651387237, time.UTC)
View Source
var DefaultMockTargetEntity = &handler.TargetEntity{
	Owner:  DefaultMockPrOwner,
	Repo:   DefaultMockPrRepoName,
	Number: DefaultMockPrNum,
	Kind:   handler.PullRequest,
}

Functions

func AddReportComment

func AddReportComment(env Env, report string) error

func AladinoErrorMessage

func AladinoErrorMessage(state, lookAhead int) string

func AladinoParse

func AladinoParse(Aladinolex AladinoLexer) int

func AladinoStatname

func AladinoStatname(s int) string

func AladinoTokname

func AladinoTokname(c int) string

func Aladinolex1

func Aladinolex1(lex AladinoLexer, lval *AladinoSymType) (char, token int)

func BuildDryRunExecutionReport added in v3.23.0

func BuildDryRunExecutionReport(program *engine.Program) string

func BuildInternalLabelID

func BuildInternalLabelID(id string) string

func BuildInternalRuleName

func BuildInternalRuleName(name string) string

func BuildVerboseReport

func BuildVerboseReport(report *Report) string

func DeleteReportComment

func DeleteReportComment(env Env, commentId int64) error

func EqualList

func EqualList(left []Expr, right []Expr) bool

func EvalCondition

func EvalCondition(env Env, expr Expr) (bool, error)

EvalCondition evaluates a boolean expression Pre-condition: the type of expr is BoolType

func EvalExpr

func EvalExpr(env Env, kind, expr string) (bool, error)

func FindReportCommentByAnnotation added in v3.13.0

func FindReportCommentByAnnotation(env Env, annotation string) (*github.IssueComment, error)

func GetDefaultMockIssueDetails added in v3.13.0

func GetDefaultMockIssueDetails() *github.Issue

func GetDefaultMockPullRequestDetails added in v3.1.0

func GetDefaultMockPullRequestDetails() *github.PullRequest

func GetDefaultMockPullRequestDetailsWith added in v3.1.0

func GetDefaultMockPullRequestDetailsWith(pr *github.PullRequest) *github.PullRequest

func MockDefaultGithubAppClient added in v3.19.0

func MockDefaultGithubAppClient(ghApiClientOptions []mock.MockBackendOption) *gh.GithubAppClient

func MockDefaultGithubClient added in v3.3.0

func MockDefaultGithubClient(ghApiClientOptions []mock.MockBackendOption, ghGraphQLHandler func(http.ResponseWriter, *http.Request)) *gh.GithubClient

func NewInterpreter

func NewInterpreter(
	ctx context.Context,
	logger *logrus.Entry,
	dryRun bool,
	githubClient *gh.GithubClient,
	collector collector.Collector,
	targetEntity *handler.TargetEntity,
	eventPayload interface{},
	builtIns *BuiltIns,
) (engine.Interpreter, error)

func UpdateReportComment

func UpdateReportComment(env Env, commentId int64, report string) error

Types

type AladinoLex

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

func (*AladinoLex) Error

func (l *AladinoLex) Error(s string)

func (*AladinoLex) Lex

func (l *AladinoLex) Lex(lval *AladinoSymType) int

type AladinoLexer

type AladinoLexer interface {
	Lex(lval *AladinoSymType) int
	Error(s string)
}

type AladinoParser

type AladinoParser interface {
	Parse(AladinoLexer) int
	Lookahead() int
}

func AladinoNewParser

func AladinoNewParser() AladinoParser

type AladinoParserImpl

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

func (*AladinoParserImpl) Lookahead

func (p *AladinoParserImpl) Lookahead() int

func (*AladinoParserImpl) Parse

func (Aladinorcvr *AladinoParserImpl) Parse(Aladinolex AladinoLexer) int

type AladinoSymType

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

type AndOp

type AndOp struct{}

func (*AndOp) Eval

func (op *AndOp) Eval(lhs, rhs Value) Value

type Array

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

func BuildArray

func BuildArray(elems []Expr) *Array

func (*Array) Eval

func (a *Array) Eval(e Env) (Value, error)

func (*Array) Kind

func (a *Array) Kind() string

type ArrayOfType

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

func BuildArrayOfType

func BuildArrayOfType(elemType Type) *ArrayOfType

func (*ArrayOfType) Kind

func (aTy *ArrayOfType) Kind() string

type ArrayType

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

func BuildArrayType

func BuildArrayType(elemsTypes []Type) *ArrayType

func (*ArrayType) Kind

func (aTy *ArrayType) Kind() string

type ArrayValue

type ArrayValue struct {
	// defaultValue
	Vals []Value
}

ArrayValue represents an array value

func BuildArrayValue

func BuildArrayValue(elVals []Value) *ArrayValue

func (*ArrayValue) Equals

func (thisVal *ArrayValue) Equals(other Value) bool

func (*ArrayValue) HasKindOf

func (aVal *ArrayValue) HasKindOf(ty string) bool

func (*ArrayValue) Kind

func (aVal *ArrayValue) Kind() string

type BaseEnv

type BaseEnv struct {
	BuiltIns                 *BuiltIns
	BuiltInsReportedMessages map[Severity][]string
	GithubClient             *gh.GithubClient
	Collector                collector.Collector
	Ctx                      context.Context
	DryRun                   bool
	EventPayload             interface{}
	RegisterMap              RegisterMap
	Report                   *Report
	Target                   codehost.Target
	Logger                   *logrus.Entry
}

func (*BaseEnv) GetBuiltIns

func (e *BaseEnv) GetBuiltIns() *BuiltIns

func (*BaseEnv) GetBuiltInsReportedMessages added in v3.2.0

func (e *BaseEnv) GetBuiltInsReportedMessages() map[Severity][]string

func (*BaseEnv) GetCollector

func (e *BaseEnv) GetCollector() collector.Collector

func (*BaseEnv) GetCtx

func (e *BaseEnv) GetCtx() context.Context

func (*BaseEnv) GetDryRun added in v3.1.0

func (e *BaseEnv) GetDryRun() bool

func (*BaseEnv) GetEventPayload

func (e *BaseEnv) GetEventPayload() interface{}

func (*BaseEnv) GetGithubClient added in v3.2.0

func (e *BaseEnv) GetGithubClient() *gh.GithubClient

func (*BaseEnv) GetLogger added in v3.21.0

func (e *BaseEnv) GetLogger() *logrus.Entry

func (*BaseEnv) GetRegisterMap

func (e *BaseEnv) GetRegisterMap() RegisterMap

func (*BaseEnv) GetReport

func (e *BaseEnv) GetReport() *Report

func (*BaseEnv) GetTarget added in v3.3.0

func (e *BaseEnv) GetTarget() codehost.Target

type BinaryOp

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

func BuildAndOp

func BuildAndOp(lhs Expr, rhs Expr) *BinaryOp

func BuildBinaryOp

func BuildBinaryOp(lhs Expr, op BinaryOperator, rhs Expr) *BinaryOp

func BuildEqOp

func BuildEqOp(lhs Expr, rhs Expr) *BinaryOp

func BuildGreaterEqThanOp

func BuildGreaterEqThanOp(lhs Expr, rhs Expr) *BinaryOp

func BuildGreaterThanOp

func BuildGreaterThanOp(lhs Expr, rhs Expr) *BinaryOp

func BuildLessEqThanOp

func BuildLessEqThanOp(lhs Expr, rhs Expr) *BinaryOp

func BuildLessThanOp

func BuildLessThanOp(lhs Expr, rhs Expr) *BinaryOp

func BuildNeqOp

func BuildNeqOp(lhs Expr, rhs Expr) *BinaryOp

func BuildOrOp

func BuildOrOp(lhs Expr, rhs Expr) *BinaryOp

func (*BinaryOp) Eval

func (b *BinaryOp) Eval(e Env) (Value, error)

func (*BinaryOp) Kind

func (b *BinaryOp) Kind() string

type BinaryOperator

type BinaryOperator interface {
	Eval(lhs, rhs Value) Value
	// contains filtered or unexported methods
}

type BoolConst

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

func BuildBoolConst

func BuildBoolConst(bVal bool) *BoolConst

func (*BoolConst) Eval

func (b *BoolConst) Eval(e Env) (Value, error)

func (*BoolConst) Kind

func (b *BoolConst) Kind() string

type BoolType

type BoolType struct{}

func BuildBoolType

func BuildBoolType() *BoolType

func (*BoolType) Kind

func (bTy *BoolType) Kind() string

type BoolValue

type BoolValue struct {
	// defaultValue
	Val bool
}

BoolValue represents a bool value

func BuildBoolValue

func BuildBoolValue(bval bool) *BoolValue

func BuildFalseValue

func BuildFalseValue() *BoolValue

func BuildTrueValue

func BuildTrueValue() *BoolValue

func (*BoolValue) Equals

func (thisVal *BoolValue) Equals(other Value) bool

func (*BoolValue) HasKindOf

func (bVal *BoolValue) HasKindOf(ty string) bool

func (*BoolValue) Kind

func (bVal *BoolValue) Kind() string

type BuiltInAction

type BuiltInAction struct {
	Type           Type
	Code           func(e Env, args []Value) error
	Disabled       bool
	SupportedKinds []handler.TargetEntityKind
}

type BuiltInFunction

type BuiltInFunction struct {
	Type           Type
	Code           func(e Env, args []Value) (Value, error)
	SupportedKinds []handler.TargetEntityKind
}

type BuiltIns

type BuiltIns struct {
	Functions map[string]*BuiltInFunction
	Actions   map[string]*BuiltInAction
	Services  map[string]interface{}
}

func MergeAladinoBuiltIns

func MergeAladinoBuiltIns(builtInsList ...*BuiltIns) *BuiltIns

func MockBuiltIns added in v3.1.0

func MockBuiltIns() *BuiltIns

type DynamicArrayType added in v3.20.0

type DynamicArrayType struct{}

func BuildDynamicArrayType added in v3.20.0

func BuildDynamicArrayType() *DynamicArrayType

func (*DynamicArrayType) Kind added in v3.20.0

func (dATy *DynamicArrayType) Kind() string

type Env

type Env interface {
	GetBuiltIns() *BuiltIns
	GetBuiltInsReportedMessages() map[Severity][]string
	GetGithubClient() *gh.GithubClient
	GetCollector() collector.Collector
	GetCtx() context.Context
	GetDryRun() bool
	GetEventPayload() interface{}
	GetRegisterMap() RegisterMap
	GetReport() *Report
	GetTarget() codehost.Target
	GetLogger() *logrus.Entry
}

func MockDefaultEnv added in v3.1.0

func MockDefaultEnv(
	t *testing.T,
	ghApiClientOptions []mock.MockBackendOption,
	ghGraphQLHandler func(http.ResponseWriter, *http.Request),
	builtIns *BuiltIns,
	eventPayload interface{},
) Env

MockDefaultEnv mocks an Aladino Env with default values.

func MockDefaultEnvWithTargetEntity added in v3.13.0

func MockDefaultEnvWithTargetEntity(
	t *testing.T,
	ghApiClientOptions []mock.MockBackendOption,
	ghGraphQLHandler func(http.ResponseWriter, *http.Request),
	builtIns *BuiltIns,
	eventPayload interface{},
	targetEntity *handler.TargetEntity,
) Env

MockDefaultEnvWithTargetEntity mocks an Aladino Env with default values and a custom TargetEntity.

func NewEvalEnv

func NewEvalEnv(
	ctx context.Context,
	logger *logrus.Entry,
	dryRun bool,
	githubClient *gh.GithubClient,
	collector collector.Collector,
	targetEntity *handler.TargetEntity,
	eventPayload interface{},
	builtIns *BuiltIns,
) (Env, error)

type EqOp

type EqOp struct{}

func (*EqOp) Eval

func (op *EqOp) Eval(lhs, rhs Value) Value

type ExecExpr

type ExecExpr interface {
	// contains filtered or unexported methods
}

func TypeCheckExec

func TypeCheckExec(env Env, expr Expr) (ExecExpr, error)

type Expr

type Expr interface {
	Kind() string

	Eval(Env) (Value, error)
	// contains filtered or unexported methods
}

func BuildCmpOp

func BuildCmpOp(lhs Expr, op string, rhs Expr) Expr

func BuildFilter

func BuildFilter(param string, condition Expr) (Expr, error)

func Parse

func Parse(input string) (Expr, error)

type FunctionCall

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

func BuildFunctionCall

func BuildFunctionCall(name *Variable, arguments []Expr) *FunctionCall

func (*FunctionCall) Eval

func (fc *FunctionCall) Eval(e Env) (Value, error)

func (*FunctionCall) Kind

func (fc *FunctionCall) Kind() string

type FunctionType

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

func BuildFunctionType

func BuildFunctionType(paramsTypes []Type, returnType Type) *FunctionType

func (*FunctionType) Kind

func (fTy *FunctionType) Kind() string

type FunctionValue

type FunctionValue struct {
	// defaultValue
	Fn func(args []Value) Value
}

FunctionValue represents a function value

func BuildFunctionValue

func BuildFunctionValue(fn func(args []Value) Value) *FunctionValue

func (*FunctionValue) Equals

func (thisVal *FunctionValue) Equals(other Value) bool

func (*FunctionValue) HasKindOf

func (fVal *FunctionValue) HasKindOf(ty string) bool

func (*FunctionValue) Kind

func (fVal *FunctionValue) Kind() string

type GreaterEqThanOp

type GreaterEqThanOp struct{}

func (*GreaterEqThanOp) Eval

func (op *GreaterEqThanOp) Eval(lhs, rhs Value) Value

type GreaterThanOp

type GreaterThanOp struct{}

func (*GreaterThanOp) Eval

func (op *GreaterThanOp) Eval(lhs, rhs Value) Value

type IntConst

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

func BuildIntConst

func BuildIntConst(val int) *IntConst

func BuildRelativeTimeConst

func BuildRelativeTimeConst(val string) *IntConst

func BuildTimeConst

func BuildTimeConst(val string) *IntConst

func (*IntConst) Eval

func (i *IntConst) Eval(e Env) (Value, error)

func (*IntConst) Kind

func (i *IntConst) Kind() string

type IntType

type IntType struct{}

func BuildIntType

func BuildIntType() *IntType

func (*IntType) Kind

func (iTy *IntType) Kind() string

type IntValue

type IntValue struct {
	Val int
}

IntValue represents an integer value

func BuildIntValue

func BuildIntValue(iVal int) *IntValue

func (*IntValue) Equals

func (thisVal *IntValue) Equals(other Value) bool

func (*IntValue) HasKindOf

func (iVal *IntValue) HasKindOf(ty string) bool

func (*IntValue) Kind

func (iVal *IntValue) Kind() string

type Interpreter

type Interpreter struct {
	Env Env
}

func (*Interpreter) EvalExpr

func (i *Interpreter) EvalExpr(kind, expr string) (bool, error)

func (*Interpreter) ExecProgram

func (i *Interpreter) ExecProgram(program *engine.Program) (engine.ExitStatus, error)

func (*Interpreter) ExecStatement

func (i *Interpreter) ExecStatement(statement *engine.Statement) error

func (*Interpreter) ProcessGroup

func (i *Interpreter) ProcessGroup(groupName string, kind engine.GroupKind, typeOf engine.GroupType, expr, paramExpr, whereExpr string) error

func (*Interpreter) ProcessLabel

func (i *Interpreter) ProcessLabel(id, name string) error

func (*Interpreter) ProcessRule

func (i *Interpreter) ProcessRule(name, spec string) error

func (*Interpreter) Report

func (i *Interpreter) Report(mode string, safeMode bool) error

func (*Interpreter) ReportMetrics added in v3.13.0

func (i *Interpreter) ReportMetrics() error

type JSONType added in v3.19.0

type JSONType struct{}

func BuildJSONType added in v3.19.0

func BuildJSONType() *JSONType

func (*JSONType) Kind added in v3.19.0

func (jTy *JSONType) Kind() string

type JSONValue added in v3.19.0

type JSONValue struct {
	Val interface{}
}

JSONValue represents a json value

func BuildJSONValue added in v3.19.0

func BuildJSONValue(value interface{}) *JSONValue

func (*JSONValue) Equals added in v3.19.0

func (jVal *JSONValue) Equals(other Value) bool

func (*JSONValue) HasKindOf added in v3.19.0

func (jVal *JSONValue) HasKindOf(ty string) bool

func (*JSONValue) Kind added in v3.19.0

func (jVal *JSONValue) Kind() string

type Lambda

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

func BuildLambda

func BuildLambda(parameters []Expr, body Expr) *Lambda

func (*Lambda) Eval

func (lambda *Lambda) Eval(e Env) (Value, error)

func (*Lambda) Kind

func (l *Lambda) Kind() string

type LessEqThanOp

type LessEqThanOp struct{}

func (*LessEqThanOp) Eval

func (op *LessEqThanOp) Eval(lhs, rhs Value) Value

type LessThanOp

type LessThanOp struct{}

func (*LessThanOp) Eval

func (op *LessThanOp) Eval(lhs, rhs Value) Value

type NeqOp

type NeqOp struct{}

func (*NeqOp) Eval

func (op *NeqOp) Eval(lhs, rhs Value) Value

type NotOp

type NotOp struct{}

func (*NotOp) Eval

func (op *NotOp) Eval(exprVal Value) Value

type OrOp

type OrOp struct{}

func (*OrOp) Eval

func (op *OrOp) Eval(lhs, rhs Value) Value

type RegisterMap

type RegisterMap map[string]Value

type Report

type Report struct {
	Actions []string
}

type Severity added in v3.2.0

type Severity int
const (
	SEVERITY_FATAL   Severity = 1
	SEVERITY_ERROR   Severity = 2
	SEVERITY_WARNING Severity = 3
	SEVERITY_INFO    Severity = 4
)

type StringConst

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

func BuildStringConst

func BuildStringConst(val string) *StringConst

func (*StringConst) Eval

func (c *StringConst) Eval(e Env) (Value, error)

func (*StringConst) Kind

func (c *StringConst) Kind() string

type StringType

type StringType struct{}

func BuildStringType

func BuildStringType() *StringType

func (*StringType) Kind

func (sTy *StringType) Kind() string

type StringValue

type StringValue struct {
	// defaultValue
	Val string
}

StringValue represents a string value

func BuildStringValue

func BuildStringValue(sval string) *StringValue

func (*StringValue) Equals

func (thisVal *StringValue) Equals(other Value) bool

func (*StringValue) HasKindOf

func (sVal *StringValue) HasKindOf(ty string) bool

func (*StringValue) Kind

func (sVal *StringValue) Kind() string

type TimeValue

type TimeValue struct {
	Val int
}

func BuildTimeValue

func BuildTimeValue(tVal int) *TimeValue

func (*TimeValue) Equals

func (thisVal *TimeValue) Equals(other Value) bool

func (*TimeValue) HasKindOf

func (tVal *TimeValue) HasKindOf(kind string) bool

func (*TimeValue) Kind

func (tVal *TimeValue) Kind() string

type Type

type Type interface {
	Kind() string
	// contains filtered or unexported methods
}

func TypeInference

func TypeInference(e Env, expr Expr) (Type, error)

type TypeEnv

type TypeEnv map[string]Type

func MockTypeEnv added in v3.1.0

func MockTypeEnv() TypeEnv

func NewTypeEnv

func NewTypeEnv(e Env) TypeEnv

type TypedExpr

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

func BuildTypedExpr

func BuildTypedExpr(expr Expr, typeOf Type) *TypedExpr

func (*TypedExpr) Eval

func (te *TypedExpr) Eval(e Env) (Value, error)

func (*TypedExpr) Kind

func (te *TypedExpr) Kind() string

type UnaryOp

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

func BuildNotOp

func BuildNotOp(expr Expr) *UnaryOp

func BuildUnaryOp

func BuildUnaryOp(op UnaryOperator, expr Expr) *UnaryOp

func (*UnaryOp) Eval

func (u *UnaryOp) Eval(e Env) (Value, error)

func (*UnaryOp) Kind

func (b *UnaryOp) Kind() string

type UnaryOperator

type UnaryOperator interface {
	Eval(exprValue Value) Value
	// contains filtered or unexported methods
}

type Value

type Value interface {
	HasKindOf(string) bool
	Kind() string
	Equals(Value) bool
}

func Eval

func Eval(env Env, expr Expr) (Value, error)

type Variable

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

func BuildVariable

func BuildVariable(ident string) *Variable

func (*Variable) Eval

func (v *Variable) Eval(e Env) (Value, error)

func (*Variable) Kind

func (v *Variable) Kind() string

Jump to

Keyboard shortcuts

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