Documentation
¶
Index ¶
- Variables
- func ExpectedExpression(v Directive) (err error)
- func Format(ds []Directive) string
- func UnexpectedExpression(v Directive) (err error)
- func UnknownDirective(v Directive) error
- type ArgParser
- type BlockParser
- type BooleanParser
- type CallParser
- type Delegate
- type Directive
- type DirectiveParser
- type EmptyOperand
- type ExpressionParser
- type ExpressionState
- type ExpressionStateFactory
- type FieldParser
- type IdentParser
- type KeyParser
- type LeftParser
- type NumParser
- type OperandParser
- type OperandState
- type OperatorParser
- type PipeParser
- type QuoteParser
- type RightParser
- type Section
- type SeriesParser
- type State
- type SubdirParser
- type TemplateParser
Constants ¶
This section is empty.
Variables ¶
var OnExit = charm.OnExit
var Parallel = charm.Parallel
var Parse = charm.ParseEof
var RunStep = charm.RunStep
var Self = charm.Self
var Statement = charm.Statement
var Step = charm.Step
Functions ¶
func ExpectedExpression ¶
func UnexpectedExpression ¶
func UnknownDirective ¶
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.
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 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}
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 ¶
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 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 ¶
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) 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 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
Source Files
¶
- argParser.go
- blockParser.go
- callParser.go
- chart.go
- directive.go
- directiveParser.go
- emptyOperand.go
- expressionParser.go
- fieldParser.go
- identParser.go
- keyParser.go
- leftParser.go
- operandParser.go
- operatorParser.go
- pipeParser.go
- rightParser.go
- runeTypes.go
- section.go
- seriesParser.go
- subdirParser.go
- templateParser.go