Documentation
¶
Index ¶
- type AssignmentStmt
- type Class
- type CommentStmt
- type ElifStmt
- type ElseStmt
- type Expression
- type Field
- type File
- type Function
- type FunctionCall
- type FunctionCallParameter
- type FunctionCallStmt
- type IfStmt
- type Import
- type ImportWhat
- type Node
- type Parameter
- type PythonCodeGenerator
- func (cg *PythonCodeGenerator) Generate(file *File) (string, error)
- func (cg *PythonCodeGenerator) VisitAssignmentStmt(assignment *AssignmentStmt) error
- func (cg *PythonCodeGenerator) VisitClass(class *Class) error
- func (cg *PythonCodeGenerator) VisitCommentStmt(comment *CommentStmt) error
- func (cg *PythonCodeGenerator) VisitElifStmt(elifStmt *ElifStmt) error
- func (cg *PythonCodeGenerator) VisitElseStmt(elseStmt *ElseStmt) error
- func (cg *PythonCodeGenerator) VisitField(field *Field) error
- func (cg *PythonCodeGenerator) VisitFile(file *File) error
- func (cg *PythonCodeGenerator) VisitFunction(function *Function) error
- func (cg *PythonCodeGenerator) VisitFunctionCall(functionCall *FunctionCall) error
- func (cg *PythonCodeGenerator) VisitFunctionCallParameter(functionCallParameter *FunctionCallParameter) error
- func (cg *PythonCodeGenerator) VisitFunctionCallStmt(functionCall *FunctionCallStmt) error
- func (cg *PythonCodeGenerator) VisitIfStmt(ifStmt *IfStmt) error
- func (cg *PythonCodeGenerator) VisitImport(importStmt *Import) error
- func (cg *PythonCodeGenerator) VisitImportWhat(importWhat *ImportWhat) error
- func (cg *PythonCodeGenerator) VisitParameter(parameter *Parameter) error
- func (cg *PythonCodeGenerator) VisitReturnStmt(returnStmt *ReturnStmt) error
- type PythonVisitor
- type ReturnStmt
- type Statement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssignmentStmt ¶
type AssignmentStmt struct {
Variable string
Type string
StringValue string
FunctionCallValue *FunctionCall
}
func (*AssignmentStmt) Accept ¶
func (s *AssignmentStmt) Accept(visitor PythonVisitor) error
Accept method for AssignmentStmt
type Class ¶
type CommentStmt ¶
type CommentStmt struct {
Lines []string
}
CommentStmt One line is using # and multiple lines are using """
func (*CommentStmt) Accept ¶
func (s *CommentStmt) Accept(visitor PythonVisitor) error
Accept method for FunctionComment
type ElifStmt ¶
func (*ElifStmt) Accept ¶
func (s *ElifStmt) Accept(visitor PythonVisitor) error
Accept method for ElifStmt
type ElseStmt ¶
type ElseStmt struct {
Body []Statement
}
func (*ElseStmt) Accept ¶
func (s *ElseStmt) Accept(visitor PythonVisitor) error
Accept method for ElseStmt
type Expression ¶
type Expression interface {
}
type File ¶
type Function ¶
type Function struct {
Name string
ReturnType string
Params []Parameter
Imports []Import
Body []Statement
}
func (*Function) Accept ¶
func (f *Function) Accept(visitor PythonVisitor) error
Accept method for Function
type FunctionCall ¶
type FunctionCall struct {
Name string
Params []FunctionCallParameter
}
func (*FunctionCall) Accept ¶
func (s *FunctionCall) Accept(visitor PythonVisitor) error
Accept method for FunctionCall
type FunctionCallParameter ¶
func (*FunctionCallParameter) Accept ¶
func (s *FunctionCallParameter) Accept(visitor PythonVisitor) error
Accept method for FunctionCallParameter
type FunctionCallStmt ¶
type FunctionCallStmt struct {
FunctionCall
}
func (*FunctionCallStmt) Accept ¶
func (s *FunctionCallStmt) Accept(visitor PythonVisitor) error
Accept method for FunctionCallStmt
type IfStmt ¶
func (*IfStmt) Accept ¶
func (s *IfStmt) Accept(visitor PythonVisitor) error
Accept method for IfStmt
type Import ¶
type Import struct {
What []ImportWhat
From string
Alias string
}
func (*Import) Accept ¶
func (i *Import) Accept(visitor PythonVisitor) error
Accept method for Import
type ImportWhat ¶
func (*ImportWhat) Accept ¶
func (i *ImportWhat) Accept(visitor PythonVisitor) error
Accept method for ImportWhat
type Node ¶
type Node interface {
Accept(visitor PythonVisitor) error // Accept method to allow visitors
}
type Parameter ¶
func (*Parameter) Accept ¶
func (p *Parameter) Accept(visitor PythonVisitor) error
Accept method for Parameter
type PythonCodeGenerator ¶
type PythonCodeGenerator struct {
// contains filtered or unexported fields
}
func NewPythonCodeGenerator ¶
func NewPythonCodeGenerator(indentFourSpaces bool) *PythonCodeGenerator
NewPythonCodeGenerator creates a new PythonCodeGenerator indentFourSpaces: if true, use 4 spaces for indentation, otherwise use 8 spaces
func (*PythonCodeGenerator) Generate ¶
func (cg *PythonCodeGenerator) Generate(file *File) (string, error)
Generate generates the code from the AST
func (*PythonCodeGenerator) VisitAssignmentStmt ¶
func (cg *PythonCodeGenerator) VisitAssignmentStmt(assignment *AssignmentStmt) error
VisitAssignmentStmt visits an AssignmentStmt node
func (*PythonCodeGenerator) VisitClass ¶
func (cg *PythonCodeGenerator) VisitClass(class *Class) error
VisitClass visits a Class node
func (*PythonCodeGenerator) VisitCommentStmt ¶
func (cg *PythonCodeGenerator) VisitCommentStmt(comment *CommentStmt) error
VisitCommentStmt visits a CommentStmt node
func (*PythonCodeGenerator) VisitElifStmt ¶
func (cg *PythonCodeGenerator) VisitElifStmt(elifStmt *ElifStmt) error
VisitElifStmt visits an ElifStmt node
func (*PythonCodeGenerator) VisitElseStmt ¶
func (cg *PythonCodeGenerator) VisitElseStmt(elseStmt *ElseStmt) error
VisitElseStmt visits an ElseStmt node
func (*PythonCodeGenerator) VisitField ¶
func (cg *PythonCodeGenerator) VisitField(field *Field) error
VisitField visits a Field node
func (*PythonCodeGenerator) VisitFile ¶
func (cg *PythonCodeGenerator) VisitFile(file *File) error
VisitFile visits a File node
func (*PythonCodeGenerator) VisitFunction ¶
func (cg *PythonCodeGenerator) VisitFunction(function *Function) error
VisitFunction visits a Function node
func (*PythonCodeGenerator) VisitFunctionCall ¶
func (cg *PythonCodeGenerator) VisitFunctionCall(functionCall *FunctionCall) error
VisitFunctionCall visits a FunctionCall node
func (*PythonCodeGenerator) VisitFunctionCallParameter ¶
func (cg *PythonCodeGenerator) VisitFunctionCallParameter(functionCallParameter *FunctionCallParameter) error
VisitFunctionCallParameter visits a FunctionCallParameter node
func (*PythonCodeGenerator) VisitFunctionCallStmt ¶
func (cg *PythonCodeGenerator) VisitFunctionCallStmt(functionCall *FunctionCallStmt) error
VisitFunctionCallStmt visits a FunctionCallStmt node
func (*PythonCodeGenerator) VisitIfStmt ¶
func (cg *PythonCodeGenerator) VisitIfStmt(ifStmt *IfStmt) error
VisitIfStmt visits an IfStmt node
func (*PythonCodeGenerator) VisitImport ¶
func (cg *PythonCodeGenerator) VisitImport(importStmt *Import) error
VisitImport visits an Import node
func (*PythonCodeGenerator) VisitImportWhat ¶
func (cg *PythonCodeGenerator) VisitImportWhat(importWhat *ImportWhat) error
VisitImportWhat visits an ImportWhat node
func (*PythonCodeGenerator) VisitParameter ¶
func (cg *PythonCodeGenerator) VisitParameter(parameter *Parameter) error
VisitParameter visits a Parameter node
func (*PythonCodeGenerator) VisitReturnStmt ¶
func (cg *PythonCodeGenerator) VisitReturnStmt(returnStmt *ReturnStmt) error
VisitReturnStmt visits a ReturnStmt node
type PythonVisitor ¶
type PythonVisitor interface {
VisitFile(*File) error
VisitFunction(*Function) error
VisitClass(*Class) error
VisitField(*Field) error
VisitParameter(*Parameter) error
VisitImport(*Import) error
VisitImportWhat(*ImportWhat) error
VisitFunctionCall(*FunctionCall) error
VisitFunctionCallParameter(*FunctionCallParameter) error
// Statements
VisitAssignmentStmt(*AssignmentStmt) error
VisitFunctionCallStmt(*FunctionCallStmt) error
VisitCommentStmt(*CommentStmt) error
VisitReturnStmt(*ReturnStmt) error
VisitIfStmt(*IfStmt) error
VisitElifStmt(*ElifStmt) error
VisitElseStmt(*ElseStmt) error
}
type ReturnStmt ¶
type ReturnStmt struct {
Value string
}
func (*ReturnStmt) Accept ¶
func (s *ReturnStmt) Accept(visitor PythonVisitor) error
Accept method for ReturnStmt