Documentation
¶
Overview ¶
Package gochart_lang is the frontend for what we can "gochart_lang", which is a custom spec language to describe gocharts.
Package gochart_lang holds the logic to parse a gochart from a file/text into our intermediate representation, which can then be used by a backend.
Index ¶
- func NewGochartLangFrontend(opts ...option.Option) (*gochartLangFrontend, error)
- func WithVerbose(verbose bool) option.Option
- type ASTNode
- type ASTNodeComment
- type ASTNodeGochart
- type ASTNodeOption
- type ASTNodeRoot
- type ASTNodeState
- type ASTNodeStateCapture
- type ASTNodeStateReaction
- type ASTNodeStateTransition
- type ASTNodeTrigger
- type Options
- type Parser
- type ScanError
- type Scanner
- type Token
- type TokenIdentifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewGochartLangFrontend ¶
NewFrontend returns a frontend capable of parting the gochart language.
func WithVerbose ¶
Types ¶
type ASTNode ¶
type ASTNode interface { // AppendNode is a convenient function to be able to append nodes into a node and have correct // tracking of the internal indices. AppendNode(node ASTNode) }
ASTNode is the common interface for all the nodes within our Abstract Syntax Tree.
type ASTNodeComment ¶
type ASTNodeComment struct {
// contains filtered or unexported fields
}
func (*ASTNodeComment) AppendNode ¶
func (n *ASTNodeComment) AppendNode(node ASTNode)
type ASTNodeGochart ¶
type ASTNodeGochart struct { Name string Options []*ASTNodeOption Triggers []*ASTNodeTrigger Root *ASTNodeState States []*ASTNodeState // These comments will be outside the gochart, as inside comments will be inside of the root // state comment tracking. Comments []*ASTNodeComment // contains filtered or unexported fields }
func (*ASTNodeGochart) AppendNode ¶
func (n *ASTNodeGochart) AppendNode(node ASTNode)
func (*ASTNodeGochart) NonCommentEntryCount ¶
func (n *ASTNodeGochart) NonCommentEntryCount() int
type ASTNodeOption ¶
type ASTNodeOption struct { Name string ValueKind common.OptionValueKind Value string // contains filtered or unexported fields }
func (*ASTNodeOption) AppendNode ¶
func (n *ASTNodeOption) AppendNode(node ASTNode)
type ASTNodeRoot ¶
type ASTNodeRoot struct {
// contains filtered or unexported fields
}
func (*ASTNodeRoot) AppendNode ¶
func (n *ASTNodeRoot) AppendNode(node ASTNode)
type ASTNodeState ¶
type ASTNodeState struct { Name string ParentName string Default bool Options []*ASTNodeOption EnterReactions []*ASTNodeStateReaction ExitReactions []*ASTNodeStateReaction Transitions []*ASTNodeStateTransition Captures []*ASTNodeStateCapture Children []*ASTNodeState Comments []*ASTNodeComment // contains filtered or unexported fields }
func (*ASTNodeState) AppendNode ¶
func (n *ASTNodeState) AppendNode(node ASTNode)
func (*ASTNodeState) NonCommentEntryCount ¶
func (n *ASTNodeState) NonCommentEntryCount() int
type ASTNodeStateCapture ¶
type ASTNodeStateCapture struct { Trigger string Condition string // contains filtered or unexported fields }
func (*ASTNodeStateCapture) AppendNode ¶
func (n *ASTNodeStateCapture) AppendNode(node ASTNode)
type ASTNodeStateReaction ¶
type ASTNodeStateReaction struct { Trigger string // contains filtered or unexported fields }
func (*ASTNodeStateReaction) AppendNode ¶
func (n *ASTNodeStateReaction) AppendNode(node ASTNode)
func (*ASTNodeStateReaction) IsEnterReaction ¶
func (n *ASTNodeStateReaction) IsEnterReaction() bool
func (*ASTNodeStateReaction) IsExitReaction ¶
func (n *ASTNodeStateReaction) IsExitReaction() bool
type ASTNodeStateTransition ¶
type ASTNodeStateTransition struct { Trigger string TargetState string Condition string Action string // contains filtered or unexported fields }
func (*ASTNodeStateTransition) AppendNode ¶
func (n *ASTNodeStateTransition) AppendNode(node ASTNode)
type ASTNodeTrigger ¶
type ASTNodeTrigger struct { Name string ArgsString string // contains filtered or unexported fields }
func (*ASTNodeTrigger) AppendNode ¶
func (n *ASTNodeTrigger) AppendNode(node ASTNode)
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser is an object capable of taking tokens of the gochart_lang language and parse it against the grammer, returning an Abstract Syntax Tree (AST).
type ScanError ¶
type ScanError struct {
ErrorToken Token
}
ScanError is a custom error associated with scanning.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner is an object capable of taking in a reader and scanning over to create a valid representation of our gochart grammar.
func NewScanner ¶
func NewScanner() *Scanner
NewScanner returns a scanner ready to process input. Here all the keywords are defined.
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
Token represents a single token that the scanner outputs to the parser, which holds associated information such as the associated string literal and line/char information.
func NewToken ¶
func NewToken(id TokenIdentifier) Token
type TokenIdentifier ¶
type TokenIdentifier int
TokenIdentifier represents a single token of our parser. IMPORTANT: If you add another token, remember to add it to the String() function at the end
const ( Token_Invalid TokenIdentifier = iota // Single character tokens. Token_LeftParen // '(' Token_RightParen // ')' Token_LeftBrace // '{' Token_RightBrace // '}' Token_LeftBracket // '[' Token_RightBracket // ']' Token_LeftAngleBracket // '<' Token_RightAngleBracket // '>' Token_Equal // '=' Token_Comma // ',' Token_Boolean // 'true' | 'false' // literals. Token_String // "content" Token_Integer // 123456 // Keywords Token_KeywordIf // 'if' Token_KeywordDo // 'do' Token_KeywordGochart // 'gochart' Token_KeywordState // 'state' Token_KeywordEnter // 'enter' Token_KeywordExit // 'exit' Token_KeywordTransition // 'transition' Token_KeywordTrigger // 'trigger' Token_KeywordCapture // 'capture' Token_KeywordNull // 'null' // Represents the argument string of a trigger. Token_TriggerArgs // Represents abstract code to be executed. // Normally part of a conditional (if) or executive (do) clauses. Token_Code Token_Identifier // Any string that is not quoted. Token_Comment // A code comment. Token_EOF )
func (TokenIdentifier) String ¶
func (t TokenIdentifier) String() string