Example #1
0
func flatten(r sickle.Rule) sickle.Rule {
	return sickle.Action(r, func(n sickle.Node) sickle.Node {
		var ret []sickle.Node
		flatten_(&ret, n)

		n.Value = ret
		return n
	})
}
Example #2
0
func parseUint(r sickle.Rule) sickle.Rule {
	return notNil(sickle.Action(r, func(n sickle.Node) sickle.Node {
		nodes := n.Value.([]sickle.Node)

		runes := make([]rune, 0, len(nodes))
		for _, node := range nodes {
			runes = append(runes, node.Value.(rune))
		}

		str := string(runes)
		num, err := strconv.ParseInt(str, 10, 64)

		if err == nil {
			n.Value = uint64(num)
		} else {
			n.Value = nil
		}

		return n
	}))
}