Documentation ¶
Index ¶
- func AreCompatibleTypes(a, b types.Type) bool
- func IsOrdinalType(t types.Type) bool
- func IsSimpleType(t types.Type) bool
- type Boolean
- type Char
- type Const
- type Field
- type Function
- type Integer
- type Kind
- type LValueVisitor
- type Label
- type Procedure
- type Real
- type Scope
- type Symbol
- type SymbolTable
- type TypeDef
- type Variable
- type Visitor
- func (s *Visitor) AreAssignmentCompatible(src ast.Expression, dest ast.Expression) bool
- func (s *Visitor) VisitAssignStmt(a *ast.AssignStatement) error
- func (s *Visitor) VisitBinaryExpr(b *ast.BinaryExpression) error
- func (s *Visitor) VisitBlock(blk *ast.Block) error
- func (s *Visitor) VisitBoolLiteral(b *ast.BoolLiteral) error
- func (s *Visitor) VisitCaseStatement(cse *ast.CaseStatement) error
- func (s *Visitor) VisitCompoundStatement(cs *ast.CompoundStatement) error
- func (s *Visitor) VisitConstDef(constDef *ast.ConstDefinition) error
- func (s *Visitor) VisitFieldDesignator(f *ast.FieldDesignator) error
- func (s *Visitor) VisitForStatement(f *ast.ForStatement) error
- func (s *Visitor) VisitFuncDeclaration(f *ast.FuncDeclaration) error
- func (s *Visitor) VisitFuncDesignator(f *ast.FuncDesignator) error
- func (s *Visitor) VisitFuncHeading(f *ast.FuncHeading) error
- func (s *Visitor) VisitGotoStatement(g *ast.GotoStatement) error
- func (s *Visitor) VisitIdentifiedVariable(i *ast.IdentifiedVariable) error
- func (s *Visitor) VisitIdentifier(id *ast.Identifier) error
- func (s *Visitor) VisitIfStatement(i *ast.IfStatement) error
- func (s *Visitor) VisitIndexedVariable(iv *ast.IndexedVariable) error
- func (s *Visitor) VisitLabelDef(label *ast.LabelDefinition) error
- func (s *Visitor) VisitNil(n *ast.NilValue) error
- func (s *Visitor) VisitProcedureDecl(p *ast.ProcedureDeclaration) error
- func (s *Visitor) VisitProcedureHeading(p *ast.ProcedureHeading) error
- func (s *Visitor) VisitProcedureStmt(p *ast.ProcedureStmt) error
- func (s *Visitor) VisitProgram() error
- func (s *Visitor) VisitRange(r *ast.Range) error
- func (s *Visitor) VisitRead(r *ast.Read) error
- func (s *Visitor) VisitReadLn(r *ast.ReadLn) error
- func (s *Visitor) VisitRepeatStatement(rpt *ast.RepeatStatement) error
- func (s *Visitor) VisitReturnStatement(ret *ast.ReturnStatement) error
- func (s *Visitor) VisitSetConstructor(st *ast.SetConstructor) error
- func (s *Visitor) VisitStrLiteral(str *ast.StrLiteral) error
- func (s *Visitor) VisitTypeDef(types *ast.TypeDefinition) error
- func (s *Visitor) VisitUIntLiteral(i *ast.UIntegerLiteral) error
- func (s *Visitor) VisitURealLiteral(ur *ast.URealLiteral) error
- func (s *Visitor) VisitUnaryExpr(u *ast.UnaryExpression) error
- func (s *Visitor) VisitValueParam(v *ast.ValueParam) error
- func (s *Visitor) VisitVarDecl(decl *ast.VarDeclaration) error
- func (s *Visitor) VisitVariableParam(v *ast.VariableParam) error
- func (s *Visitor) VisitWhileStatement(whl *ast.WhileStatement) error
- func (s *Visitor) VisitWithStatement(with *ast.WithStatement) error
- func (s *Visitor) VisitWrite(w *ast.Write) error
- func (s *Visitor) VisitWriteParameter(w *ast.WriteParameter) error
- func (s *Visitor) VisitWriteln(w *ast.Writeln) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AreCompatibleTypes ¶
AreCompatibleTypes checks whether type provided types are 'compatible'.
func IsOrdinalType ¶
func IsSimpleType ¶
Types ¶
type Boolean ¶
type Boolean struct {
// contains filtered or unexported fields
}
Boolean ...
func NewBoolean ¶
NewBoolean creates and returns a new real-type symbol
type Char ¶
type Char struct {
// contains filtered or unexported fields
}
Char ...
type Const ¶
type Const struct {
// contains filtered or unexported fields
}
Const denotes a constant symbol
func (*Const) Value ¶
func (c *Const) Value() ast.Expression
type Field ¶
type Field struct { Offset uint64 // contains filtered or unexported fields }
Field denotes a record field symbol
type Function ¶
type Function struct {
// contains filtered or unexported fields
}
Function denotes a function symbol
func NewFunction ¶
NewFunction creates and returns a new function symbol
func NewProcedure ¶
NewProcedure creates and returns a new procedure symbol
type Integer ¶
type Integer struct {
// contains filtered or unexported fields
}
Integer ...
func NewInteger ¶
NewInteger creates and returns a new integer-type symbol
type LValueVisitor ¶
type LValueVisitor struct {
Visitor
}
LValueVisitor ...
func (*LValueVisitor) VisitFieldDesignator ¶
func (l *LValueVisitor) VisitFieldDesignator(f *ast.FieldDesignator) error
func (*LValueVisitor) VisitIdentifier ¶
func (l *LValueVisitor) VisitIdentifier(id *ast.Identifier) error
VisitIdentifier ...
func (*LValueVisitor) VisitIndexedVariable ¶
func (l *LValueVisitor) VisitIndexedVariable(iv *ast.IndexedVariable) error
VisitIndexedVariable ...
type Label ¶
type Label struct {
// contains filtered or unexported fields
}
Label denotes a label symbol
type Procedure ¶
type Procedure struct {
// contains filtered or unexported fields
}
Procedure denotes a procedure symbol
type Real ¶
type Real struct {
// contains filtered or unexported fields
}
Real ...
type Scope ¶
type Scope interface { OpenScope() CloseScope() EnterSymbol(string, Symbol) RetrieveSymbol(string) Symbol DeclaredLocally(string) bool }
Scope ...
type Symbol ¶
type Symbol interface { Name() string Kind() Kind Type() types.Type Depth() int Var() Symbol SetVar(Symbol) SetDepth(int) }
Symbol denotes a generic symbol
type SymbolTable ¶
SymbolTable ...
func (*SymbolTable) DeclaredLocally ¶
func (w *SymbolTable) DeclaredLocally(name string) bool
DeclaredLocally ...
func (*SymbolTable) EnterSymbol ¶
func (w *SymbolTable) EnterSymbol(name string, sym Symbol)
EnterSymbol ...
func (*SymbolTable) RetrieveSymbol ¶
func (w *SymbolTable) RetrieveSymbol(name string) Symbol
RetrieveSymbol ...
type TypeDef ¶
type TypeDef struct {
// contains filtered or unexported fields
}
TypeDef ...
func NewTypeDef ¶
NewTypeDef returns a new type definition symbol
type Variable ¶
type Variable struct {
// contains filtered or unexported fields
}
Variable denotes a variable symbol
func NewVariable ¶
NewVariable returns a new variable symbol type
type Visitor ¶
type Visitor struct {
// contains filtered or unexported fields
}
Visitor ...
func NewSemaVisitor ¶
func NewSemaVisitor(program *ast.Program, symTable *SymbolTable) *Visitor
func (*Visitor) AreAssignmentCompatible ¶
func (s *Visitor) AreAssignmentCompatible(src ast.Expression, dest ast.Expression) bool
AreAssignmentCompatible checks whether the provided types are 'assignment-compatible'. Any types T1 is said to be 'assignment-compatible' with T2 if any of the following conditions are satisfied:
a) T1 and T2 are the same type, and that type is permissible as the component-type of a file-type (see 6.4.3.5). b) T1 is the real-type and T2 is the integer-type. c) T1 and T2 are compatible ordinal-types, and the value of type T2 is in the closed interval specified by the type T1. d) T1 and T2 are compatible set-types, and all the members of the value of type T2 are in the closed interval specified by the base-type of T1. e) T1 and T2 are compatible string-types.
func (*Visitor) VisitAssignStmt ¶
func (s *Visitor) VisitAssignStmt(a *ast.AssignStatement) error
VisitAssignStmt ...
func (*Visitor) VisitBinaryExpr ¶
func (s *Visitor) VisitBinaryExpr(b *ast.BinaryExpression) error
func (*Visitor) VisitBoolLiteral ¶
func (s *Visitor) VisitBoolLiteral(b *ast.BoolLiteral) error
func (*Visitor) VisitCaseStatement ¶
func (s *Visitor) VisitCaseStatement(cse *ast.CaseStatement) error
func (*Visitor) VisitCompoundStatement ¶
func (s *Visitor) VisitCompoundStatement(cs *ast.CompoundStatement) error
func (*Visitor) VisitConstDef ¶
func (s *Visitor) VisitConstDef(constDef *ast.ConstDefinition) error
func (*Visitor) VisitFieldDesignator ¶
func (s *Visitor) VisitFieldDesignator(f *ast.FieldDesignator) error
func (*Visitor) VisitForStatement ¶
func (s *Visitor) VisitForStatement(f *ast.ForStatement) error
func (*Visitor) VisitFuncDeclaration ¶
func (s *Visitor) VisitFuncDeclaration(f *ast.FuncDeclaration) error
func (*Visitor) VisitFuncDesignator ¶
func (s *Visitor) VisitFuncDesignator(f *ast.FuncDesignator) error
func (*Visitor) VisitFuncHeading ¶
func (s *Visitor) VisitFuncHeading(f *ast.FuncHeading) error
func (*Visitor) VisitGotoStatement ¶
func (s *Visitor) VisitGotoStatement(g *ast.GotoStatement) error
func (*Visitor) VisitIdentifiedVariable ¶
func (s *Visitor) VisitIdentifiedVariable(i *ast.IdentifiedVariable) error
func (*Visitor) VisitIdentifier ¶
func (s *Visitor) VisitIdentifier(id *ast.Identifier) error
VisitIdentifier ...
func (*Visitor) VisitIfStatement ¶
func (s *Visitor) VisitIfStatement(i *ast.IfStatement) error
func (*Visitor) VisitIndexedVariable ¶
func (s *Visitor) VisitIndexedVariable(iv *ast.IndexedVariable) error
VisitIndexedVariable ...
func (*Visitor) VisitLabelDef ¶
func (s *Visitor) VisitLabelDef(label *ast.LabelDefinition) error
func (*Visitor) VisitProcedureDecl ¶
func (s *Visitor) VisitProcedureDecl(p *ast.ProcedureDeclaration) error
func (*Visitor) VisitProcedureHeading ¶
func (s *Visitor) VisitProcedureHeading(p *ast.ProcedureHeading) error
func (*Visitor) VisitProcedureStmt ¶
func (s *Visitor) VisitProcedureStmt(p *ast.ProcedureStmt) error
func (*Visitor) VisitProgram ¶
func (*Visitor) VisitRepeatStatement ¶
func (s *Visitor) VisitRepeatStatement(rpt *ast.RepeatStatement) error
func (*Visitor) VisitReturnStatement ¶
func (s *Visitor) VisitReturnStatement(ret *ast.ReturnStatement) error
func (*Visitor) VisitSetConstructor ¶
func (s *Visitor) VisitSetConstructor(st *ast.SetConstructor) error
func (*Visitor) VisitStrLiteral ¶
func (s *Visitor) VisitStrLiteral(str *ast.StrLiteral) error
func (*Visitor) VisitTypeDef ¶
func (s *Visitor) VisitTypeDef(types *ast.TypeDefinition) error
func (*Visitor) VisitUIntLiteral ¶
func (s *Visitor) VisitUIntLiteral(i *ast.UIntegerLiteral) error
VisitUIntLiteral ...
func (*Visitor) VisitURealLiteral ¶
func (s *Visitor) VisitURealLiteral(ur *ast.URealLiteral) error
func (*Visitor) VisitUnaryExpr ¶
func (s *Visitor) VisitUnaryExpr(u *ast.UnaryExpression) error
func (*Visitor) VisitValueParam ¶
func (s *Visitor) VisitValueParam(v *ast.ValueParam) error
func (*Visitor) VisitVarDecl ¶
func (s *Visitor) VisitVarDecl(decl *ast.VarDeclaration) error
func (*Visitor) VisitVariableParam ¶
func (s *Visitor) VisitVariableParam(v *ast.VariableParam) error
func (*Visitor) VisitWhileStatement ¶
func (s *Visitor) VisitWhileStatement(whl *ast.WhileStatement) error
func (*Visitor) VisitWithStatement ¶
func (s *Visitor) VisitWithStatement(with *ast.WithStatement) error
func (*Visitor) VisitWriteParameter ¶
func (s *Visitor) VisitWriteParameter(w *ast.WriteParameter) error