mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-03-10 00:23:29 +08:00
since both pdfs and Adobe Type1 fonts use postscript type objects, tokenization is needed by the main project and the fonts project
33 lines
768 B
C#
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;
|
|
}
|
|
}
|
|
}
|