chart

package
v0.24.5 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OnExit = charm.OnExit
View Source
var Parallel = charm.Parallel
View Source
var Parse = charm.ParseEof
View Source
var RunStep = charm.RunStep
View Source
var Self = charm.Self
View Source
var Statement = charm.Statement
View Source
var Step = charm.Step

Functions

func ExpectedExpression

func ExpectedExpression(v Directive) (err error)

func Format

func Format(ds []Directive) string

Format a string from slice of directives.

func UnexpectedExpression

func UnexpectedExpression(v Directive) (err error)

func UnknownDirective

func UnknownDirective(v Directive) error

Types

type ArgParser

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

ArgParser reads arguments specified by a function call.

func MakeArgParser

func MakeArgParser(f ExpressionStateFactory) ArgParser

MakeArgParser using a factory so that tests can mock out recursion; Normally, arguments can be any operand -- or any directive.

func (*ArgParser) GetArguments

func (p *ArgParser) GetArguments() (postfix.Expression, int, error)

GetArguments returns both the expression, and the number of separated arguments.

func (*ArgParser) GetExpression

func (p *ArgParser) GetExpression() (postfix.Expression, error)

GetExpression see also GetArguments.

func (*ArgParser) NewRune

func (p *ArgParser) NewRune(r rune) State

NewRune starts with the first character of an argument; each arg is parsed via ArgParser.

func (*ArgParser) String

func (p *ArgParser) String() string

type BlockParser

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

BlockParser reads alternating text and directives. It is used for tests of Left and RightParser.

func (*BlockParser) GetDirectives

func (p *BlockParser) GetDirectives() ([]Directive, error)

GetDirectives or error

func (*BlockParser) NewRune

func (p *BlockParser) NewRune(r rune) State

NewRune starts with the first character of a string.

func (*BlockParser) String

func (p *BlockParser) String() string

type BooleanParser

type BooleanParser struct{ IdentParser }

fix: apparently this is handling more than just bool if it doesnt read a whole ident, or if it tries to return error ( instead of a nil function ) then various tests fail ( ex. {cycle}a{end} )

func (*BooleanParser) GetOperand

func (p *BooleanParser) GetOperand() (ret postfix.Function, err error)

type CallParser

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

CallParser reads a single function call and its arguments.

func MakeCallParser

func MakeCallParser(a int, f ExpressionStateFactory) CallParser

func (*CallParser) GetExpression

func (p *CallParser) GetExpression() (ret postfix.Expression, err error)

func (*CallParser) NewRune

func (p *CallParser) NewRune(r rune) State

NewRune starts with the first character past the bar.

func (*CallParser) String

func (p *CallParser) String() string

type Delegate

type Delegate func(*TemplateParser, Directive) (State, error)

type Directive

type Directive struct {
	Key string
	postfix.Expression
}

Directive containing the parsed content of a types. Both or either of the key and the expression can be empty. ex. {elseIf b = 5}

func (Directive) String

func (d Directive) String() (ret string)

String of a directive in the format: {key:expression} or {expression}

type DirectiveParser

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

DirectiveParser reads a key-expression pair where both elements are optional. ( compare to KeyParser which always has a key, followed by an optional expression. )

func (*DirectiveParser) GetDirective

func (p *DirectiveParser) GetDirective() (Directive, error)

func (*DirectiveParser) NewRune

func (p *DirectiveParser) NewRune(r rune) State

rune at the start of a directive's content.

func (*DirectiveParser) String

func (p *DirectiveParser) String() string

type EmptyOperand

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

implements OperandState by returning nothing

func (*EmptyOperand) GetOperand

func (p *EmptyOperand) GetOperand() (postfix.Function, error)

func (*EmptyOperand) NewRune

func (p *EmptyOperand) NewRune(r rune) State

func (*EmptyOperand) String

func (p *EmptyOperand) String() string

type ExpressionParser

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

ExpressionParser reads either a single call or a series of operations.

func (*ExpressionParser) GetExpression

func (p *ExpressionParser) GetExpression() (postfix.Expression, error)

func (*ExpressionParser) NewRune

func (p *ExpressionParser) NewRune(r rune) State

NewRune starts with the first character of a directive's content.

func (*ExpressionParser) String

func (p *ExpressionParser) String() string

type ExpressionState

type ExpressionState interface {
	State
	GetExpression() (postfix.Expression, error)
}

type ExpressionStateFactory

type ExpressionStateFactory interface {
	NewExpressionState() ExpressionState
}

ExpressionStateFactory is used for testing with mocks. when no factory is specified, the pipe or subdirective parser is used depending on context.

type FieldParser

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

FieldParser reads identifiers separated by dots, implements OperandState.

func (*FieldParser) GetFields

func (p *FieldParser) GetFields() (ret []string, err error)

GetFields returns an array of parsed identifiers.

func (*FieldParser) GetOperand

func (p *FieldParser) GetOperand() (ret postfix.Function, err error)

func (*FieldParser) NewRune

func (p *FieldParser) NewRune(r rune) (ret State)

NewRune starts on the dot of a new field.

func (*FieldParser) String

func (p *FieldParser) String() string

type IdentParser

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

func (*IdentParser) Identifier

func (p *IdentParser) Identifier() string

func (*IdentParser) NewRune

func (p *IdentParser) NewRune(r rune) (ret State)

first character of the identifier

func (*IdentParser) Reset

func (p *IdentParser) Reset() string

func (*IdentParser) String

func (p *IdentParser) String() string

type KeyParser

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

KeyParser reads a key and its optional following expression.

func (*KeyParser) GetDirective

func (p *KeyParser) GetDirective() (ret Directive, err error)

func (*KeyParser) NewRune

func (p *KeyParser) NewRune(r rune) (ret State)

NewRune starts on the first letter of the key.

func (*KeyParser) String

func (p *KeyParser) String() string

type LeftParser

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

LeftParser reads text, ending just after the opening of a directive. It deals with leading trim: "...{~".

func (*LeftParser) GetText

func (p *LeftParser) GetText() string

func (*LeftParser) NewRune

func (p *LeftParser) NewRune(r rune) (ret State)

NewRune starts with the first character of a string, ends just after the opening bracket of a directive.

func (*LeftParser) String

func (p *LeftParser) String() string

type NumParser

type NumParser struct {
	charmed.NumParser
}

func (*NumParser) GetOperand

func (p *NumParser) GetOperand() (ret postfix.Function, err error)

func (*NumParser) NewRune

func (p *NumParser) NewRune(r rune) charm.State

type OperandParser

type OperandParser struct {
	OperandState
}

func (*OperandParser) GetExpression

func (p *OperandParser) GetExpression() (ret postfix.Expression, err error)

func (*OperandParser) NewRune

func (p *OperandParser) NewRune(r rune) (ret State)

func (*OperandParser) String

func (p *OperandParser) String() string

type OperandState

type OperandState interface {
	State
	GetOperand() (postfix.Function, error)
}

OperandState reads a single number, reference, or quote.

type OperatorParser

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

OperatorParser reads a binary operator.

func (*OperatorParser) GetOperator

func (p *OperatorParser) GetOperator() (ret types.Operator, err error)

GetOperator representing the result of parsing, can be -1 if nothing was matched.

func (*OperatorParser) NewRune

func (p *OperatorParser) NewRune(r rune) (ret State)

NewRune starts on the first character of the operator; unless we find an exact match, we are done with the state.

func (*OperatorParser) String

func (p *OperatorParser) String() string

type PipeParser

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

Pipe parser reads an expression followed by an optional series of functions. Expression | Function | ...

func (*PipeParser) GetExpression

func (p *PipeParser) GetExpression() (postfix.Expression, error)

func (*PipeParser) NewRune

func (p *PipeParser) NewRune(r rune) State

NewRune starts on the first character of an operand or opening sub-phrase.

func (*PipeParser) String

func (p *PipeParser) String() string

type QuoteParser

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

func (*QuoteParser) GetOperand

func (p *QuoteParser) GetOperand() (ret postfix.Function, err error)

func (*QuoteParser) NewRune

func (p *QuoteParser) NewRune(r rune) (ret State)

NewRune starts with the leading quote mark; it finishes just after the matching quote mark.

type RightParser

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

RightParser reads the content of a directive, ending just after the closing brace and any trimed whitespace. "~}...".

func (*RightParser) GetDirective

func (p *RightParser) GetDirective() (Directive, error)

func (*RightParser) NewRune

func (p *RightParser) NewRune(r rune) State

NewRune starts on the first rune of directive content, after the opening bracket, trim, and leading whitespace.

func (*RightParser) String

func (p *RightParser) String() string

type Section

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

Section joins a bunch of separate postfix expressions into a single operation. if it only has one expression, thats all thats returned; otherwise a span does.

func (*Section) AddText

func (x *Section) AddText(t string)

Add the passed text as an expression to the current span.

func (*Section) Append

func (x *Section) Append(xs postfix.Expression)

Append the expression to the current span.

func (Section) Reduce

func (x Section) Reduce(kind types.BuiltinType) (ret postfix.Expression)

Reduce returns the summation of the current span.

type SeriesParser

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

SeriesParser reads a sequence of operand and operator phrases.

func (*SeriesParser) GetExpression

func (p *SeriesParser) GetExpression() (ret postfix.Expression, err error)

func (*SeriesParser) NewRune

func (p *SeriesParser) NewRune(r rune) State

NewRune starts on the first character of an operand or opening sub-phrase.

func (*SeriesParser) String

func (p *SeriesParser) String() string

type State

type State = charm.State

func Finished

func Finished(reason string) State

for the very next rune, return nil ( unhandled ) it may be the end of parsing, or some parent state might be taking over from here on out.

type SubdirParser

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

SubdirParser reads a single operand or sub bracket pipeline. "a" -or- "{a!|...}"

func (*SubdirParser) GetExpression

func (p *SubdirParser) GetExpression() (postfix.Expression, error)

func (*SubdirParser) NewRune

func (p *SubdirParser) NewRune(r rune) (ret State)

func (*SubdirParser) String

func (p *SubdirParser) String() string

type TemplateParser

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

func MakeSubParser

func MakeSubParser(d Delegate, xs postfix.Expression) TemplateParser

func MakeTemplateParser

func MakeTemplateParser() TemplateParser

func (*TemplateParser) GetExpression

func (p *TemplateParser) GetExpression() (ret postfix.Expression, err error)

func (*TemplateParser) NewRune

func (p *TemplateParser) NewRune(r rune) State

words { directive } words { directive }

func (*TemplateParser) String

func (p *TemplateParser) String() string

Jump to

Keyboard shortcuts

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