Documentation ¶
Index ¶
- type AssignStatement
- type BinaryExpression
- type Block
- type BoolLiteral
- type CaseElement
- type CaseStatement
- type CompoundStatement
- type ConstDef
- type ConstDefinition
- type Decl
- type Expression
- type FieldDesignator
- type ForStatement
- type FormalParameter
- type FuncDeclaration
- type FuncDesignator
- type FuncHeading
- type GotoStatement
- type IdentifiedVariable
- type Identifier
- type IfStatement
- type IndexedVariable
- type LabelDefinition
- type NilValue
- type Node
- type ProcedureDeclaration
- type ProcedureHeading
- type ProcedureStatement
- type ProcedureStmt
- type Program
- type Range
- type Read
- type ReadLn
- type RepeatStatement
- type ReturnStatement
- type SetConstructor
- type Statement
- type StrLiteral
- type TypeDef
- type TypeDefinition
- type UIntegerLiteral
- type URealLiteral
- type UnaryExpression
- type ValueParam
- type VarDecl
- type VarDeclaration
- type VariableParam
- type Visitor
- type WhileStatement
- type WithStatement
- type Write
- type WriteParameter
- type Writeln
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssignStatement ¶
type AssignStatement struct { Token token.Token Variable Expression Value Expression Label string }
AssignStatement is the node used to represent Pascal assignments in the AST
func (*AssignStatement) Pos ¶
func (as *AssignStatement) Pos() *token.Position
func (*AssignStatement) SetLabel ¶
func (as *AssignStatement) SetLabel(l string)
func (*AssignStatement) String ¶
func (as *AssignStatement) String() string
type BinaryExpression ¶
type BinaryExpression struct {
Left, Right Expression
Operator token.Token
EType types.Type
}
BinaryExpression ...
func (*BinaryExpression) Accept ¶
func (b *BinaryExpression) Accept(vst Visitor) error
func (*BinaryExpression) Pos ¶
func (b *BinaryExpression) Pos() *token.Position
func (*BinaryExpression) String ¶
func (b *BinaryExpression) String() string
func (*BinaryExpression) Type ¶
func (b *BinaryExpression) Type() types.Type
type Block ¶
type Block struct { // label definition part Labels *LabelDefinition // constant definition part Consts *ConstDefinition // type definition part Types *TypeDefinition // variable declaration part VarDeclaration *VarDeclaration // procedure and function declaration part Callables []Statement // statements Stats []Statement }
Block is a block type node in the AST. These include function and procedure blocks
type BoolLiteral ¶
BoolLiteral defines a boolean literal value node in the AST
func (*BoolLiteral) Pos ¶
func (b *BoolLiteral) Pos() *token.Position
func (*BoolLiteral) String ¶
func (b *BoolLiteral) String() string
type CaseElement ¶
type CaseElement struct { ConstList []Expression Body Statement }
CaseElement ...
func (*CaseElement) String ¶
func (c *CaseElement) String() string
type CaseStatement ¶
type CaseStatement struct { Token token.Token Index Expression List []*CaseElement Label string }
CaseStatement models the AST node of a Case Statement
func (*CaseStatement) Accept ¶
func (c *CaseStatement) Accept(vst Visitor) error
func (*CaseStatement) Pos ¶
func (c *CaseStatement) Pos() *token.Position
func (*CaseStatement) SetLabel ¶
func (c *CaseStatement) SetLabel(l string)
func (*CaseStatement) String ¶
func (c *CaseStatement) String() string
type CompoundStatement ¶
CompoundStatement is the node in the AST that represents a compound statement.
func (*CompoundStatement) Accept ¶
func (cs *CompoundStatement) Accept(vst Visitor) error
func (*CompoundStatement) Pos ¶
func (cs *CompoundStatement) Pos() *token.Position
func (*CompoundStatement) SetLabel ¶
func (cs *CompoundStatement) SetLabel(l string)
func (*CompoundStatement) String ¶
func (cs *CompoundStatement) String() string
type ConstDef ¶
type ConstDef struct { Name *Identifier Value Expression }
ConstDef models a single constant definition
type ConstDefinition ¶
ConstDefinition models the constant-definition-part of a block
func (*ConstDefinition) Accept ¶
func (c *ConstDefinition) Accept(vst Visitor) error
func (*ConstDefinition) Pos ¶
func (c *ConstDefinition) Pos() *token.Position
func (*ConstDefinition) String ¶
func (c *ConstDefinition) String() string
type Expression ¶
Expression models a generic node for expression types
type FieldDesignator ¶
type FieldDesignator struct { RecordVar Expression FieldSpec Expression EType types.Type }
FieldDesignator ...
func (*FieldDesignator) Accept ¶
func (f *FieldDesignator) Accept(vst Visitor) error
func (*FieldDesignator) Pos ¶
func (f *FieldDesignator) Pos() *token.Position
func (*FieldDesignator) String ¶
func (f *FieldDesignator) String() string
func (*FieldDesignator) Type ¶
func (f *FieldDesignator) Type() types.Type
type ForStatement ¶
type ForStatement struct { Token token.Token CtrlID *Identifier InitValue, FinalValue Expression Body Statement Direction token.Kind Label string }
ForStatement ...
func (*ForStatement) Accept ¶
func (f *ForStatement) Accept(vst Visitor) error
func (*ForStatement) Pos ¶
func (f *ForStatement) Pos() *token.Position
func (*ForStatement) SetLabel ¶
func (f *ForStatement) SetLabel(l string)
func (*ForStatement) String ¶
func (f *ForStatement) String() string
type FormalParameter ¶
type FormalParameter interface { Expression // contains filtered or unexported methods }
FormalParameter denotes a generic formal parameter type
type FuncDeclaration ¶
type FuncDeclaration struct { Heading *FuncHeading Block *Block Directive *Identifier Label string }
FuncDeclaration is the node type for a function declaration in the AST
func (*FuncDeclaration) Accept ¶
func (f *FuncDeclaration) Accept(vst Visitor) error
func (*FuncDeclaration) Pos ¶
func (f *FuncDeclaration) Pos() *token.Position
func (*FuncDeclaration) SetLabel ¶
func (f *FuncDeclaration) SetLabel(l string)
func (*FuncDeclaration) String ¶
func (f *FuncDeclaration) String() string
type FuncDesignator ¶
type FuncDesignator struct { Name *Identifier Args []Expression EType types.Type }
FuncDesignator is the node that represents a function call
func (*FuncDesignator) Accept ¶
func (f *FuncDesignator) Accept(vst Visitor) error
func (*FuncDesignator) Pos ¶
func (f *FuncDesignator) Pos() *token.Position
func (*FuncDesignator) String ¶
func (f *FuncDesignator) String() string
func (*FuncDesignator) Type ¶
func (f *FuncDesignator) Type() types.Type
type FuncHeading ¶
type FuncHeading struct { Token token.Token FName *Identifier Parameters []FormalParameter ReturnType types.Type Lbl string }
FuncHeading denotes a function's signature.
func (*FuncHeading) Accept ¶
func (f *FuncHeading) Accept(vst Visitor) error
func (*FuncHeading) Name ¶
func (f *FuncHeading) Name() string
func (*FuncHeading) Pos ¶
func (f *FuncHeading) Pos() *token.Position
func (*FuncHeading) String ¶
func (f *FuncHeading) String() string
func (*FuncHeading) Type ¶
func (f *FuncHeading) Type() types.Type
func (*FuncHeading) Underlying ¶
func (f *FuncHeading) Underlying() types.Type
type GotoStatement ¶
type GotoStatement struct { Token token.Token Label *UIntegerLiteral Lbl string }
GotoStatement ...
func (*GotoStatement) Accept ¶
func (g *GotoStatement) Accept(vst Visitor) error
func (*GotoStatement) Pos ¶
func (g *GotoStatement) Pos() *token.Position
func (*GotoStatement) SetLabel ¶
func (g *GotoStatement) SetLabel(l string)
func (*GotoStatement) String ¶
func (g *GotoStatement) String() string
type IdentifiedVariable ¶
type IdentifiedVariable struct { PointerName *Identifier UnderType types.Type EType types.Type }
func (*IdentifiedVariable) Accept ¶
func (i *IdentifiedVariable) Accept(vst Visitor) error
func (*IdentifiedVariable) Pos ¶
func (i *IdentifiedVariable) Pos() *token.Position
func (*IdentifiedVariable) String ¶
func (i *IdentifiedVariable) String() string
func (*IdentifiedVariable) Type ¶
func (i *IdentifiedVariable) Type() types.Type
type Identifier ¶
Identifier models an identifier node in the AST
func (*Identifier) Accept ¶
func (id *Identifier) Accept(vst Visitor) error
func (*Identifier) Pos ¶
func (id *Identifier) Pos() *token.Position
func (*Identifier) String ¶
func (id *Identifier) String() string
func (*Identifier) Type ¶
func (id *Identifier) Type() types.Type
type IfStatement ¶
type IfStatement struct { Token token.Token BoolExpr Expression TruePath Statement ElsePath Statement Label string }
IfStatement is the node in the AST that represents an If Statement
func (*IfStatement) Accept ¶
func (f *IfStatement) Accept(vst Visitor) error
func (*IfStatement) Pos ¶
func (f *IfStatement) Pos() *token.Position
func (*IfStatement) SetLabel ¶
func (f *IfStatement) SetLabel(l string)
func (*IfStatement) String ¶
func (f *IfStatement) String() string
type IndexedVariable ¶
type IndexedVariable struct { ArrayVar Expression IndexExpr []Expression EType types.Type }
IndexedVariable ...
func (*IndexedVariable) Accept ¶
func (iv *IndexedVariable) Accept(vst Visitor) error
func (*IndexedVariable) Pos ¶
func (iv *IndexedVariable) Pos() *token.Position
func (*IndexedVariable) String ¶
func (iv *IndexedVariable) String() string
func (*IndexedVariable) Type ¶
func (iv *IndexedVariable) Type() types.Type
type LabelDefinition ¶
type LabelDefinition struct { Token token.Token Labels []*UIntegerLiteral }
LabelDefinition ...
func (*LabelDefinition) Accept ¶
func (l *LabelDefinition) Accept(vst Visitor) error
func (*LabelDefinition) Pos ¶
func (l *LabelDefinition) Pos() *token.Position
func (*LabelDefinition) String ¶
func (l *LabelDefinition) String() string
type ProcedureDeclaration ¶
type ProcedureDeclaration struct { Heading *ProcedureHeading Block *Block Directive *Identifier Label string }
ProcedureDeclaration denotes a procedure declaration
func (*ProcedureDeclaration) Accept ¶
func (p *ProcedureDeclaration) Accept(vst Visitor) error
func (*ProcedureDeclaration) Pos ¶
func (p *ProcedureDeclaration) Pos() *token.Position
func (*ProcedureDeclaration) SetLabel ¶
func (p *ProcedureDeclaration) SetLabel(l string)
func (*ProcedureDeclaration) String ¶
func (p *ProcedureDeclaration) String() string
type ProcedureHeading ¶
type ProcedureHeading struct { Token token.Token PName *Identifier Parameters []FormalParameter }
ProcedureHeading denotes a procedure's signature.
func (*ProcedureHeading) Accept ¶
func (p *ProcedureHeading) Accept(vst Visitor) error
func (*ProcedureHeading) Name ¶
func (p *ProcedureHeading) Name() string
func (*ProcedureHeading) Pos ¶
func (p *ProcedureHeading) Pos() *token.Position
func (*ProcedureHeading) String ¶
func (p *ProcedureHeading) String() string
func (*ProcedureHeading) Type ¶
func (p *ProcedureHeading) Type() types.Type
func (*ProcedureHeading) Underlying ¶
func (p *ProcedureHeading) Underlying() types.Type
type ProcedureStatement ¶
type ProcedureStatement interface { Statement GetName() string GetParamList() []Expression }
type ProcedureStmt ¶
type ProcedureStmt struct { Name *Identifier Args []Expression Label string }
ProcedureStmt models a procedure statement node
func (*ProcedureStmt) Accept ¶
func (ps *ProcedureStmt) Accept(vst Visitor) error
func (*ProcedureStmt) GetName ¶
func (ps *ProcedureStmt) GetName() string
func (*ProcedureStmt) GetParamList ¶
func (ps *ProcedureStmt) GetParamList() []Expression
func (*ProcedureStmt) Pos ¶
func (ps *ProcedureStmt) Pos() *token.Position
func (*ProcedureStmt) SetLabel ¶
func (ps *ProcedureStmt) SetLabel(l string)
func (*ProcedureStmt) String ¶
func (ps *ProcedureStmt) String() string
type Program ¶
type Program struct { TokenKind token.Kind Name *Identifier ParamList []*Identifier Block *Block }
Program defines the root node of the AST. It correlates to the start symbol in the grammar
type Range ¶
type Range struct { Token token.Token Start, End Expression EType types.Type }
Range ...
type Read ¶
type Read struct { Token token.Token Name string File *Identifier VarAccess []Expression Label string }
func (*Read) GetParamList ¶
func (r *Read) GetParamList() []Expression
type ReadLn ¶
type ReadLn struct { Token token.Token Name string File *Identifier VarAccess []Expression Label string }
func (*ReadLn) GetParamList ¶
func (r *ReadLn) GetParamList() []Expression
type RepeatStatement ¶
type RepeatStatement struct { Token token.Token StmtSeq []Statement BoolExpr Expression Label string }
RepeatStatement models the AST node of a Repeat Statement
func (*RepeatStatement) Accept ¶
func (r *RepeatStatement) Accept(vst Visitor) error
func (*RepeatStatement) Pos ¶
func (r *RepeatStatement) Pos() *token.Position
func (*RepeatStatement) SetLabel ¶
func (r *RepeatStatement) SetLabel(l string)
func (*RepeatStatement) String ¶
func (r *RepeatStatement) String() string
type ReturnStatement ¶
type ReturnStatement struct { Token token.Token Expr Expression Label string }
func (*ReturnStatement) Accept ¶
func (r *ReturnStatement) Accept(vst Visitor) error
func (*ReturnStatement) Pos ¶
func (r *ReturnStatement) Pos() *token.Position
func (*ReturnStatement) SetLabel ¶
func (r *ReturnStatement) SetLabel(l string)
func (*ReturnStatement) String ¶
func (r *ReturnStatement) String() string
type SetConstructor ¶
type SetConstructor struct { Token token.Token Members []Expression EType types.Type }
SetConstructor ...
func (*SetConstructor) Accept ¶
func (s *SetConstructor) Accept(vst Visitor) error
func (*SetConstructor) Pos ¶
func (s *SetConstructor) Pos() *token.Position
func (*SetConstructor) String ¶
func (s *SetConstructor) String() string
func (*SetConstructor) Type ¶
func (s *SetConstructor) Type() types.Type
type StrLiteral ¶
StrLiteral models the node for character string literals
func (*StrLiteral) Accept ¶
func (str *StrLiteral) Accept(vst Visitor) error
func (*StrLiteral) Pos ¶
func (str *StrLiteral) Pos() *token.Position
func (*StrLiteral) String ¶
func (str *StrLiteral) String() string
func (*StrLiteral) Type ¶
func (str *StrLiteral) Type() types.Type
type TypeDefinition ¶
TypeDefinition ...
func (*TypeDefinition) Accept ¶
func (t *TypeDefinition) Accept(vst Visitor) error
func (*TypeDefinition) Pos ¶
func (t *TypeDefinition) Pos() *token.Position
func (*TypeDefinition) String ¶
func (t *TypeDefinition) String() string
type UIntegerLiteral ¶
UIntegerLiteral is the node for an unsigned integer node in the AST
func (*UIntegerLiteral) Accept ¶
func (u *UIntegerLiteral) Accept(vst Visitor) error
func (*UIntegerLiteral) Pos ¶
func (u *UIntegerLiteral) Pos() *token.Position
func (*UIntegerLiteral) String ¶
func (u *UIntegerLiteral) String() string
func (*UIntegerLiteral) Type ¶
func (u *UIntegerLiteral) Type() types.Type
type URealLiteral ¶
URealLiteral represents an unsigned floating point number
func (*URealLiteral) Accept ¶
func (ur *URealLiteral) Accept(vst Visitor) error
func (*URealLiteral) Pos ¶
func (ur *URealLiteral) Pos() *token.Position
func (*URealLiteral) String ¶
func (ur *URealLiteral) String() string
func (*URealLiteral) Type ¶
func (ur *URealLiteral) Type() types.Type
type UnaryExpression ¶
type UnaryExpression struct { Operator token.Token Operand Expression EType types.Type }
UnaryExpression ...
func (*UnaryExpression) Accept ¶
func (u *UnaryExpression) Accept(vst Visitor) error
func (*UnaryExpression) Pos ¶
func (u *UnaryExpression) Pos() *token.Position
func (*UnaryExpression) String ¶
func (u *UnaryExpression) String() string
func (*UnaryExpression) Type ¶
func (u *UnaryExpression) Type() types.Type
type ValueParam ¶
type ValueParam struct { Names []*Identifier Typ types.Type }
ValueParam denoted a value parameter specification
func (*ValueParam) Accept ¶
func (v *ValueParam) Accept(vst Visitor) error
func (*ValueParam) Name ¶
func (v *ValueParam) Name() string
func (*ValueParam) Pos ¶
func (v *ValueParam) Pos() *token.Position
func (*ValueParam) String ¶
func (v *ValueParam) String() string
func (*ValueParam) Type ¶
func (v *ValueParam) Type() types.Type
type VarDeclaration ¶
VarDeclaration models the variable definition node in the AST
func (*VarDeclaration) Accept ¶
func (vr *VarDeclaration) Accept(vst Visitor) error
func (*VarDeclaration) Pos ¶
func (vr *VarDeclaration) Pos() *token.Position
func (*VarDeclaration) String ¶
func (vr *VarDeclaration) String() string
type VariableParam ¶
type VariableParam struct { Token token.Token Names []*Identifier Typ types.Type }
VariableParam denotes a variable parameter specification
func (*VariableParam) Accept ¶
func (v *VariableParam) Accept(vst Visitor) error
func (*VariableParam) Name ¶
func (v *VariableParam) Name() string
func (*VariableParam) Pos ¶
func (v *VariableParam) Pos() *token.Position
func (*VariableParam) String ¶
func (v *VariableParam) String() string
func (*VariableParam) Type ¶
func (v *VariableParam) Type() types.Type
type Visitor ¶
type Visitor interface { VisitIdentifier(*Identifier) error VisitUIntLiteral(*UIntegerLiteral) error VisitAssignStmt(*AssignStatement) error VisitIndexedVariable(*IndexedVariable) error VisitBinaryExpr(*BinaryExpression) error VisitUnaryExpr(*UnaryExpression) error VisitBoolLiteral(*BoolLiteral) error VisitURealLiteral(*URealLiteral) error VisitForStatement(*ForStatement) error VisitIfStatement(*IfStatement) error VisitFuncDesignator(*FuncDesignator) error VisitGotoStatement(*GotoStatement) error VisitIdentifiedVariable(*IdentifiedVariable) error VisitWhileStatement(*WhileStatement) error VisitWithStatement(*WithStatement) error VisitRepeatStatement(*RepeatStatement) error VisitReturnStatement(*ReturnStatement) error VisitRange(*Range) error VisitFieldDesignator(*FieldDesignator) error VisitCompoundStatement(*CompoundStatement) error VisitStrLiteral(*StrLiteral) error VisitFuncDeclaration(*FuncDeclaration) error VisitProcedureDecl(*ProcedureDeclaration) error VisitProcedureStmt(*ProcedureStmt) error VisitRead(*Read) error VisitReadLn(*ReadLn) error VisitWrite(*Write) error VisitWriteln(*Writeln) error VisitNil(*NilValue) error VisitCaseStatement(*CaseStatement) error VisitWriteParameter(*WriteParameter) error VisitSetConstructor(*SetConstructor) error VisitValueParam(*ValueParam) error VisitVariableParam(*VariableParam) error VisitFuncHeading(*FuncHeading) error VisitProcedureHeading(*ProcedureHeading) error VisitVarDecl(*VarDeclaration) error VisitConstDef(*ConstDefinition) error VisitLabelDef(*LabelDefinition) error VisitTypeDef(*TypeDefinition) error }
Visitor ...
type WhileStatement ¶
type WhileStatement struct { Token token.Token BoolExpr Expression Body Statement Label string }
WhileStatement models the AST node of a While Statement
func (*WhileStatement) Accept ¶
func (w *WhileStatement) Accept(vst Visitor) error
func (*WhileStatement) Pos ¶
func (w *WhileStatement) Pos() *token.Position
func (*WhileStatement) SetLabel ¶
func (w *WhileStatement) SetLabel(l string)
func (*WhileStatement) String ¶
func (w *WhileStatement) String() string
type WithStatement ¶
type WithStatement struct { Token token.Token RecordVarList []Expression Body Statement Label string }
WithStatement models the AST node of a With Statement
func (*WithStatement) Accept ¶
func (w *WithStatement) Accept(vst Visitor) error
func (*WithStatement) Pos ¶
func (w *WithStatement) Pos() *token.Position
func (*WithStatement) SetLabel ¶
func (w *WithStatement) SetLabel(l string)
func (*WithStatement) String ¶
func (w *WithStatement) String() string
type Write ¶
type Write struct { Token token.Token Name string File *Identifier ParamList []Expression Label string }
func (*Write) GetParamList ¶
func (w *Write) GetParamList() []Expression
type WriteParameter ¶
type WriteParameter struct { E Expression TotalWidth Expression FracDigits Expression EType types.Type }
WriteParameter is the node that represents a single parameter to be passed to the write[ln] procedure
func (*WriteParameter) Accept ¶
func (w *WriteParameter) Accept(vst Visitor) error
func (*WriteParameter) Pos ¶
func (w *WriteParameter) Pos() *token.Position
func (*WriteParameter) String ¶
func (w *WriteParameter) String() string
func (*WriteParameter) Type ¶
func (w *WriteParameter) Type() types.Type
type Writeln ¶
type Writeln struct { Token token.Token Name string File *Identifier ParamList []Expression Label string }
func (*Writeln) GetParamList ¶
func (w *Writeln) GetParamList() []Expression
Source Files ¶
- AssignStatement.go
- Ast.go
- BinaryExpression.go
- Block.go
- BoolLiteral.go
- CaseStatement.go
- CompoundStatement.go
- ConstDefinition.go
- FieldDesignator.go
- ForStatement.go
- FuncDeclaration.go
- FuncDesignator.go
- GoToStatement.go
- IdentifiedVariable.go
- Identifier.go
- IfStatement.go
- IndexedVariable.go
- LabelDefinition.go
- NilValue.go
- Parameter.go
- ProcedureDeclaration.go
- ProcedureStatement.go
- ProcedureStmt.go
- Program.go
- Range.go
- Read.go
- ReadLn.go
- RepeatStatement.go
- ReturnStatement.go
- SetConstructor.go
- StrLiteral.go
- TypeDefinition.go
- UIntegerLiteral.go
- URealLiteral.go
- UnaryExpression.go
- VarDeclaration.go
- Visitor.go
- WhileStatement.go
- WithStatement.go
- Write.go
- WriteParameter.go
- Writeln.go