action

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TokenPlus           = "+"
	TokenMinus          = "-"
	TokenMultiply       = "*"
	TokenFloatDiv       = "/"
	TokenLParen         = "("
	TokenRParen         = ")"
	TokenLSquare        = "["
	TokenRSquare        = "]"
	TokenLCurly         = "{"
	TokenRCurly         = "}"
	TokenSemi           = ";"
	TokenDot            = "."
	TokenColon          = ":"
	TokenComma          = ","
	TokenID             = "ID"
	TokenIntegerConst   = "INTEGER_CONST" // #nosec
	TokenFloatConst     = "FLOAT_CONST"
	TokenStringConst    = "STRING_CONST"
	TokenMessageConst   = "MESSAGE_CONST"
	TokenTrue           = "TRUE"
	TokenFalse          = "FALSE"
	TokenCarriageReturn = "\n"
	TokenEOF            = "EOF"
)

Variables

View Source
var Debug bool
View Source
var ReservedKeywords = map[string]Token{
	"TRUE":  {Type: TokenTrue, Value: true},
	"FALSE": {Type: TokenFalse, Value: false},
}

Functions

This section is empty.

Types

type Ast

type Ast interface{}

type BooleanConst

type BooleanConst struct {
	Token *Token
	Value bool
}

func NewBooleanConst

func NewBooleanConst(token *Token) *BooleanConst

type BuiltinTypeSymbol added in v0.0.18

type BuiltinTypeSymbol struct {
	Name       string
	Type       Symbol
	ScopeLevel int
}

func NewBuiltinTypeSymbol added in v0.0.18

func NewBuiltinTypeSymbol(name string) *BuiltinTypeSymbol

func (*BuiltinTypeSymbol) String added in v0.0.18

func (s *BuiltinTypeSymbol) String() string

type CronSymbol added in v0.0.18

type CronSymbol struct {
	When string
}

func NewCronSymbol added in v0.0.18

func NewCronSymbol(when string) *CronSymbol

func (*CronSymbol) String added in v0.0.18

func (s *CronSymbol) String() string

type Error

type Error struct {
	ErrorCode ErrorCode
	Token     *Token
	Message   string
	Type      ErrorType
}

func (Error) Error

func (e Error) Error() string

type ErrorCode

type ErrorCode string
const (
	UnexpectedToken ErrorCode = "Unexpected token"
	IdNotFound      ErrorCode = "Identifier not found"
	RepeatOpcode    ErrorCode = "Repeat opcode"
	ParameterType   ErrorCode = "Parameter type error"
)

type ErrorType

type ErrorType string
const (
	LexerErrorType    ErrorType = "LexerError"
	ParserErrorType   ErrorType = "ParserError"
	SemanticErrorType ErrorType = "SemanticError"
)

type FloatConst

type FloatConst struct {
	Token *Token
	Value float64
}

func NewFloatConst

func NewFloatConst(token *Token) *FloatConst

type IntegerConst

type IntegerConst struct {
	Token *Token
	Value int64
}

func NewIntegerConst

func NewIntegerConst(token *Token) *IntegerConst

type Interpreter

type Interpreter struct {
	Comp *inside.Component
	// contains filtered or unexported fields
}

func NewInterpreter

func NewInterpreter(ctx context.Context, tree Ast) *Interpreter

func (*Interpreter) Interpret

func (i *Interpreter) Interpret() (interface{}, error)

func (*Interpreter) SetComponent added in v0.0.25

func (i *Interpreter) SetComponent(bus event.Bus, rdb *redis.Client, message pb.MessageSvcClient, middle pb.MiddleSvcClient, logger log.Logger)

func (*Interpreter) Stdout

func (i *Interpreter) Stdout() string

func (*Interpreter) Visit

func (i *Interpreter) Visit(node Ast) interface{}

func (*Interpreter) VisitBooleanConst

func (i *Interpreter) VisitBooleanConst(node *BooleanConst) bool

func (*Interpreter) VisitFloatConst

func (i *Interpreter) VisitFloatConst(node *FloatConst) float64

func (*Interpreter) VisitIntegerConst

func (i *Interpreter) VisitIntegerConst(node *IntegerConst) int64

func (*Interpreter) VisitMessageConst

func (i *Interpreter) VisitMessageConst(node *MessageConst) interface{}

func (*Interpreter) VisitNoOp

func (i *Interpreter) VisitNoOp(_ *NoOp) interface{}

func (*Interpreter) VisitOpcode

func (i *Interpreter) VisitOpcode(node *Opcode) float64

func (*Interpreter) VisitProgram

func (i *Interpreter) VisitProgram(node *Program) interface{}

func (*Interpreter) VisitStringConst

func (i *Interpreter) VisitStringConst(node *StringConst) string

func (*Interpreter) VisitVar

func (i *Interpreter) VisitVar(_ *Var) interface{}

type Lexer

type Lexer struct {
	Text        []rune
	Pos         int
	CurrentChar rune
	LineNo      int
	Column      int
}

func NewLexer

func NewLexer(text []rune) *Lexer

func (*Lexer) Advance

func (l *Lexer) Advance()

func (*Lexer) CarriageReturn

func (l *Lexer) CarriageReturn() (*Token, error)

func (*Lexer) GetNextToken

func (l *Lexer) GetNextToken() (*Token, error)

func (*Lexer) Id

func (l *Lexer) Id() (*Token, error)

func (*Lexer) Message

func (l *Lexer) Message() (*Token, error)

func (*Lexer) Number

func (l *Lexer) Number() (*Token, error)

func (*Lexer) Peek

func (l *Lexer) Peek() rune

func (*Lexer) SkipComment

func (l *Lexer) SkipComment()

func (*Lexer) SkipWhitespace

func (l *Lexer) SkipWhitespace()

func (*Lexer) String

func (l *Lexer) String() (*Token, error)

type MessageConst

type MessageConst struct {
	Token *Token
	Value interface{}
}

func NewMessageConst

func NewMessageConst(token *Token) *MessageConst

type NoOp

type NoOp struct{}

func NewNoOp

func NewNoOp() *NoOp

type Opcode

type Opcode struct {
	ID          Ast
	Expressions []Ast
	Token       *Token
}

func NewOpcode

func NewOpcode(ID Ast, expressions []Ast, token *Token) *Opcode

type OpcodeSymbol added in v0.0.18

type OpcodeSymbol struct {
	Name       string
	ScopeLevel int
}

func NewOpcodeSymbol added in v0.0.18

func NewOpcodeSymbol(name string) *OpcodeSymbol

func (*OpcodeSymbol) String added in v0.0.18

func (s *OpcodeSymbol) String() string

type Parser

type Parser struct {
	Lexer        *Lexer
	CurrentToken *Token
}

func NewParser

func NewParser(lexer *Lexer) (*Parser, error)

func (*Parser) Eat

func (p *Parser) Eat(tokenType TokenType) (err error)

func (*Parser) Empty

func (p *Parser) Empty() (Ast, error)

func (*Parser) Expression

func (p *Parser) Expression() ([]Ast, error)

func (*Parser) Factor

func (p *Parser) Factor() (Ast, error)

func (*Parser) OpcodeStatement

func (p *Parser) OpcodeStatement() (Ast, error)

func (*Parser) Parse

func (p *Parser) Parse() (Ast, error)

func (*Parser) Program

func (p *Parser) Program() (Ast, error)

func (*Parser) Statement

func (p *Parser) Statement() (Ast, error)

func (*Parser) StatementList

func (p *Parser) StatementList() ([]Ast, error)

func (*Parser) Variable

func (p *Parser) Variable() (Ast, error)

type Program

type Program struct {
	Name       string
	Statements []Ast
}

func NewProgram

func NewProgram(name string, statements []Ast) *Program

type ScopedSymbolTable added in v0.0.18

type ScopedSymbolTable struct {
	ScopeName      string
	ScopeLevel     int
	EnclosingScope *ScopedSymbolTable
	// contains filtered or unexported fields
}

func NewScopedSymbolTable added in v0.0.18

func NewScopedSymbolTable(scopeName string, scopeLevel int, enclosingScope *ScopedSymbolTable) *ScopedSymbolTable

func (*ScopedSymbolTable) Insert added in v0.0.18

func (t *ScopedSymbolTable) Insert(symbol Symbol)

func (*ScopedSymbolTable) Lookup added in v0.0.18

func (t *ScopedSymbolTable) Lookup(name string, currentScopeOnly bool) Symbol

func (*ScopedSymbolTable) String added in v0.0.18

func (t *ScopedSymbolTable) String() string

type SemanticAnalyzer added in v0.0.18

type SemanticAnalyzer struct {
	CurrentScope *ScopedSymbolTable
	Webhook      *WebhookSymbol
	Cron         *CronSymbol
}

func NewSemanticAnalyzer added in v0.0.18

func NewSemanticAnalyzer() *SemanticAnalyzer

func (*SemanticAnalyzer) Visit added in v0.0.18

func (b *SemanticAnalyzer) Visit(node Ast) error

func (*SemanticAnalyzer) VisitBooleanConst added in v0.0.18

func (b *SemanticAnalyzer) VisitBooleanConst(_ *BooleanConst) error

func (*SemanticAnalyzer) VisitIntegerConst added in v0.0.18

func (b *SemanticAnalyzer) VisitIntegerConst(_ *IntegerConst) error

func (*SemanticAnalyzer) VisitMessageConst added in v0.0.18

func (b *SemanticAnalyzer) VisitMessageConst(_ *MessageConst) error

func (*SemanticAnalyzer) VisitNoOp added in v0.0.18

func (b *SemanticAnalyzer) VisitNoOp(_ *NoOp) error

func (*SemanticAnalyzer) VisitOpcode added in v0.0.18

func (b *SemanticAnalyzer) VisitOpcode(node *Opcode) error

func (*SemanticAnalyzer) VisitProgram added in v0.0.18

func (b *SemanticAnalyzer) VisitProgram(node *Program) error

func (*SemanticAnalyzer) VisitStringConst added in v0.0.18

func (b *SemanticAnalyzer) VisitStringConst(_ *StringConst) error

func (*SemanticAnalyzer) VisitVar added in v0.0.18

func (b *SemanticAnalyzer) VisitVar(node *Var) error

type StringConst

type StringConst struct {
	Token *Token
	Value string
}

func NewStringConst

func NewStringConst(token *Token) *StringConst

type Symbol added in v0.0.18

type Symbol interface{}

type Token

type Token struct {
	Type   TokenType
	Value  interface{}
	LineNo int
	Column int
}

func (*Token) String

func (t *Token) String() string

type TokenType

type TokenType string

type Var

type Var struct {
	Token *Token
	Value interface{}
}

func NewVar

func NewVar(token *Token) *Var

type WebhookSymbol added in v0.0.18

type WebhookSymbol struct {
	Flag   string
	Secret string
}

func NewWebhookSymbol added in v0.0.18

func NewWebhookSymbol(flag string, secret string) *WebhookSymbol

func (*WebhookSymbol) String added in v0.0.18

func (s *WebhookSymbol) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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