2018-01-10 19:49:32 +00:00
|
|
|
|
namespace UglyToad.PdfPig.Tokenization
|
2017-11-13 23:48:25 +00:00
|
|
|
|
{
|
|
|
|
|
|
using System.Text;
|
2020-01-04 16:38:18 +00:00
|
|
|
|
using Core;
|
2017-11-13 23:48:25 +00:00
|
|
|
|
using Tokens;
|
|
|
|
|
|
|
2018-01-03 20:15:25 +00:00
|
|
|
|
internal class CommentTokenizer : ITokenizer
|
2017-11-13 23:48:25 +00:00
|
|
|
|
{
|
|
|
|
|
|
public bool ReadsNextByte { get; } = true;
|
|
|
|
|
|
|
|
|
|
|
|
public bool TryTokenize(byte currentByte, IInputBytes inputBytes, out IToken token)
|
|
|
|
|
|
{
|
|
|
|
|
|
token = null;
|
|
|
|
|
|
|
|
|
|
|
|
if (currentByte != '%')
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var builder = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
while (inputBytes.MoveNext() && !ReadHelper.IsEndOfLine(inputBytes.CurrentByte))
|
|
|
|
|
|
{
|
|
|
|
|
|
builder.Append((char) inputBytes.CurrentByte);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
token = new CommentToken(builder.ToString());
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|