Documentation ¶
Overview ¶
A parser for the DOT grammar.
Index ¶
- Constants
- Variables
- func NewStack() *stack
- func Parse(r io.Reader) (*ast.Graph, error)
- func ParseBytes(dotBytes []byte) (*ast.Graph, error)
- func ParseFile(filename string) (*ast.Graph, error)
- func ParseString(dotString string) (*ast.Graph, error)
- type Accept
- type Action
- type ActionRow
- type ActionTab
- type Attrib
- type GotoRow
- type GotoTab
- type NT
- type Parser
- type ProdTab
- type ProdTabEntry
- type Reduce
- type Scanner
- type Shift
- type State
Constants ¶
View Source
const INITIAL_STACK_SIZE = 100
Variables ¶
View Source
var ProductionsTable = ProdTab{ ProdTabEntry{ "S! : DotGraph ;", "S!", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "DotGraph : Graph { } << ast.NewGraph(ast.GRAPH, ast.FALSE, nil, nil) >> ;", "DotGraph", 3, func(X []Attrib) (Attrib, error) { return ast.NewGraph(ast.GRAPH, ast.FALSE, nil, nil) }, }, ProdTabEntry{ "DotGraph : Strict Graph { } << ast.NewGraph(ast.GRAPH, ast.TRUE, nil, nil) >> ;", "DotGraph", 4, func(X []Attrib) (Attrib, error) { return ast.NewGraph(ast.GRAPH, ast.TRUE, nil, nil) }, }, ProdTabEntry{ "DotGraph : Graph Id { } << ast.NewGraph(ast.GRAPH, ast.FALSE, X[1], nil) >> ;", "DotGraph", 4, func(X []Attrib) (Attrib, error) { return ast.NewGraph(ast.GRAPH, ast.FALSE, X[1], nil) }, }, ProdTabEntry{ "DotGraph : Strict Graph Id { } << ast.NewGraph(ast.GRAPH, ast.TRUE, X[2], nil) >> ;", "DotGraph", 5, func(X []Attrib) (Attrib, error) { return ast.NewGraph(ast.GRAPH, ast.TRUE, X[2], nil) }, }, ProdTabEntry{ "DotGraph : Graph { StmtList } << ast.NewGraph(ast.GRAPH, ast.FALSE, nil, X[2]) >> ;", "DotGraph", 4, func(X []Attrib) (Attrib, error) { return ast.NewGraph(ast.GRAPH, ast.FALSE, nil, X[2]) }, }, ProdTabEntry{ "DotGraph : Graph Id { StmtList } << ast.NewGraph(ast.GRAPH, ast.FALSE, X[1], X[3]) >> ;", "DotGraph", 5, func(X []Attrib) (Attrib, error) { return ast.NewGraph(ast.GRAPH, ast.FALSE, X[1], X[3]) }, }, ProdTabEntry{ "DotGraph : Strict Graph { StmtList } << ast.NewGraph(ast.GRAPH, ast.TRUE, nil, X[3]) >> ;", "DotGraph", 5, func(X []Attrib) (Attrib, error) { return ast.NewGraph(ast.GRAPH, ast.TRUE, nil, X[3]) }, }, ProdTabEntry{ "DotGraph : Strict Graph Id { StmtList } << ast.NewGraph(ast.GRAPH, ast.TRUE, X[2], X[4]) >> ;", "DotGraph", 6, func(X []Attrib) (Attrib, error) { return ast.NewGraph(ast.GRAPH, ast.TRUE, X[2], X[4]) }, }, ProdTabEntry{ "DotGraph : Digraph { } << ast.NewGraph(ast.DIGRAPH, ast.FALSE, nil, nil) >> ;", "DotGraph", 3, func(X []Attrib) (Attrib, error) { return ast.NewGraph(ast.DIGRAPH, ast.FALSE, nil, nil) }, }, ProdTabEntry{ "DotGraph : Strict Digraph { } << ast.NewGraph(ast.DIGRAPH, ast.TRUE, nil, nil) >> ;", "DotGraph", 4, func(X []Attrib) (Attrib, error) { return ast.NewGraph(ast.DIGRAPH, ast.TRUE, nil, nil) }, }, ProdTabEntry{ "DotGraph : Digraph Id { } << ast.NewGraph(ast.DIGRAPH, ast.FALSE, X[1], nil) >> ;", "DotGraph", 4, func(X []Attrib) (Attrib, error) { return ast.NewGraph(ast.DIGRAPH, ast.FALSE, X[1], nil) }, }, ProdTabEntry{ "DotGraph : Strict Digraph Id { } << ast.NewGraph(ast.DIGRAPH, ast.TRUE, X[2], nil) >> ;", "DotGraph", 5, func(X []Attrib) (Attrib, error) { return ast.NewGraph(ast.DIGRAPH, ast.TRUE, X[2], nil) }, }, ProdTabEntry{ "DotGraph : Digraph { StmtList } << ast.NewGraph(ast.DIGRAPH, ast.FALSE, nil, X[2]) >> ;", "DotGraph", 4, func(X []Attrib) (Attrib, error) { return ast.NewGraph(ast.DIGRAPH, ast.FALSE, nil, X[2]) }, }, ProdTabEntry{ "DotGraph : Digraph Id { StmtList } << ast.NewGraph(ast.DIGRAPH, ast.FALSE, X[1], X[3]) >> ;", "DotGraph", 5, func(X []Attrib) (Attrib, error) { return ast.NewGraph(ast.DIGRAPH, ast.FALSE, X[1], X[3]) }, }, ProdTabEntry{ "DotGraph : Strict Digraph { StmtList } << ast.NewGraph(ast.DIGRAPH, ast.TRUE, nil, X[3]) >> ;", "DotGraph", 5, func(X []Attrib) (Attrib, error) { return ast.NewGraph(ast.DIGRAPH, ast.TRUE, nil, X[3]) }, }, ProdTabEntry{ "DotGraph : Strict Digraph Id { StmtList } << ast.NewGraph(ast.DIGRAPH, ast.TRUE, X[2], X[4]) >> ;", "DotGraph", 6, func(X []Attrib) (Attrib, error) { return ast.NewGraph(ast.DIGRAPH, ast.TRUE, X[2], X[4]) }, }, ProdTabEntry{ "StmtList : Stmt1 << ast.NewStmtList(X[0]) >> ;", "StmtList", 1, func(X []Attrib) (Attrib, error) { return ast.NewStmtList(X[0]) }, }, ProdTabEntry{ "StmtList : StmtList Stmt1 << ast.AppendStmtList(X[0], X[1]) >> ;", "StmtList", 2, func(X []Attrib) (Attrib, error) { return ast.AppendStmtList(X[0], X[1]) }, }, ProdTabEntry{ "Stmt1 : Stmt << X[0], nil >> ;", "Stmt1", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Stmt1 : Stmt ; << X[0], nil >> ;", "Stmt1", 2, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Stmt : Id = Id << ast.NewAttr(X[0], X[2]) >> ;", "Stmt", 3, func(X []Attrib) (Attrib, error) { return ast.NewAttr(X[0], X[2]) }, }, ProdTabEntry{ "Stmt : NodeStmt << X[0], nil >> ;", "Stmt", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Stmt : EdgeStmt << X[0], nil >> ;", "Stmt", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Stmt : AttrStmt << X[0], nil >> ;", "Stmt", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Stmt : SubGraphStmt << X[0], nil >> ;", "Stmt", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "AttrStmt : Graph AttrList << ast.NewGraphAttrs(X[1]) >> ;", "AttrStmt", 2, func(X []Attrib) (Attrib, error) { return ast.NewGraphAttrs(X[1]) }, }, ProdTabEntry{ "AttrStmt : Node AttrList << ast.NewNodeAttrs(X[1]) >> ;", "AttrStmt", 2, func(X []Attrib) (Attrib, error) { return ast.NewNodeAttrs(X[1]) }, }, ProdTabEntry{ "AttrStmt : Edge AttrList << ast.NewEdgeAttrs(X[1]) >> ;", "AttrStmt", 2, func(X []Attrib) (Attrib, error) { return ast.NewEdgeAttrs(X[1]) }, }, ProdTabEntry{ "AttrList : [ ] << ast.NewAttrList(nil) >> ;", "AttrList", 2, func(X []Attrib) (Attrib, error) { return ast.NewAttrList(nil) }, }, ProdTabEntry{ "AttrList : [ AList ] << ast.NewAttrList(X[1]) >> ;", "AttrList", 3, func(X []Attrib) (Attrib, error) { return ast.NewAttrList(X[1]) }, }, ProdTabEntry{ "AttrList : AttrList [ ] << ast.AppendAttrList(X[0], nil) >> ;", "AttrList", 3, func(X []Attrib) (Attrib, error) { return ast.AppendAttrList(X[0], nil) }, }, ProdTabEntry{ "AttrList : AttrList [ AList ] << ast.AppendAttrList(X[0], X[2]) >> ;", "AttrList", 4, func(X []Attrib) (Attrib, error) { return ast.AppendAttrList(X[0], X[2]) }, }, ProdTabEntry{ "AList : Attr << ast.NewAList(X[0]) >> ;", "AList", 1, func(X []Attrib) (Attrib, error) { return ast.NewAList(X[0]) }, }, ProdTabEntry{ "AList : AList Attr << ast.AppendAList(X[0], X[1]) >> ;", "AList", 2, func(X []Attrib) (Attrib, error) { return ast.AppendAList(X[0], X[1]) }, }, ProdTabEntry{ "AList : AList , Attr << ast.AppendAList(X[0], X[2]) >> ;", "AList", 3, func(X []Attrib) (Attrib, error) { return ast.AppendAList(X[0], X[2]) }, }, ProdTabEntry{ "Attr : Id << ast.NewAttr(X[0], nil) >> ;", "Attr", 1, func(X []Attrib) (Attrib, error) { return ast.NewAttr(X[0], nil) }, }, ProdTabEntry{ "Attr : Id = Id << ast.NewAttr(X[0], X[2]) >> ;", "Attr", 3, func(X []Attrib) (Attrib, error) { return ast.NewAttr(X[0], X[2]) }, }, ProdTabEntry{ "EdgeStmt : NodeId EdgeRHS << ast.NewEdgeStmt(X[0], X[1], nil) >> ;", "EdgeStmt", 2, func(X []Attrib) (Attrib, error) { return ast.NewEdgeStmt(X[0], X[1], nil) }, }, ProdTabEntry{ "EdgeStmt : NodeId EdgeRHS AttrList << ast.NewEdgeStmt(X[0], X[1], X[2]) >> ;", "EdgeStmt", 3, func(X []Attrib) (Attrib, error) { return ast.NewEdgeStmt(X[0], X[1], X[2]) }, }, ProdTabEntry{ "EdgeStmt : SubGraphStmt EdgeRHS << ast.NewEdgeStmt(X[0], X[1], nil) >> ;", "EdgeStmt", 2, func(X []Attrib) (Attrib, error) { return ast.NewEdgeStmt(X[0], X[1], nil) }, }, ProdTabEntry{ "EdgeStmt : SubGraphStmt EdgeRHS AttrList << ast.NewEdgeStmt(X[0], X[1], X[2]) >> ;", "EdgeStmt", 3, func(X []Attrib) (Attrib, error) { return ast.NewEdgeStmt(X[0], X[1], X[2]) }, }, ProdTabEntry{ "EdgeRHS : EdgeOp NodeId << ast.NewEdgeRHS(X[0], X[1]) >> ;", "EdgeRHS", 2, func(X []Attrib) (Attrib, error) { return ast.NewEdgeRHS(X[0], X[1]) }, }, ProdTabEntry{ "EdgeRHS : EdgeOp SubGraphStmt << ast.NewEdgeRHS(X[0], X[1]) >> ;", "EdgeRHS", 2, func(X []Attrib) (Attrib, error) { return ast.NewEdgeRHS(X[0], X[1]) }, }, ProdTabEntry{ "EdgeRHS : EdgeRHS EdgeOp NodeId << ast.AppendEdgeRHS(X[0], X[1], X[2]) >> ;", "EdgeRHS", 3, func(X []Attrib) (Attrib, error) { return ast.AppendEdgeRHS(X[0], X[1], X[2]) }, }, ProdTabEntry{ "EdgeRHS : EdgeRHS EdgeOp SubGraphStmt << ast.AppendEdgeRHS(X[0], X[1], X[2]) >> ;", "EdgeRHS", 3, func(X []Attrib) (Attrib, error) { return ast.AppendEdgeRHS(X[0], X[1], X[2]) }, }, ProdTabEntry{ "NodeStmt : NodeId << ast.NewNodeStmt(X[0], nil) >> ;", "NodeStmt", 1, func(X []Attrib) (Attrib, error) { return ast.NewNodeStmt(X[0], nil) }, }, ProdTabEntry{ "NodeStmt : NodeId AttrList << ast.NewNodeStmt(X[0], X[1]) >> ;", "NodeStmt", 2, func(X []Attrib) (Attrib, error) { return ast.NewNodeStmt(X[0], X[1]) }, }, ProdTabEntry{ "NodeId : Id << ast.NewNodeId(X[0], nil) >> ;", "NodeId", 1, func(X []Attrib) (Attrib, error) { return ast.NewNodeId(X[0], nil) }, }, ProdTabEntry{ "NodeId : Id Port << ast.NewNodeId(X[0], X[1]) >> ;", "NodeId", 2, func(X []Attrib) (Attrib, error) { return ast.NewNodeId(X[0], X[1]) }, }, ProdTabEntry{ "Port : : Id << ast.NewPort(X[1], nil) >> ;", "Port", 2, func(X []Attrib) (Attrib, error) { return ast.NewPort(X[1], nil) }, }, ProdTabEntry{ "Port : : Id : Id << ast.NewPort(X[1], X[3]) >> ;", "Port", 4, func(X []Attrib) (Attrib, error) { return ast.NewPort(X[1], X[3]) }, }, ProdTabEntry{ "SubGraphStmt : { StmtList } << ast.NewSubGraph(nil, X[1]) >> ;", "SubGraphStmt", 3, func(X []Attrib) (Attrib, error) { return ast.NewSubGraph(nil, X[1]) }, }, ProdTabEntry{ "SubGraphStmt : Subgraph { StmtList } << ast.NewSubGraph(nil, X[2]) >> ;", "SubGraphStmt", 4, func(X []Attrib) (Attrib, error) { return ast.NewSubGraph(nil, X[2]) }, }, ProdTabEntry{ "SubGraphStmt : Subgraph Id { StmtList } << ast.NewSubGraph(X[1], X[3]) >> ;", "SubGraphStmt", 5, func(X []Attrib) (Attrib, error) { return ast.NewSubGraph(X[1], X[3]) }, }, ProdTabEntry{ "EdgeOp : -> << ast.DIRECTED, nil >> ;", "EdgeOp", 1, func(X []Attrib) (Attrib, error) { return ast.DIRECTED, nil }, }, ProdTabEntry{ "EdgeOp : -- << ast.UNDIRECTED, nil >> ;", "EdgeOp", 1, func(X []Attrib) (Attrib, error) { return ast.UNDIRECTED, nil }, }, ProdTabEntry{ "Graph : graph << X[0], nil >> ;", "Graph", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Graph : Graph << X[0], nil >> ;", "Graph", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Graph : GRAPH << X[0], nil >> ;", "Graph", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Strict : strict << X[0], nil >> ;", "Strict", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Strict : Strict << X[0], nil >> ;", "Strict", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Strict : STRICT << X[0], nil >> ;", "Strict", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Digraph : digraph << X[0], nil >> ;", "Digraph", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Digraph : Digraph << X[0], nil >> ;", "Digraph", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Digraph : DiGraph << X[0], nil >> ;", "Digraph", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Digraph : DIGRAPH << X[0], nil >> ;", "Digraph", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Node : node << X[0], nil >> ;", "Node", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Node : Node << X[0], nil >> ;", "Node", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Node : NODE << X[0], nil >> ;", "Node", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Edge : edge << X[0], nil >> ;", "Edge", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Edge : Edge << X[0], nil >> ;", "Edge", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Edge : EDGE << X[0], nil >> ;", "Edge", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Subgraph : subgraph << X[0], nil >> ;", "Subgraph", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Subgraph : Subgraph << X[0], nil >> ;", "Subgraph", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Subgraph : SubGraph << X[0], nil >> ;", "Subgraph", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Subgraph : SUBGRAPH << X[0], nil >> ;", "Subgraph", 1, func(X []Attrib) (Attrib, error) { return X[0], nil }, }, ProdTabEntry{ "Id : id << ast.NewId(X[0]) >> ;", "Id", 1, func(X []Attrib) (Attrib, error) { return ast.NewId(X[0]) }, }, ProdTabEntry{ "Id : string_lit << ast.NewId(X[0]) >> ;", "Id", 1, func(X []Attrib) (Attrib, error) { return ast.NewId(X[0]) }, }, ProdTabEntry{ "Id : int_lit << ast.NewId(X[0]) >> ;", "Id", 1, func(X []Attrib) (Attrib, error) { return ast.NewId(X[0]) }, }, ProdTabEntry{ "Id : float_lit << ast.NewId(X[0]) >> ;", "Id", 1, func(X []Attrib) (Attrib, error) { return ast.NewId(X[0]) }, }, ProdTabEntry{ "Id : html_lit << ast.NewId(X[0]) >> ;", "Id", 1, func(X []Attrib) (Attrib, error) { return ast.NewId(X[0]) }, }, }
Functions ¶
func Parse ¶
Parses a reader which contains a DOT string and outputs the abstract syntax tree representing the graph.
func ParseBytes ¶
Parses the bytes representing a DOT string and outputs the abstract syntax tree representing the graph.
Types ¶
type ProdTab ¶
type ProdTab []ProdTabEntry
type ProdTabEntry ¶
Click to show internal directories.
Click to hide internal directories.