syntax

package
v0.0.0-...-dc6f9f8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const NoLabel = ""

Variables

View Source
var ErrUnexpectedEnd = SyntaxError{Msg: "unexpected end of file"}

Functions

func FoldBracket

func FoldBracket(suffix []lex.Lex) (r []lex.Lex, err error)

func ParseRepo

func ParseRepo(repo Repository, pkgPaths []string) (map[string][]File, error)

ParseRepo returns a map from package path to a set of parsed files from the package directory.

Types

type Assembly

type Assembly struct {
	Sign    Ref     `ko:"name=ref"`
	Type    string  `ko:"name=type"` // "{}" or "[]" or "()"
	Term    []Term  `ko:"name=term"`
	Bracket lex.Lex `ko:"name=bracket"`
}

func (Assembly) EndPosition

func (asm Assembly) EndPosition() lex.Position

func (Assembly) FilePath

func (asm Assembly) FilePath() string

func (Assembly) RegionString

func (asm Assembly) RegionString() string

func (Assembly) StartPosition

func (asm Assembly) StartPosition() lex.Position

func (Assembly) Syntax

func (asm Assembly) Syntax() lex.Region

type Bracket

type Bracket struct {
	Left  lex.Token `ko:"name=left"`
	Right lex.Token `ko:"name=right"`
	Body  []lex.Lex `ko:"name=body"` // []Token
}

Bracket is a Lex.

func (Bracket) EndPosition

func (bra Bracket) EndPosition() lex.Position

func (Bracket) FilePath

func (bra Bracket) FilePath() string

func (Bracket) RegionString

func (bra Bracket) RegionString() string

func (Bracket) StartPosition

func (bra Bracket) StartPosition() lex.Position

func (Bracket) Type

func (bra Bracket) Type() string

type Design

type Design struct {
	Comment string   `ko:"name=comment"`
	Name    Ref      `ko:"name=name"`
	Factor  []Factor `ko:"name=factor"`
	Returns Assembly `ko:"name=returns"`
	lex.Lex `ko:"name=lex"`
}

type EmptySyntax

type EmptySyntax struct {
	lex.EmptyRegion `ko:"name=emptyRegion"`
}

type Factor

type Factor struct {
	Comment string          `ko:"name=comment"`
	Name    Ref             `ko:"name=name"`
	Monadic bool            `ko:"name=monadic"`
	lex.Lex `ko:"name=lex"` // comment and name tokens for this factor
}

type File

type File struct {
	Path   string   `ko:"name=path"`
	Import []Import `ko:"name=import"`
	Design []Design `ko:"name=design"`
}

func ParseFileString

func ParseFileString(fileName, text string) (File, error)

ParseFileString parses the tokens of a file.

type Import

type Import struct {
	Path      string     `ko:"name=path"`
	As        Ref        `ko:"name=as"`
	Comment   string     `ko:"name=comment" ctx:"expand"`     // comments preceding import statement
	EndOfLine string     `ko:"name=eol_comment" ctx:"expand"` // end-of-line comment following import statement
	Lex       lex.Region `ko:"name=lex"`                      // lex tokens comprising the import statement and surrounding comments
}

func (Import) EndPosition

func (imp Import) EndPosition() lex.Position

func (Import) FilePath

func (imp Import) FilePath() string

func (Import) RegionString

func (imp Import) RegionString() string

func (Import) StartPosition

func (imp Import) StartPosition() lex.Position

type Inline

type Inline struct {
	Design []Design `ko:"name=design"` // inline function definitions
	Series []Term   `ko:"name=series"` // inline step definitions, arising from series composition
}

func (Inline) Union

func (inline Inline) Union(u Inline) Inline

type Literal

type Literal struct {
	Value   lex.Char `ko:"name=value"` // String, Int64, or Float64
	lex.Lex `ko:"name=lex"`
}

Literal is Syntax.

type Ref

type Ref struct {
	lex.Lex `ko:"name=lex"`
	Path    []string `ko:"name=path"`
}

func ParseRef

func ParseRef(suffix []lex.Lex) (ref Ref, remain []lex.Lex, err error)

func (Ref) IsEmpty

func (ref Ref) IsEmpty() bool

func (Ref) Join

func (ref Ref) Join(with string) string

func (Ref) Name

func (ref Ref) Name() string

type Repository

type Repository interface {
	Read(filePath string) (content string, err error)
	List(dirPath string) (file, subdir []string, err error)
}

func NewLocalRepositories

func NewLocalRepositories(rootDirs []string) Repository

func NewLocalRepository

func NewLocalRepository(rootDirs []string) Repository

type SrcDir

type SrcDir map[string]interface{} // name -> SrcDir or SrcFile

SrcDir is repository.

func (SrcDir) List

func (srcDir SrcDir) List(dirPath string) (file, subdir []string, err error)

func (SrcDir) Read

func (srcDir SrcDir) Read(filePath string) (string, error)

type SrcFile

type SrcFile string

SrcFile is a source file in a SrcDir repository.

type Syntax

type Syntax interface {
	lex.Region
}

func DesignToSyntax

func DesignToSyntax(f ...Design) []Syntax

func ImportToSyntax

func ImportToSyntax(m ...Import) []Syntax

type SyntaxError

type SyntaxError struct {
	Remainder []lex.Lex     `ko:"name=remainder"` // remaining tokens at error
	Msg       string        `ko:"name=msg"`
	Cause     []SyntaxError `ko:"name=cause"`
}

func (SyntaxError) BottomCause

func (e SyntaxError) BottomCause() SyntaxError

func (SyntaxError) DeepestCause

func (e SyntaxError) DeepestCause() SyntaxError

func (SyntaxError) Depth

func (e SyntaxError) Depth() int

func (SyntaxError) Error

func (e SyntaxError) Error() string

func (SyntaxError) ShortestRemainder

func (e SyntaxError) ShortestRemainder() SyntaxError

type Term

type Term struct {
	Comment string `ko:"name=comment" ctx:"expand"`
	Label   Ref    `ko:"name=label"`
	Hitch   Syntax `ko:"name=hitch"` // Assembly, Ref, Literal
}

func (Term) EndPosition

func (term Term) EndPosition() lex.Position

func (Term) FilePath

func (term Term) FilePath() string

func (Term) RegionString

func (term Term) RegionString() string

func (Term) StartPosition

func (term Term) StartPosition() lex.Position

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL