Documentation
¶
Index ¶
- Constants
- Variables
- type ARType
- type ActivationRecord
- type Assign
- type Ast
- type BinOp
- type Block
- type BooleanConst
- type BuiltinTypeSymbol
- type CallStack
- type Compound
- type Dict
- type Error
- type ErrorCode
- type ErrorType
- type Flow
- type If
- type Interpreter
- func (i *Interpreter) Interpret() (float64, error)
- func (i *Interpreter) SetClient(midClient pb.MiddleClient)
- func (i *Interpreter) Stdout() string
- func (i *Interpreter) Visit(node Ast) interface{}
- func (i *Interpreter) VisitAssign(node *Assign) float64
- func (i *Interpreter) VisitBinOp(node *BinOp) float64
- func (i *Interpreter) VisitBlock(node *Block) float64
- func (i *Interpreter) VisitBooleanConst(node *BooleanConst) bool
- func (i *Interpreter) VisitCompound(node *Compound) float64
- func (i *Interpreter) VisitDict(node *Dict) map[string]interface{}
- func (i *Interpreter) VisitFlow(node *Flow) float64
- func (i *Interpreter) VisitIf(node *If) interface{}
- func (i *Interpreter) VisitList(node *List) []interface{}
- func (i *Interpreter) VisitLogical(node *Logical) bool
- func (i *Interpreter) VisitMessageConst(node *MessageConst) interface{}
- func (i *Interpreter) VisitNoOp(_ *NoOp) float64
- func (i *Interpreter) VisitNode(node *Node) map[string]interface{}
- func (i *Interpreter) VisitNodeConst(node *NodeConst) interface{}
- func (i *Interpreter) VisitNumberConst(node *NumberConst) float64
- func (i *Interpreter) VisitPrint(node *Print) interface{}
- func (i *Interpreter) VisitProgram(node *Program) float64
- func (i *Interpreter) VisitStringConst(node *StringConst) string
- func (i *Interpreter) VisitType(_ *Type) float64
- func (i *Interpreter) VisitUnaryOp(node *UnaryOp) float64
- func (i *Interpreter) VisitVar(node *Var) interface{}
- func (i *Interpreter) VisitVarDecl(_ *VarDecl) float64
- func (i *Interpreter) VisitWhile(node *While) float64
- func (i *Interpreter) VisitWorkflow(node *Workflow) float64
- type Lexer
- func (l *Lexer) Advance()
- func (l *Lexer) GetNextToken() (*Token, error)
- func (l *Lexer) Id() (*Token, error)
- func (l *Lexer) Message() (*Token, error)
- func (l *Lexer) Node() (*Token, error)
- func (l *Lexer) Number() (*Token, error)
- func (l *Lexer) Peek() rune
- func (l *Lexer) SkipComment()
- func (l *Lexer) SkipWhitespace()
- func (l *Lexer) String() (*Token, error)
- type List
- type Logical
- type MessageConst
- type NoOp
- type Node
- type NodeConst
- type NodeSymbol
- type NumberConst
- type Param
- type Parser
- func (p *Parser) AssignmentStatement() (Ast, error)
- func (p *Parser) Block() (Ast, error)
- func (p *Parser) Comparison() (Ast, error)
- func (p *Parser) CompoundStatement() (Ast, error)
- func (p *Parser) Declarations() ([][]Ast, error)
- func (p *Parser) Dict() (Ast, error)
- func (p *Parser) Eat(tokenType TokenType) (err error)
- func (p *Parser) Empty() (Ast, error)
- func (p *Parser) Equality() (Ast, error)
- func (p *Parser) Expr() (Ast, error)
- func (p *Parser) Expression() (Ast, error)
- func (p *Parser) Factor() (Ast, error)
- func (p *Parser) FlowStatement() (Ast, error)
- func (p *Parser) FormalParameters() ([]Ast, error)
- func (p *Parser) IfStatement() (Ast, error)
- func (p *Parser) List() (Ast, error)
- func (p *Parser) LogicAnd() (Ast, error)
- func (p *Parser) LogicOr() (Ast, error)
- func (p *Parser) Node() (map[string]Ast, error)
- func (p *Parser) Parse() (Ast, error)
- func (p *Parser) PrintStatement() (Ast, error)
- func (p *Parser) Program() (Ast, error)
- func (p *Parser) Statement() (Ast, error)
- func (p *Parser) StatementList() ([]Ast, error)
- func (p *Parser) Term() (Ast, error)
- func (p *Parser) TypeSpec() (Ast, error)
- func (p *Parser) Variable() (Ast, error)
- func (p *Parser) VariableDeclaration() ([]Ast, error)
- func (p *Parser) WhileStatement() (Ast, error)
- func (p *Parser) Workflow() (map[string]Ast, error)
- type Print
- type Program
- type ScopedSymbolTable
- type SemanticAnalyzer
- func (b *SemanticAnalyzer) Visit(node Ast) error
- func (b *SemanticAnalyzer) VisitAssign(node *Assign) error
- func (b *SemanticAnalyzer) VisitBinOp(node *BinOp) error
- func (b *SemanticAnalyzer) VisitBlock(node *Block) error
- func (b *SemanticAnalyzer) VisitBooleanConst(_ *BooleanConst) error
- func (b *SemanticAnalyzer) VisitCompound(node *Compound) error
- func (b *SemanticAnalyzer) VisitDict(node *Dict) error
- func (b *SemanticAnalyzer) VisitFlow(node *Flow) error
- func (b *SemanticAnalyzer) VisitIf(node *If) error
- func (b *SemanticAnalyzer) VisitList(node *List) error
- func (b *SemanticAnalyzer) VisitLogical(node *Logical) error
- func (b *SemanticAnalyzer) VisitMessageConst(_ *MessageConst) error
- func (b *SemanticAnalyzer) VisitNoOp(_ *NoOp) error
- func (b *SemanticAnalyzer) VisitNode(node *Node) error
- func (b *SemanticAnalyzer) VisitNodeConst(_ *NodeConst) error
- func (b *SemanticAnalyzer) VisitNumberConst(_ *NumberConst) error
- func (b *SemanticAnalyzer) VisitPrint(node *Print) error
- func (b *SemanticAnalyzer) VisitProgram(node *Program) error
- func (b *SemanticAnalyzer) VisitStringConst(_ *StringConst) error
- func (b *SemanticAnalyzer) VisitType(_ *Type) error
- func (b *SemanticAnalyzer) VisitUnaryOp(_ *UnaryOp) error
- func (b *SemanticAnalyzer) VisitVar(node *Var) error
- func (b *SemanticAnalyzer) VisitVarDecl(node *VarDecl) error
- func (b *SemanticAnalyzer) VisitWhile(node *While) error
- func (b *SemanticAnalyzer) VisitWorkflow(node *Workflow) error
- type StringConst
- type Symbol
- type Token
- type TokenType
- type Type
- type UnaryOp
- type Var
- type VarDecl
- type VarSymbol
- type While
- type Workflow
- type WorkflowSymbol
Constants ¶
View Source
const ( TokenPlus = "+" TokenMinus = "-" TokenMultiply = "*" TokenFloatDiv = "/" TokenLParen = "(" TokenRParen = ")" TokenLSquare = "[" TokenRSquare = "]" TokenLCurly = "{" TokenRCurly = "}" TokenSemi = ";" TokenDot = "." TokenColon = ":" TokenComma = "," TokenWorkflow = "WORKFLOW" TokenNode = "NODE" TokenWith = "WITH" TokenSecret = "SECRET" TokenInteger = "INTEGER" TokenFloat = "FLOAT" TokenString = "STRING" TokenBoolean = "BOOLEAN" TokenList = "LIST" TokenDict = "DICT" TokenMessage = "MESSAGE" TokenIntegerDiv = "DIV" TokenVar = "VAR" TokenEnd = "END" TokenPrint = "PRINT" TokenID = "ID" TokenIntegerConst = "INTEGER_CONST" TokenFloatConst = "FLOAT_CONST" TokenStringConst = "STRING_CONST" TokenMessageConst = "MESSAGE_CONST" TokenNodeConst = "NODE_CONST" TokenAssign = ":=" TokenEOF = "EOF" TokenIf = "IF" TokenElse = "ELSE" TokenWhile = "WHILE" TokenOr = "OR" TokenAnd = "AND" TokenTrue = "TRUE" TokenFalse = "FALSE" TokenEqual = "==" TokenNotEqual = "!=" TokenGreater = ">" TokenGreaterEqual = ">=" TokenLess = "<" TokenLessEqual = "<=" TokenAt = "@" TokenFlow = "<-" TokenHash = "#" )
Variables ¶
View Source
var Debug bool
View Source
var ReservedKeywords = map[string]Token{ "WORKFLOW": {Type: TokenWorkflow, Value: TokenWorkflow}, "NODE": {Type: TokenNode, Value: TokenNode}, "WITH": {Type: TokenWith, Value: TokenWith}, "SECRET": {Type: TokenSecret, Value: TokenSecret}, "VAR": {Type: TokenVar, Value: TokenVar}, "DIV": {Type: TokenIntegerDiv, Value: TokenIntegerDiv}, "INT": {Type: TokenInteger, Value: TokenInteger}, "FLOAT": {Type: TokenFloat, Value: TokenFloat}, "STRING": {Type: TokenString, Value: TokenString}, "BOOL": {Type: TokenBoolean, Value: TokenBoolean}, "END": {Type: TokenEnd, Value: TokenEnd}, "IF": {Type: TokenIf, Value: TokenIf}, "ELSE": {Type: TokenElse, Value: TokenElse}, "WHILE": {Type: TokenWhile, Value: TokenWhile}, "OR": {Type: TokenOr, Value: TokenOr}, "AND": {Type: TokenAnd, Value: TokenAnd}, "TRUE": {Type: TokenTrue, Value: true}, "FALSE": {Type: TokenFalse, Value: false}, "PRINT": {Type: TokenPrint, Value: TokenPrint}, "LIST": {Type: TokenList, Value: TokenList}, "DICT": {Type: TokenDict, Value: TokenDict}, "MESSAGE": {Type: TokenMessage, Value: TokenMessage}, }
Functions ¶
This section is empty.
Types ¶
type ActivationRecord ¶
type ActivationRecord struct {
Name string
Type ARType
NestingLevel int
Members map[string]interface{}
ReturnValue interface{}
}
func NewActivationRecord ¶
func NewActivationRecord(name string, t ARType, nestingLevel int) *ActivationRecord
func (*ActivationRecord) Get ¶
func (r *ActivationRecord) Get(key string) interface{}
func (*ActivationRecord) Set ¶
func (r *ActivationRecord) Set(key string, value interface{})
func (*ActivationRecord) String ¶
func (r *ActivationRecord) String() string
type BooleanConst ¶
func NewBooleanConst ¶
func NewBooleanConst(token *Token) *BooleanConst
type BuiltinTypeSymbol ¶
func NewBuiltinTypeSymbol ¶
func NewBuiltinTypeSymbol(name string) *BuiltinTypeSymbol
func (*BuiltinTypeSymbol) String ¶
func (s *BuiltinTypeSymbol) String() string
type CallStack ¶
type CallStack struct {
// contains filtered or unexported fields
}
func NewCallStack ¶
func NewCallStack() *CallStack
func (*CallStack) Peek ¶
func (s *CallStack) Peek() *ActivationRecord
func (*CallStack) Pop ¶
func (s *CallStack) Pop() *ActivationRecord
func (*CallStack) Push ¶
func (s *CallStack) Push(ar *ActivationRecord)
type Compound ¶
type Compound struct {
Children []Ast
}
func NewCompound ¶
func NewCompound() *Compound
type Interpreter ¶
type Interpreter struct {
// contains filtered or unexported fields
}
func NewInterpreter ¶
func NewInterpreter(tree Ast) *Interpreter
func (*Interpreter) Interpret ¶
func (i *Interpreter) Interpret() (float64, error)
func (*Interpreter) SetClient ¶
func (i *Interpreter) SetClient(midClient pb.MiddleClient)
func (*Interpreter) Stdout ¶
func (i *Interpreter) Stdout() string
func (*Interpreter) Visit ¶
func (i *Interpreter) Visit(node Ast) interface{}
func (*Interpreter) VisitAssign ¶
func (i *Interpreter) VisitAssign(node *Assign) float64
func (*Interpreter) VisitBinOp ¶
func (i *Interpreter) VisitBinOp(node *BinOp) float64
func (*Interpreter) VisitBlock ¶
func (i *Interpreter) VisitBlock(node *Block) float64
func (*Interpreter) VisitBooleanConst ¶
func (i *Interpreter) VisitBooleanConst(node *BooleanConst) bool
func (*Interpreter) VisitCompound ¶
func (i *Interpreter) VisitCompound(node *Compound) float64
func (*Interpreter) VisitDict ¶
func (i *Interpreter) VisitDict(node *Dict) map[string]interface{}
func (*Interpreter) VisitFlow ¶
func (i *Interpreter) VisitFlow(node *Flow) float64
func (*Interpreter) VisitIf ¶
func (i *Interpreter) VisitIf(node *If) interface{}
func (*Interpreter) VisitList ¶
func (i *Interpreter) VisitList(node *List) []interface{}
func (*Interpreter) VisitLogical ¶
func (i *Interpreter) VisitLogical(node *Logical) bool
func (*Interpreter) VisitMessageConst ¶
func (i *Interpreter) VisitMessageConst(node *MessageConst) interface{}
func (*Interpreter) VisitNoOp ¶
func (i *Interpreter) VisitNoOp(_ *NoOp) float64
func (*Interpreter) VisitNode ¶
func (i *Interpreter) VisitNode(node *Node) map[string]interface{}
func (*Interpreter) VisitNodeConst ¶
func (i *Interpreter) VisitNodeConst(node *NodeConst) interface{}
func (*Interpreter) VisitNumberConst ¶
func (i *Interpreter) VisitNumberConst(node *NumberConst) float64
func (*Interpreter) VisitPrint ¶
func (i *Interpreter) VisitPrint(node *Print) interface{}
func (*Interpreter) VisitProgram ¶
func (i *Interpreter) VisitProgram(node *Program) float64
func (*Interpreter) VisitStringConst ¶
func (i *Interpreter) VisitStringConst(node *StringConst) string
func (*Interpreter) VisitType ¶
func (i *Interpreter) VisitType(_ *Type) float64
func (*Interpreter) VisitUnaryOp ¶
func (i *Interpreter) VisitUnaryOp(node *UnaryOp) float64
func (*Interpreter) VisitVar ¶
func (i *Interpreter) VisitVar(node *Var) interface{}
func (*Interpreter) VisitVarDecl ¶
func (i *Interpreter) VisitVarDecl(_ *VarDecl) float64
func (*Interpreter) VisitWhile ¶
func (i *Interpreter) VisitWhile(node *While) float64
func (*Interpreter) VisitWorkflow ¶
func (i *Interpreter) VisitWorkflow(node *Workflow) float64
type Lexer ¶
func (*Lexer) GetNextToken ¶
func (*Lexer) SkipComment ¶
func (l *Lexer) SkipComment()
func (*Lexer) SkipWhitespace ¶
func (l *Lexer) SkipWhitespace()
type MessageConst ¶
type MessageConst struct {
Token *Token
Value interface{}
}
func NewMessageConst ¶
func NewMessageConst(token *Token) *MessageConst
type Node ¶
type NodeSymbol ¶
func NewNodeSymbol ¶
func NewNodeSymbol(name string) *NodeSymbol
func (*NodeSymbol) String ¶
func (s *NodeSymbol) String() string
type NumberConst ¶
func NewNumberConst ¶
func NewNumberConst(token *Token) *NumberConst
type Parser ¶
func (*Parser) AssignmentStatement ¶
func (*Parser) Comparison ¶
func (*Parser) CompoundStatement ¶
func (*Parser) Declarations ¶
func (*Parser) Expression ¶
func (*Parser) FlowStatement ¶
func (*Parser) FormalParameters ¶
func (*Parser) IfStatement ¶
func (*Parser) PrintStatement ¶
func (*Parser) StatementList ¶
func (*Parser) VariableDeclaration ¶
func (*Parser) WhileStatement ¶
type ScopedSymbolTable ¶
type ScopedSymbolTable struct {
ScopeName string
ScopeLevel int
EnclosingScope *ScopedSymbolTable
// contains filtered or unexported fields
}
func NewScopedSymbolTable ¶
func NewScopedSymbolTable(scopeName string, scopeLevel int, enclosingScope *ScopedSymbolTable) *ScopedSymbolTable
func (*ScopedSymbolTable) Insert ¶
func (t *ScopedSymbolTable) Insert(symbol Symbol)
func (*ScopedSymbolTable) Lookup ¶
func (t *ScopedSymbolTable) Lookup(name string, currentScopeOnly bool) Symbol
func (*ScopedSymbolTable) String ¶
func (t *ScopedSymbolTable) String() string
type SemanticAnalyzer ¶
type SemanticAnalyzer struct {
CurrentScope *ScopedSymbolTable
}
func NewSemanticAnalyzer ¶
func NewSemanticAnalyzer() *SemanticAnalyzer
func (*SemanticAnalyzer) Visit ¶
func (b *SemanticAnalyzer) Visit(node Ast) error
func (*SemanticAnalyzer) VisitAssign ¶
func (b *SemanticAnalyzer) VisitAssign(node *Assign) error
func (*SemanticAnalyzer) VisitBinOp ¶
func (b *SemanticAnalyzer) VisitBinOp(node *BinOp) error
func (*SemanticAnalyzer) VisitBlock ¶
func (b *SemanticAnalyzer) VisitBlock(node *Block) error
func (*SemanticAnalyzer) VisitBooleanConst ¶
func (b *SemanticAnalyzer) VisitBooleanConst(_ *BooleanConst) error
func (*SemanticAnalyzer) VisitCompound ¶
func (b *SemanticAnalyzer) VisitCompound(node *Compound) error
func (*SemanticAnalyzer) VisitDict ¶
func (b *SemanticAnalyzer) VisitDict(node *Dict) error
func (*SemanticAnalyzer) VisitFlow ¶
func (b *SemanticAnalyzer) VisitFlow(node *Flow) error
func (*SemanticAnalyzer) VisitIf ¶
func (b *SemanticAnalyzer) VisitIf(node *If) error
func (*SemanticAnalyzer) VisitList ¶
func (b *SemanticAnalyzer) VisitList(node *List) error
func (*SemanticAnalyzer) VisitLogical ¶
func (b *SemanticAnalyzer) VisitLogical(node *Logical) error
func (*SemanticAnalyzer) VisitMessageConst ¶
func (b *SemanticAnalyzer) VisitMessageConst(_ *MessageConst) error
func (*SemanticAnalyzer) VisitNoOp ¶
func (b *SemanticAnalyzer) VisitNoOp(_ *NoOp) error
func (*SemanticAnalyzer) VisitNode ¶
func (b *SemanticAnalyzer) VisitNode(node *Node) error
func (*SemanticAnalyzer) VisitNodeConst ¶
func (b *SemanticAnalyzer) VisitNodeConst(_ *NodeConst) error
func (*SemanticAnalyzer) VisitNumberConst ¶
func (b *SemanticAnalyzer) VisitNumberConst(_ *NumberConst) error
func (*SemanticAnalyzer) VisitPrint ¶
func (b *SemanticAnalyzer) VisitPrint(node *Print) error
func (*SemanticAnalyzer) VisitProgram ¶
func (b *SemanticAnalyzer) VisitProgram(node *Program) error
func (*SemanticAnalyzer) VisitStringConst ¶
func (b *SemanticAnalyzer) VisitStringConst(_ *StringConst) error
func (*SemanticAnalyzer) VisitType ¶
func (b *SemanticAnalyzer) VisitType(_ *Type) error
func (*SemanticAnalyzer) VisitUnaryOp ¶
func (b *SemanticAnalyzer) VisitUnaryOp(_ *UnaryOp) error
func (*SemanticAnalyzer) VisitVar ¶
func (b *SemanticAnalyzer) VisitVar(node *Var) error
func (*SemanticAnalyzer) VisitVarDecl ¶
func (b *SemanticAnalyzer) VisitVarDecl(node *VarDecl) error
func (*SemanticAnalyzer) VisitWhile ¶
func (b *SemanticAnalyzer) VisitWhile(node *While) error
func (*SemanticAnalyzer) VisitWorkflow ¶
func (b *SemanticAnalyzer) VisitWorkflow(node *Workflow) error
type StringConst ¶
func NewStringConst ¶
func NewStringConst(token *Token) *StringConst
type UnaryOp ¶
func NewUnaryOp ¶
type VarDecl ¶
func NewVarDecl ¶
type VarSymbol ¶
func NewVarSymbol ¶
type Workflow ¶
func NewWorkflow ¶
type WorkflowSymbol ¶
func NewWorkflowSymbol ¶
func NewWorkflowSymbol(name string) *WorkflowSymbol
func (*WorkflowSymbol) String ¶
func (s *WorkflowSymbol) String() string
Source Files
¶
Click to show internal directories.
Click to hide internal directories.