Documentation
¶
Index ¶
- Variables
- type BlockScope
- func (s BlockScope) AddSymbol(symbol Symbol)
- func (s BlockScope) ContainsSymbol(symbol Symbol) bool
- func (s BlockScope) GetCtx() antlr.ParserRuleContext
- func (s BlockScope) GetFunction(name string, paramTypes []Type) *Func
- func (s BlockScope) GetSymbols() []Symbol
- func (s BlockScope) GetVariable(name string) *Variable
- func (s BlockScope) SetCtx(ctx antlr.ParserRuleContext)
- func (s BlockScope) String() string
- type Func
- func (s Func) AddSymbol(symbol Symbol)
- func (f *Func) AppendParameter(v *Variable)
- func (s Func) ContainsSymbol(symbol Symbol) bool
- func (s Func) GetCtx() antlr.ParserRuleContext
- func (f *Func) GetEncloseScope() Scope
- func (s Func) GetFunction(name string, paramTypes []Type) *Func
- func (f *Func) GetName() string
- func (f *Func) GetParameterType() []Type
- func (f *Func) GetReturnType() Type
- func (s Func) GetSymbols() []Symbol
- func (s Func) GetVariable(name string) *Variable
- func (f *Func) IsType(t Type) bool
- func (f *Func) MatchParameterTypes(paramTypes []Type) bool
- func (s Func) SetCtx(ctx antlr.ParserRuleContext)
- func (f *Func) SetEncloseScope(scope Scope)
- func (f *Func) SetName(name string)
- func (f *Func) SetReturnType(t Type)
- func (s Func) String() string
- type FuncType
- type PrimitiveType
- type Scope
- type Symbol
- type Type
- type Variable
- type VoidType
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Int = &PrimitiveType{name: "int"} String = &PrimitiveType{name: "string"} Float = &PrimitiveType{name: "float"} Bool = &PrimitiveType{name: "bool"} Void = &VoidType{} )
Functions ¶
This section is empty.
Types ¶
type BlockScope ¶
type BlockScope struct {
// contains filtered or unexported fields
}
func (BlockScope) ContainsSymbol ¶
func (BlockScope) GetCtx ¶
func (s BlockScope) GetCtx() antlr.ParserRuleContext
func (BlockScope) GetFunction ¶
func (BlockScope) GetSymbols ¶
func (s BlockScope) GetSymbols() []Symbol
func (BlockScope) GetVariable ¶
func (BlockScope) SetCtx ¶
func (s BlockScope) SetCtx(ctx antlr.ParserRuleContext)
type Func ¶
type Func struct {
// contains filtered or unexported fields
}
func (*Func) AppendParameter ¶
func (Func) ContainsSymbol ¶
func (Func) GetCtx ¶
func (s Func) GetCtx() antlr.ParserRuleContext
func (*Func) GetEncloseScope ¶
func (Func) GetFunction ¶
func (*Func) GetReturnType ¶
func (Func) GetSymbols ¶
func (s Func) GetSymbols() []Symbol
func (Func) GetVariable ¶
func (*Func) MatchParameterTypes ¶
MatchParameterTypes 通过参数类型匹配函数是否一致
func (Func) SetCtx ¶
func (s Func) SetCtx(ctx antlr.ParserRuleContext)
func (*Func) SetEncloseScope ¶
func (*Func) SetReturnType ¶
type PrimitiveType ¶
type PrimitiveType struct {
// contains filtered or unexported fields
}
func (*PrimitiveType) GetEncloseScope ¶
func (b *PrimitiveType) GetEncloseScope() Scope
func (*PrimitiveType) GetName ¶
func (b *PrimitiveType) GetName() string
func (*PrimitiveType) IsType ¶
func (b *PrimitiveType) IsType(t Type) bool
func (*PrimitiveType) String ¶
func (b *PrimitiveType) String() string
type Scope ¶
type Scope interface { Symbol AddSymbol(symbol Symbol) ContainsSymbol(symbol Symbol) bool GetSymbols() []Symbol SetCtx(ctx antlr.ParserRuleContext) GetVariable(name string) *Variable GetFunction(name string, paramTypes []Type) *Func String() string }
func NewBlockScope ¶
func NewBlockScope(ctx antlr.ParserRuleContext, name string, s Scope) Scope
type Variable ¶
type Variable struct {
// contains filtered or unexported fields
}
func GetVariable ¶
GetVariable 从 scope 中通过变量名称查询变量
func NewVariable ¶
func NewVariable(ctx antlr.ParserRuleContext, name string, enclose Scope) *Variable
func (Variable) GetEncloseScope ¶
func (s Variable) GetEncloseScope() Scope
func (Variable) SetEncloseScope ¶
func (s Variable) SetEncloseScope(scope Scope)
Click to show internal directories.
Click to hide internal directories.