Files
PdfPig/src/UglyToad.PdfPig.Tokenization/CommentTokenizer.cs
Eliot Jones bbde38f656 move tokenizers to their own project
since both pdfs and Adobe Type1 fonts use postscript type objects, tokenization is needed by the main project and the fonts project
2020-01-05 10:40:44 +00:00

33 lines
768 B
C#

namespace UglyToad.PdfPig.Tokenization
{
using System.Text;
using Core;
using Tokens;
internal class CommentTokenizer : ITokenizer
{
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;
}
}
}