View Source Pdf.Reader.Lexer (ExPDF v1.0.1)

PDF binary tokenizer.

Token shapes

:eof
{:integer, integer()}
{:real, float()}
{:boolean, boolean()}
:null
{:name, binary()}          # without leading /
{:string, binary()}        # literal (...)
{:hex_string, binary()}    # <...> decoded to bytes
:array_open  |  :array_close
:dict_open   |  :dict_close
{:obj, rest}  |  {:endobj, rest}
{:stream, rest}  |  {:endstream, rest}
{:xref, rest}  |  {:trailer, rest}  |  {:startxref, rest}
{:r, rest}  |  {:f, rest}  |  {:n, rest}

next_token/1 returns {token, rest_binary} or :eof.

Summary

Functions

Returns the next token from binary together with the unconsumed rest.

Skips all leading whitespace (PDF § 7.2.2: space, tab, LF, CR, FF, NUL).

Functions

@spec next_token(binary()) :: {term(), binary()} | :eof

Returns the next token from binary together with the unconsumed rest.

Returns :eof when the binary is empty or contains only whitespace/comments.

@spec skip_whitespace(binary()) :: binary()

Skips all leading whitespace (PDF § 7.2.2: space, tab, LF, CR, FF, NUL).