Documentation ¶
Index ¶
- type DefaultFileAccessor
- func (sr *DefaultFileAccessor) CreateFileFromContent(name string, content string)
- func (sr *DefaultFileAccessor) CreateFileFromLines(name string, lines []string)
- func (sr *DefaultFileAccessor) FindPaths(root, pattern string) ([]string, error)
- func (sr *DefaultFileAccessor) ReadCode(name string) string
- func (sr *DefaultFileAccessor) ReadCodeAsLines(name string) ([]string, []int)
- type DefaultFileReader
- type DefaultFileWriter
- type FileAccessor
- type FileReader
- type FileWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultFileAccessor ¶
type DefaultFileAccessor struct { FileReader FileWriter }
DefaultFileAccessor is the base implementation of FileAccessor
func (*DefaultFileAccessor) CreateFileFromContent ¶
func (sr *DefaultFileAccessor) CreateFileFromContent(name string, content string)
CreateFileFromContent creates a file with the given name and extension with content
func (*DefaultFileAccessor) CreateFileFromLines ¶
func (sr *DefaultFileAccessor) CreateFileFromLines(name string, lines []string)
CreateFileFromLines creates a file with the given name and extension and lines as content
func (*DefaultFileAccessor) FindPaths ¶
func (sr *DefaultFileAccessor) FindPaths(root, pattern string) ([]string, error)
FindPaths returns all file paths from the given root path, if it is a file path, it will return it as a slice
func (*DefaultFileAccessor) ReadCode ¶
func (sr *DefaultFileAccessor) ReadCode(name string) string
ReadCode reads the code lines from a source file into a string array. It will ignore all of the empty lines and the comments. It will give back the line numbers in the files in an int array, what will help later the parser to locate the error, if a there is an invalid code which can not be translated to binary.
func (*DefaultFileAccessor) ReadCodeAsLines ¶
func (sr *DefaultFileAccessor) ReadCodeAsLines(name string) ([]string, []int)
ReadCodeAsLines reads the code lines from a source file into a string array. It will ignore all of the empty lines and the comments. It will give back the line numbers in the files in an int array, what will help later the parser to locate the error, if a there is an invalid code which can not be translated to binary.
type DefaultFileReader ¶
type DefaultFileReader struct { }
DefaultFileReader is the base implementation of FileReader
type DefaultFileWriter ¶
type DefaultFileWriter struct { }
DefaultFileWriter is the base implementation of FileWriter
type FileAccessor ¶
type FileAccessor interface { ReadCodeAsLines(name string) ([]string, []int) ReadCode(name string) string CreateFileFromLines(name string, lines []string) CreateFileFromContent(name string, content string) FindPaths(root, pattern string) ([]string, error) }
FileAccessor is an interface for reading code lines of source file and creating new files
type FileReader ¶
FileReader is an interface for reading files
type FileWriter ¶
FileWriter is an interface for creating and writing hack file