public PdfObject Parse(long offset) { if (offset >= 0) { _lexer.SetPosition(offset); } PdfToken t = _lexer.GetNextToken(); return(new PdfObject()); }
private PdfToken matchKeyword(int ch) { _buffer.Clear(); while (true) { ch = readByte(); if (ch == CHAR_EOF || isWhiteSpace(ch) || isDelimiter(ch)) { putBack(); PdfToken token = new PdfToken(PdfToken.TokenType.KEYWORD, _buffer.ToArray()); } else { _buffer.Add((byte)ch); } } }
private PdfToken matchNumber(int ch) { _buffer.Clear(); while (true) { _buffer.Add((byte)ch); ch = readByte(); if (ch == CHAR_EOF || isWhiteSpace(ch) || isDelimiter(ch)) { putBack(); if (_buffer.Count == 0) { throw new Exception("Invalid number object: The number cannot be null."); } byte[] data = _buffer.ToArray(); string val = Encoding.ASCII.GetString(data); if (val.Contains(".")) { try { double n = double.Parse(val); PdfToken token = new PdfToken(PdfToken.TokenType.NUMBER, data, PdfToken.TokenSubType.REAL, n); return(token); } catch (Exception ex) { throw new Exception("Invalid number object: '" + val + "' is not a valid number.", ex); } } else { try { int n = int.Parse(val); PdfToken token = new PdfToken(PdfToken.TokenType.NUMBER, data, PdfToken.TokenSubType.INTEGER, n); return(token); } catch (Exception ex) { throw new Exception("Invalid number object: '" + val + "' is not a valid number.", ex); } } } } }
private PdfToken matchName() { _buffer.Clear(); while (true) { int ch = readByte(); if (ch == CHAR_EOF || isWhiteSpace(ch) || isDelimiter(ch)) { putBack(); if (_buffer.Count == 0) { throw new Exception("Invalid name object: The name cannot be null."); } PdfToken token = new PdfToken(PdfToken.TokenType.NAME, _buffer.ToArray()); return(token); } else { _buffer.Add((byte)ch); } } }
private void SetTokenPosition(PdfToken token) { token.Offset = _tokenStart; token.Length = this.GetPosition() - _tokenStart; }