this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 65 lines 1.3 kB view raw
1{ 2package parser 3 4type Attribute struct{ 5 Type string 6 Value string 7} 8 9type AddCommand struct { 10 Description string 11 Attributes []Attribute 12} 13 14func MakeAdd(description interface{}, attributes interface{}) (*AddCommand, error) { 15 attribs, _ := attributes.([]Attribute) 16 return &AddCommand{Description: description.(string), Attributes: attribs}, nil 17} 18 19func MakeAttributes(attributes interface{}) ([]Attribute, error) { 20 ats := attributes.([]interface{}) 21 22 attribs := make([]Attribute, 0) 23 for _, p := range ats { 24 pa := p.([]interface{}) 25 px := pa[1:] 26 for _, pi := range px { 27 ps := pi.(*Attribute) 28 attribs = append(attribs, *ps) 29 } 30 } 31 return attribs, nil 32} 33 34} 35 36Add <- desc:Description attributes:Attributes? { 37 return MakeAdd(desc, attributes) 38} 39 40Description <- (!Attribute .)+ { 41 return string(c.text), nil 42} 43 44Attributes <- attributes:(_ Attribute)* { 45 return MakeAttributes(attributes) 46} 47Attribute <- Project / Priority / Tag 48 49Project <- ("pro:" / "project:") value:Word { 50 return &Attribute{Type:"project", Value:value.(string)}, nil 51} 52Priority <- "priority:" value:[HML] { 53 return &Attribute{Type:"priority", Value:value.(string)}, nil 54} 55 56Tag <- "+" value:Word { 57 return &Attribute{Type:"tag", Value:value.(string)}, nil 58} 59 60Word <- [a-zA-Z0-9_-]+ { 61 return string(c.text), nil 62} 63_ <- [ \t]* 64 65EOF = !.