|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using bsn.GoldParser.Semantic;
using System.Collections;
namespace EntityMapper.Semantic
{
public class Sequence<T> : TokenBase, IEnumerable<T> where T : TokenBase
{
private readonly T item;
private readonly Sequence<T> next;
[Rule("<Args> ::= ", typeof(Expression))]
public Sequence() : this(null, null)
{
}
[Rule("<Statements> ::= <Statement>", typeof(Statement))]
[Rule("<Args> ::= <Expression>", typeof(Expression))]
public Sequence(T item) : this(item, null)
{
}
[Rule("<Statements> ::= <Statement> <Statements>", typeof(Statement))]
[Rule("<Args> ::= <Expression> ~',' <Args>", typeof(Expression))]
public Sequence(T item, Sequence<T> next)
{
this.item = item;
this.next = next;
}
#region IEnumerable<T> Members
public IEnumerator<T> GetEnumerator()
{
for (Sequence<T> sequence = this; sequence != null; sequence = sequence.next)
{
if (sequence.item != null)
{
yield return sequence.item;
}
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am always interested in finding innovative ways for building better applications and founded a technology company since 2003. Welcome to exchange any idea with you and if I am not too busy before deadline of projects, I will reply your emails. Also, if you willing to pay for consulting works and customized software development, you can leave me message.