| 1 | package parser |
| 2 | |
| 3 | import "fmt" |
| 4 | |
| 5 | type NODETYPE string |
| 6 | |
| 7 | const ( |
| 8 | LITERAL NODETYPE = "LITERAL" |
| 9 | RESOURCELITERAL = "RESOURCE" |
| 10 | NODEIDLITERAL = "NodeIDLiteral" |
| 11 | BLANK = "BNODE" |
| 12 | IRI = "IRI" |
| 13 | ) |
| 14 | |
| 15 | type Node struct { |
| 16 | NodeType NODETYPE |
| 17 | ID string |
| 18 | } |
| 19 | |
| 20 | func (node *Node) String() string { |
| 21 | return fmt.Sprintf("(%v, %v)", node.NodeType, node.ID) |
| 22 | } |
| 23 | |
| 24 | type BlankNodeGetter struct { |
| 25 | lastid int |
| 26 | } |
| 27 | |
| 28 | func (getter *BlankNodeGetter) Get() Node { |
| 29 | getter.lastid += 1 |
| 30 | return Node{ |
| 31 | NodeType: BLANK, |
| 32 | ID: fmt.Sprintf("N%v", getter.lastid), |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | func (getter *BlankNodeGetter) GetFromId(id string) Node { |
| 37 | return Node{ |
| 38 | NodeType: NODEIDLITERAL, |
| 39 | ID: fmt.Sprintf("N%v", id), |
| 40 | } |
| 41 | } |