Documentation
¶
Overview ¶
ABOUTME: Consolidated AST types for the unified DOT parser, merging mammoth attractor and dot-editor ASTs. ABOUTME: Defines Graph, Node, Edge, Subgraph, and Diagnostic types with traversal helpers and edge ID assignment.
ABOUTME: Tokenizer/lexer for the DOT DSL that transforms source text into a token stream. ABOUTME: Handles identifiers, keywords, strings with escapes, numbers, booleans, comments, and DOT punctuation.
ABOUTME: Recursive descent parser for the DOT DSL that produces an in-memory Graph model. ABOUTME: Parses digraphs with nodes, edges, attributes, defaults, subgraphs, and chained edge expansion.
ABOUTME: Serializer that converts a Graph AST back to a DOT-formatted source string. ABOUTME: Also provides color-coding for pipeline visualization based on node shape conventions.
Index ¶
- func ApplyColorCoding(g *Graph)
- func Serialize(g *Graph) string
- type Diagnostic
- type Edge
- type Graph
- func (g *Graph) AddEdge(e *Edge)
- func (g *Graph) AddNode(n *Node)
- func (g *Graph) AssignEdgeIDs()
- func (g *Graph) FindExitNode() *Node
- func (g *Graph) FindNode(id string) *Node
- func (g *Graph) FindStartNode() *Node
- func (g *Graph) IncomingEdges(nodeID string) []*Edge
- func (g *Graph) NodeIDs() []string
- func (g *Graph) OutgoingEdges(nodeID string) []*Edge
- type Node
- type Subgraph
- type Token
- type TokenType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyColorCoding ¶
func ApplyColorCoding(g *Graph)
ApplyColorCoding adds fillcolor and style attributes to nodes based on their shape, and colors edges based on their label (success/fail conditions).
Types ¶
type Diagnostic ¶
type Diagnostic struct {
Severity string // "error", "warning", "info"
Message string
NodeID string
EdgeID string
Rule string
}
Diagnostic represents a validation finding associated with a node or edge.
type Edge ¶
Edge represents a directed edge from one node to another with an optional ID and attributes.
type Graph ¶
type Graph struct {
Name string
Nodes map[string]*Node
Edges []*Edge
Attrs map[string]string // graph-level attributes
NodeDefaults map[string]string // node [...] defaults
EdgeDefaults map[string]string // edge [...] defaults
Subgraphs []*Subgraph
}
Graph represents a parsed DOT digraph with its nodes, edges, attributes, and subgraphs.
func Parse ¶
Parse parses the given DOT source string into a Graph. It tokenizes the input, builds the AST, and assigns stable edge IDs before returning.
func (*Graph) AssignEdgeIDs ¶
func (g *Graph) AssignEdgeIDs()
AssignEdgeIDs assigns a unique ID to each edge that does not already have one. Edges that already have a non-empty ID are left unchanged. For edges sharing the same From->To pair, a numeric suffix disambiguates them.
func (*Graph) FindExitNode ¶
FindExitNode returns the exit/terminal node, or nil if not found. Recognized via shape=Msquare, node_type=exit, or type=exit.
func (*Graph) FindStartNode ¶
FindStartNode returns the start node, or nil if not found. Recognized via shape=Mdiamond, node_type=start, or type=start.
func (*Graph) IncomingEdges ¶
IncomingEdges returns all edges terminating at the given node ID.
func (*Graph) OutgoingEdges ¶
OutgoingEdges returns all edges originating from the given node ID.
type Subgraph ¶
type Subgraph struct {
ID string
Name string
Attrs map[string]string // subgraph attributes
NodeIDs []string // node IDs in this subgraph
NodeDefaults map[string]string // scoped node defaults
}
Subgraph represents a subgraph scope containing nodes and scoped defaults.
type TokenType ¶
type TokenType int
TokenType represents the type of a lexical token.
const ( TokenEOF TokenType = iota TokenDigraph // digraph keyword TokenSubgraph // subgraph keyword TokenGraph // graph keyword TokenNode // node keyword TokenEdge // edge keyword TokenLBrace // { TokenRBrace // } TokenLBracket // [ TokenRBracket // ] TokenArrow // -> TokenEquals // = TokenComma // , TokenSemicolon // ; TokenIdentifier // bare identifier TokenString // double-quoted string TokenNumber // integer or float literal TokenBoolean // true or false TokenMinus // - (standalone, not part of -> or number) )