func (ds *Definitions) Generator() DefinitionsGenerator {
	return DefinitionsGenerator{
		current: ds,
		iter:    0,
		length:  ds.Len(),
	}
}
Generator returns a "Generator" type for this list, allowing for much more efficient iteration
over items within this linked list than using ForEach, though ForEach may still be more
convenient, because ForEach is a high order function, it's slower.
package ast
type Arguments struct {
	Data Argument
	next *Arguments
	pos  int
}
func (as *Arguments) Add(data Argument) *Arguments {
	var pos int
	if as != nil {
		pos = as.pos + 1
	}
	return &Arguments{
		Data: data,
		next: as,
		pos:  pos,
	}
}
func (as *Arguments) ForEach(fn func(a Argument, i int)) {
	if as == nil {
		return
	}
	iter := 0
	current := as
	for {
		fn(current.Data, iter)
		if current.next == nil {
			break
		}
		iter++
		current = current.next
	}
}
type ArgumentsGenerator struct {
	original *Arguments
	current  *Arguments
	iter     int
	length   int
}
func (g *ArgumentsGenerator) Next() (Argument, int) {
	if g.current == nil {
		return Argument{}, -1
	}
	retv := g.current.Data
	reti := g.iter
	g.current = g.current.next
	g.iter++
	return retv, reti
}
func (g *ArgumentsGenerator) Reset() {
	g.current = g.original
	g.iter = 0
}
func (as *Arguments) Generator() ArgumentsGenerator {
	return ArgumentsGenerator{
		current: as,
		iter:    0,
		length:  as.Len(),
	}
}
func (as *Arguments) Insert(a Argument, pos int) *Arguments {
	if pos >= as.Len() || as == nil {
		return as.Add(a)
	}
	if pos < 0 {
		pos = 0
	}
	mid := as
	for mid.pos != pos {
		mid = mid.next
	}
	bot := mid.next
	mid.next = nil
	as.pos -= mid.pos
	bot = bot.Add(a)
	as.Join(bot)
	return as
}
func (as *Arguments) Join(otherList *Arguments) {
	if as == nil {
		return
	}
	pos := as.Len() + otherList.Len() - 1
	last := as
	for as != nil {
		as.pos = pos
		pos--
		last = as
		as = as.next
	}
	last.next = otherList
}
func (as *Arguments) Len() int {
	if as == nil {
		return 0
	}
	return as.pos + 1
}
func (as *Arguments) Reverse() *Arguments {
	current := as
	var prev *Arguments
	var pos int
	for current != nil {
		current.pos = pos
		pos++
		next := current.next
		current.next = prev
		prev = current
		current = next
	}
	return prev
}
func ArgumentsFromSlice(sl []Argument) *Arguments {
	var list *Arguments
	for _, v := range sl {
		list = list.Add(v)
	}
	return list.Reverse()
}
type Definitions struct {
	Data Definition
	next *Definitions
	pos  int
}
func (ds *Definitions) Add(data Definition) *Definitions {
	var pos int
	if ds != nil {
		pos = ds.pos + 1
	}
	return &Definitions{
		Data: data,
		next: ds,
		pos:  pos,
	}
}
func (ds *Definitions) ForEach(fn func(d Definition, i int)) {
	if ds == nil {
		return
	}
	iter := 0
	current := ds
	for {
		fn(current.Data, iter)
		if current.next == nil {
			break
		}
		iter++
		current = current.next
	}
}
type DefinitionsGenerator struct {
	original *Definitions
	current  *Definitions
	iter     int
	length   int
}
func (g *DefinitionsGenerator) Next() (Definition, int) {
	if g.current == nil {
		return Definition{}, -1
	}
	retv := g.current.Data
	reti := g.iter
	g.current = g.current.next
	g.iter++
	return retv, reti
}
func (g *DefinitionsGenerator) Reset() {
	g.current = g.original
	g.iter = 0
}