Documentation
¶
Index ¶
- func Parse(s string) (Expression, []ParseError)
- type ArithmeticExpression
- type DataType
- type Expression
- type IntLiteral
- type Node
- type Operator
- type ParseError
- type Parser
- func (p *Parser) ParseExpression() Expression
- func (p *Parser) ParseFactor() Expression
- func (p *Parser) ParseInteger() Expression
- func (p *Parser) ParsePod() Expression
- func (p *Parser) ParseString() Expression
- func (p *Parser) ParseStringOrInteger() Expression
- func (p *Parser) ParseTerm() Expression
- type PodExpression
- type StringLiteral
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
func Parse(s string) (Expression, []ParseError)
Parse parses an expression and returns its AST representation.
Types ¶
type ArithmeticExpression ¶
type ArithmeticExpression struct { LHS Expression Operator Operator RHS Expression Position lexer.Position }
ArithmeticExpression is an expression that contains a +, * operator.
type Expression ¶
type Expression interface { Node // contains filtered or unexported methods }
Expression is a combination of numbers, variables and operators that can be evaluated to a value.
type IntLiteral ¶
IntLiteral is an expression that contains a single constant integer number.
type Node ¶
type Node interface {
// contains filtered or unexported methods
}
Node represents a node in the abstract syntax tree.
type ParseError ¶
ParseError represents an error that occurred during parsing.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
Error returns the string representation of the error.
type Parser ¶
type Parser struct { Errors []ParseError // contains filtered or unexported fields }
func (*Parser) ParseExpression ¶
func (p *Parser) ParseExpression() Expression
ParseExpression parses expressions that might contain any arthimatic operator.
func (*Parser) ParseFactor ¶
func (p *Parser) ParseFactor() Expression
ParseFactor parses a single variable, single constant number or (...some expr...).
func (*Parser) ParseInteger ¶
func (p *Parser) ParseInteger() Expression
func (*Parser) ParsePod ¶
func (p *Parser) ParsePod() Expression
func (*Parser) ParseString ¶
func (p *Parser) ParseString() Expression
func (*Parser) ParseStringOrInteger ¶
func (p *Parser) ParseStringOrInteger() Expression
func (*Parser) ParseTerm ¶
func (p *Parser) ParseTerm() Expression
ParseTerm parses expressions that might contain multipications.
type PodExpression ¶
type PodExpression struct { CPU Expression Memory Expression GPU Expression Position lexer.Position }
PodExpression is an expression that represents a pod.
type StringLiteral ¶
String is an expression that contains a string.