progress
This commit is contained in:
parent
16e76d6b31
commit
484dbfc9d9
529 changed files with 113694 additions and 0 deletions
50
AspClassic.Scripting/Runtime/TokenizerService.cs
Normal file
50
AspClassic.Scripting/Runtime/TokenizerService.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace AspClassic.Scripting.Runtime;
|
||||
|
||||
public abstract class TokenizerService
|
||||
{
|
||||
public abstract object CurrentState { get; }
|
||||
|
||||
public abstract SourceLocation CurrentPosition { get; }
|
||||
|
||||
public abstract bool IsRestartable { get; }
|
||||
|
||||
public abstract ErrorSink ErrorSink { get; set; }
|
||||
|
||||
public abstract void Initialize(object state, TextReader sourceReader, SourceUnit sourceUnit, SourceLocation initialLocation);
|
||||
|
||||
public abstract TokenInfo ReadToken();
|
||||
|
||||
public virtual bool SkipToken()
|
||||
{
|
||||
return ReadToken().Category != TokenCategory.EndOfStream;
|
||||
}
|
||||
|
||||
public virtual IEnumerable<TokenInfo> ReadTokens(int countOfChars)
|
||||
{
|
||||
List<TokenInfo> list = new List<TokenInfo>();
|
||||
int index = CurrentPosition.Index;
|
||||
while (CurrentPosition.Index - index < countOfChars)
|
||||
{
|
||||
TokenInfo item = ReadToken();
|
||||
if (item.Category == TokenCategory.EndOfStream)
|
||||
{
|
||||
break;
|
||||
}
|
||||
list.Add(item);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool SkipTokens(int countOfChars)
|
||||
{
|
||||
bool result = false;
|
||||
int index = CurrentPosition.Index;
|
||||
while (CurrentPosition.Index - index < countOfChars && (result = SkipToken()))
|
||||
{
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue