Rosewood File Parser

Overview

Package parser implements a Rosewood file and command parsers

Index

Package files

cmd_parser.go convert.go errors.go file_parser.go io.go parse_table_cmd.go run_set.go

Constants

const (
    ErrGeneric int = iota
    ErrSyntaxError
    ErrEmpty
    ErrUnknown
)

Variables

var RWSyntaxVdotzero1 = RWSyntax{
    Version:          "v0.1",
    SectionSeparator: "---",
    ColumnSeparator:  "|",
}

RWSyntaxVdotzero1 syntax for Rosewood v0.1

var RWSyntaxVdotzero2 = RWSyntax{
    Version:          "v0.2",
    SectionSeparator: "+++",
    ColumnSeparator:  "|",
}

RWSyntaxVdotzero2 syntax for Rosewood v0.2

func CheckFileVersion

func CheckFileVersion(r io.ReadSeeker) (version string, err error)

func ConvertToCurrentVersion

func ConvertToCurrentVersion(settings *types.RosewoodSettings, oldSyntax RWSyntax, in io.Reader, out io.Writer) error

ConvertToCurrentVersion utility to convert two current Rosewood version

func ConvertVersion

func ConvertVersion(settings *types.RosewoodSettings, newSyntax RWSyntax, oldSyntax RWSyntax, in io.Reader) ([]string, error)

ConvertVersion utility to convert between two Rosewood versions

func GetFileVersion

func GetFileVersion(header string) string

GetFileVersion returns Rosewood file version based on header info

type CommandParser

type CommandParser struct {
    // contains filtered or unexported fields
}

CommandParser specialized parser for format commands

func NewCommandParser

func NewCommandParser(settings *types.RosewoodSettings) *CommandParser

NewCommandParser initializes and returns a CommandParser

func (*CommandParser) ErrorText

func (p *CommandParser) ErrorText(index int) string

ErrorText returns a \n separated list of errors if index =-1, otherwise returns the indexth error;

func (*CommandParser) Errors

func (p *CommandParser) Errors() *errors.ErrorList

Errors returns a list of parsing errors

func (*CommandParser) ParseCommandLines

func (p *CommandParser) ParseCommandLines(s *types.Section) ([]*types.Command, error)

ParseCommandLines parses a list of strings into list of commands

func (*CommandParser) Pos

func (p *CommandParser) Pos() Position

Pos returns the current position in the source

type EmError

type EmError struct {
    Type int
    Position
    Message string
}

A EmError is a generic error returned for parsing errors.

func NewError

func NewError(etype int, pos Position, msg string) *EmError

NewError returns a pointer to a new EmError

func (EmError) Error

func (e EmError) Error() string

EmError implements the error interface

type File

type File struct {
    FileName string
    // contains filtered or unexported fields
}

File holds information on currently parsed Rosewood file

func NewFile

func NewFile(fileName string, settings *types.RosewoodSettings) *File

NewFile returns a Rosewood File

func (*File) Err

func (f *File) Err() error

Err returns a list of parsing errors

func (*File) Errors

func (f *File) Errors() *errors.ErrorList

Errors returns a list of parsing errors

func (*File) Parse

func (f *File) Parse(r io.ReadSeeker) error

Parse parses an io.ReadSeeker streaming a Rosewood file and returns any found tables

func (*File) SectionCount

func (f *File) SectionCount() int

SectionCount returns the number of sections found in the file

func (*File) TableCount

func (f *File) TableCount() int

TableCount returns the number of prased tables in the file

func (*File) Tables

func (f *File) Tables() []*types.Table

Tables returns an array of pointers to parsed Tables

type Position

type Position = scanner.Position

Position is an alias of scanner.Position

type RWSyntax

type RWSyntax struct {
    Version          string
    SectionSeparator string
    ColumnSeparator  string
}

RWSyntax holds info on syntax differences in each Rosewood version


Generated by godoc2md

19/08/2018