|
using System;
namespace DigitalSamurai.SpellSharp.InputProcessing
{
public abstract partial class Processor<TLexicalElements>
{
public class TokenNode
{
private Func<Token> getNext;
public Token Token { get; private set; }
public TokenNode Previous { get; private set; }
#region public TokenNode Next { get (jit); }
private TokenNode _Next;
public TokenNode Next
{
get
{
if (_Next == null)
{
_Next = Create (getNext, this);
}
return _Next;
}
}
#endregion
private TokenNode (Func<Token> getNext, Token token, TokenNode previous)
{
this.getNext = getNext;
Token = token;
Previous = previous;
}
public static TokenNode Create (Func<Token> getNext)
{
if (getNext == null)
{
throw new ArgumentNullException ("getNext");
}
return Create (getNext, null);
}
private static TokenNode Create (Func<Token> getNext, TokenNode previous)
{
var token = getNext ();
if (token == null)
{
return null;
}
return new TokenNode (getNext, token, previous);
}
}
}
}
|
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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.