moonbitlang/pdflite/syntax does not have a README file

    PdfLexeme

    pub(all) enum PdfLexeme {
    LexNull
    LexBool(Bool)
    LexInt(Int)
    LexReal(Double)
    LexString(Bytes)
    LexName(
    PdfName
    )
    LexLeftSquare
    LexRightSquare
    LexLeftDict
    LexRightDict
    LexEndStream
    LexObj
    LexEndObj
    LexR
    LexComment(Bytes)
    StopLexing
    LexNone
    } derive(Eq, ToJson,
    Debug
    )

    Token produced by the low-level PDF lexer.

    String, name, and comment payloads are byte-oriented PDF data. StopLexing is an internal stop marker used when object lexing reaches stream/xref boundaries, and LexNone means no token matched at the current cursor position.

    PdfLexeme::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfLexeme::equal(PdfLexeme, PdfLexeme) -> Bool

    PdfLexeme::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfLexeme::not_equal(x : PdfLexeme, y : PdfLexeme) -> Bool

    PdfLexeme::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfLexeme::to_json(PdfLexeme) -> Json

    PdfLexeme::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfLexeme::to_repr(PdfLexeme) ->
    Repr

    PdfObject

    pub(all) enum PdfObject {
    PdfNull
    PdfBoolean(Bool)
    PdfInteger(Int)
    PdfReal(Double)
    PdfExactReal(Double)
    PdfString(Bytes)
    PdfNameObject(
    PdfName
    )
    PdfArray(Array[PdfObject])
    PdfDictionary(Array[(
    PdfName
    , PdfObject)])
    PdfStreamObject(PdfStream)
    PdfIndirect(Int)
    } derive(Eq, ToJson,
    Debug
    )

    The core in-memory representation of a parsed PDF object.

    Strings and names are byte-oriented PDF values, not MoonBit Unicode strings. PdfIndirect(number) is an unresolved reference by object number; callers that need the referenced object should resolve it through a PdfDocument.

    PdfReal is written rounded (to six decimals below 0.0001 in magnitude, otherwise to twelve significant digits); PdfExactReal is written exactly, as the shortest decimal that reads back as the value (see pdf_write_exact_real), for numbers such as transformation coefficients that no fixed precision serves. The parser never produces PdfExactReal: what it writes reads back as PdfReal (or PdfInteger).

    PdfObject::add_dict_entry

    Add or replace a dictionary entry.

    PdfNull is promoted to a one-entry dictionary. Existing keys are replaced in place. New keys are inserted using the historical CamlPDF order, which places the new entry before existing entries. Stream objects mutate their stream dictionary and return the same stream object.

    PdfObject::deep_copy

    fn PdfObject::deep_copy(self : PdfObject) -> PdfObject

    Deep-copy a PDF object tree.

    PdfObject::dictionary_view

    Borrow the dictionary entries of a dictionary-like object.

    Plain dictionaries return their entries. Stream objects return the entries of their stream dictionary when that dictionary is itself a PdfDictionary. Other objects return None.

    PdfObject::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfObject::equal(PdfObject, PdfObject) -> Bool

    PdfObject::find_indirect

    Return the object number of an immediate indirect dictionary entry.

    Only plain dictionaries are accepted. Missing keys and non-indirect values return None; non-dictionary inputs raise @core.PdfError::DictionaryExpected.

    PdfObject::get_stream

    Materialize a stream in place.

    Deferred stream data is read, decrypted if needed, stored back as StreamGot, and /Length is corrected when the stream dictionary is a PDF dictionary. Calling this on an already materialized stream is a no-op. Non-stream objects raise @core.PdfError::ParseStreamExpected.

    PdfObject::lookup_immediate

    Look up a key without resolving indirect references.

    Dictionary and stream-dictionary entries are searched in stored order. The returned object is the immediate value stored under key; use document-level lookup helpers when indirect references should be resolved.

    PdfObject::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfObject::not_equal(x : PdfObject, y : PdfObject) -> Bool

    PdfObject::remove_dict_entry

    Remove a dictionary entry if present.

    Missing keys are ignored for dictionaries. Stream objects mutate their stream dictionary and return the same stream object. Non-dictionary inputs raise @core.PdfError::DictionaryExpected.

    PdfObject::replace_dict_entry

    Replace an existing dictionary entry.

    The key must already exist in a plain dictionary or stream dictionary. Missing keys and non-dictionary inputs raise @core.PdfError::DictionaryKeyNotFound.

    PdfObject::stream_bytes

    fn PdfObject::stream_bytes(self : PdfObject) -> Bytes raise
    PdfError

    Return a stream object's materialized bytes.

    StreamGot data is returned directly. Deferred StreamToGet data is read from its source cursor and decrypted if necessary, but this method does not mutate the stream object or update /Length; use get_stream for that. Non-stream objects raise @core.PdfError::ParseStreamExpected.

    PdfObject::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfObject::to_json(PdfObject) -> Json

    PdfObject::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfObject::to_repr(PdfObject) ->
    Repr

    PdfObject::unique_key

    Generate a dictionary key with the form /<prefix><n> that is not in use.

    The scan starts at n = 0 and increments until the name is absent from the dictionary or stream dictionary. Non-dictionary-like objects raise @core.PdfError::DictionaryExpected.

    PdfParsedIndirectObject

    pub(all) struct PdfParsedIndirectObject {
    number : Int
    generation : Int
    object : PdfObject
    } derive(Eq, ToJson,
    Debug
    )

    A parsed indirect object with object number, generation, and payload.

    PdfParsedIndirectObject::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfParsedIndirectObject::equal(PdfParsedIndirectObject, PdfParsedIndirectObject) -> Bool

    PdfParsedIndirectObject::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfParsedIndirectObject::not_equal(x : PdfParsedIndirectObject, y : PdfParsedIndirectObject) -> Bool

    PdfParsedIndirectObject::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfParsedIndirectObject::to_json(PdfParsedIndirectObject) -> Json

    PdfParsedIndirectObject::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfParsedIndirectObject::to_repr(PdfParsedIndirectObject) ->
    Repr

    PdfStream

    pub(all) struct PdfStream {
    dictionary : PdfObject
    data : PdfStreamData
    } derive(Eq, ToJson,
    Debug
    )

    A PDF stream object: dictionary metadata plus stream bytes.

    The dictionary and data fields are mutable because helpers such as get_stream and the dictionary update methods materialize stream data and update stream dictionaries in place.

    PdfStream::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfStream::equal(PdfStream, PdfStream) -> Bool

    PdfStream::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfStream::not_equal(x : PdfStream, y : PdfStream) -> Bool

    PdfStream::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfStream::to_json(PdfStream) -> Json

    PdfStream::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfStream::to_repr(PdfStream) ->
    Repr

    PdfStreamData

    pub(all) enum PdfStreamData {
    StreamGot(Bytes)
    StreamToGet(ToGet)
    } derive(Eq, ToJson,
    Debug
    )

    Storage state for a PDF stream body.

    StreamGot stores already materialized bytes. StreamToGet stores a deferred slice of an input buffer, optionally with stream decryption metadata that is applied when the data is read.

    PdfStreamData::deep_copy

    fn PdfStreamData::deep_copy(self : PdfStreamData) -> PdfStreamData

    Deep-copy stream storage, including deferred cursor metadata.

    PdfStreamData::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfStreamData::equal(PdfStreamData, PdfStreamData) -> Bool

    PdfStreamData::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfStreamData::not_equal(x : PdfStreamData, y : PdfStreamData) -> Bool

    PdfStreamData::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfStreamData::to_json(PdfStreamData) -> Json

    PdfStreamData::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfStreamData::to_repr(PdfStreamData) ->
    Repr

    PdfStreamDataCrypt

    pub(all) enum PdfStreamDataCrypt {
    PdfStreamDataNoCrypt
    PdfStreamDataArc4Decrypt(Int, Int, Bytes, Int)
    PdfStreamDataAesV2Decrypt(Int, Int, Bytes, Int)
    PdfStreamDataAesV3Decrypt(Bytes)
    } derive(Eq, ToJson,
    Debug
    )

    Decryption metadata associated with deferred stream data.

    The variants correspond to the stream ciphers supported by the PDF security handler. Object-specific ciphers store object number, generation, file key, and key length; AES-V3 stores the already derived file key.

    PdfStreamDataCrypt::decrypt

    fn PdfStreamDataCrypt::decrypt(self : PdfStreamDataCrypt, data : BytesView) -> Bytes raise
    PdfError

    Decrypt one deferred stream-data view using this stream crypt policy.

    PdfStreamDataCrypt::deep_copy

    Deep-copy stream-decryption metadata.

    PdfStreamDataCrypt::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfStreamDataCrypt::equal(PdfStreamDataCrypt, PdfStreamDataCrypt) -> Bool

    PdfStreamDataCrypt::is_identity

    fn PdfStreamDataCrypt::is_identity(self : PdfStreamDataCrypt) -> Bool

    Return whether this stream crypt policy leaves bytes unchanged.

    PdfStreamDataCrypt::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfStreamDataCrypt::not_equal(x : PdfStreamDataCrypt, y : PdfStreamDataCrypt) -> Bool

    PdfStreamDataCrypt::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfStreamDataCrypt::to_json(PdfStreamDataCrypt) -> Json

    PdfStreamDataCrypt::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PdfStreamDataCrypt::to_repr(PdfStreamDataCrypt) ->
    Repr

    ToGet

    pub(all) struct ToGet {
    input :
    ByteCursor

    position : Int
    length : Int
    crypt : PdfStreamDataCrypt
    } derive(Eq, ToJson,
    Debug
    )

    A deferred stream-data slice read from an input cursor.

    position and length identify the raw byte range in input; crypt records the decryption operation to apply when the bytes are materialized. This lets the reader keep large stream bodies lazy until a caller requests their bytes.

    ToGet::crypt

    fn ToGet::crypt(self : ToGet) -> PdfStreamDataCrypt

    Return the decryption metadata for a deferred stream slice.

    ToGet::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn ToGet::equal(ToGet, ToGet) -> Bool

    ToGet::input

    Return the source cursor used by a deferred stream slice.

    ToGet::length

    fn ToGet::length(self : ToGet) -> Int

    Return the byte length of a deferred stream slice.

    ToGet::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn ToGet::not_equal(x : ToGet, y : ToGet) -> Bool

    ToGet::position

    fn ToGet::position(self : ToGet) -> Int

    Return the start position of a deferred stream slice.

    The value is interpreted relative to the @core.ByteCursor's offset when the stream is materialized.

    ToGet::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn ToGet::to_json(ToGet) -> Json

    ToGet::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn ToGet::to_repr(ToGet) ->
    Repr

    dict_add_entries

    Add or replace a dictionary entry while preserving historical insertion order.

    pdf_array

    fn pdf_array(values : ArrayView[PdfObject]) -> PdfObject

    Construct a PDF array from a read-only view of object values.

    The outer array is newly allocated, but the contained PdfObject values are copied by value rather than deep-copied.

    pdf_cursor_drop_whitespace

    fn pdf_cursor_drop_whitespace(cursor :
    ByteCursor
    ) -> Unit

    Advance the cursor past PDF white space.

    The first non-whitespace byte, delimiter, or end of input is left unread.

    pdf_cursor_lex_bool

    fn pdf_cursor_lex_bool(cursor :
    ByteCursor
    ) -> PdfLexeme

    Lex true or false at the current cursor position.

    The cursor first reads one regular token. Non-boolean tokens produce LexNone.

    pdf_cursor_lex_comment

    fn pdf_cursor_lex_comment(cursor :
    ByteCursor
    ) -> PdfLexeme

    Lex and skip a PDF comment.

    A comment starts with % and runs up to but not including the next newline. The comment text is intentionally not retained; this returns an empty LexComment payload. Non-comment input returns LexNone.

    pdf_cursor_lex_delimiter

    fn pdf_cursor_lex_delimiter(cursor :
    ByteCursor
    ) -> PdfLexeme

    Lex one PDF delimiter token.

    Recognizes [, ], <<, and >>. A single < or > is left unread and returns LexNone.

    pdf_cursor_lex_hex_string

    Lex a PDF hexadecimal string.

    The opening < must not be a dictionary delimiter <<. White space inside the hex string is ignored, odd trailing nibbles are padded in the PDF way, and invalid hex digits raise @core.PdfError::InvalidHexEscape.

    pdf_cursor_lex_keyword

    Lex PDF structural keywords.

    Recognized keywords include obj, endobj, R, null, and endstream. If a token begins with endobj followed by extra bytes, only endobj is consumed so the suffix can be lexed by later calls.

    pdf_cursor_lex_literal_string

    Lex a PDF literal string.

    Literal strings are enclosed in parentheses, may contain balanced nested parentheses, and support the PDF backslash escapes for control characters, octal bytes, escaped parentheses, and line continuation. Unterminated strings raise @core.PdfError::EndOfInput.

    pdf_cursor_lex_name

    Lex a PDF name object.

    Names start with / and keep the slash in the stored bytes. #xx hex escapes are decoded into raw bytes. Invalid escapes raise @core.PdfError::InvalidHexEscape; non-name input returns LexNone without consuming it.

    pdf_cursor_lex_number

    fn pdf_cursor_lex_number(cursor :
    ByteCursor
    ) -> PdfLexeme

    Lex a PDF integer or real number.

    Integers are limited to MoonBit Int range; oversized integer-looking tokens fall back to real-number parsing. A leading doubled minus is accepted compatibly by dropping one minus sign.

    pdf_cursor_lex_token

    Lex one token from the current cursor position.

    This dispatcher skips white space, recognizes comments, primitives, delimiters, names, literal and hex strings, and selected keywords. It returns StopLexing at end of input and at markers that terminate object scanning, such as startxref or inline image data boundaries.

    pdf_cursor_lex_tokens

    Lex tokens until a stop marker or unmatched input is reached.

    StopLexing and LexNone terminate scanning and are not included in the returned token array.

    pdf_cursor_matches_ascii_at

    fn pdf_cursor_matches_ascii_at(cursor :
    ByteCursor
    , position : Int, values : ArrayView[Int]) -> Bool

    Check whether cursor contains the ASCII byte sequence at an absolute position.

    pdf_cursor_read_regular_token_view

    fn pdf_cursor_read_regular_token_view(cursor :
    ByteCursor
    ) -> BytesView

    Skip PDF white space and read a regular token as a borrowed byte view.

    pdf_cursor_read_until_whitespace_or_delimiter

    fn pdf_cursor_read_until_whitespace_or_delimiter(cursor :
    ByteCursor
    ) -> BytesView

    Read a borrowed view up to PDF white space or a delimiter.

    The terminating byte is left unread so higher-level lexers can dispatch on delimiters after reading a regular token.

    pdf_dictionary

    Construct a PDF dictionary from a read-only view of name/value entries.

    Entry order is preserved exactly as supplied. Duplicate keys are not normalized by this constructor; lookup helpers return the first matching entry.

    pdf_hex_value

    fn pdf_hex_value(value : Int) -> Int?

    Return the integer value of one ASCII hex digit, or None for non-hex bytes.

    pdf_is_number_start_byte

    fn pdf_is_number_start_byte(value : Int) -> Bool

    Return whether a byte can start a PDF numeric token.

    pdf_lex_bytes

    fn pdf_lex_bytes(data : Bytes) -> Array[PdfLexeme] raise
    PdfError

    Lex all tokens from owned PDF bytes.

    pdf_lex_single_view

    fn pdf_lex_single_view(data : BytesView) -> PdfLexeme raise
    PdfError

    Lex a single token from a borrowed byte view.

    pdf_lex_view

    fn pdf_lex_view(data : BytesView) -> Array[PdfLexeme] raise
    PdfError

    Lex all tokens from a borrowed byte view.

    pdf_lexeme_debug_name

    fn pdf_lexeme_debug_name(lexeme : PdfLexeme) -> String

    Return the constructor name of a lexeme for diagnostics and snapshots.

    pdf_lexeme_indirect_object_header_at

    fn pdf_lexeme_indirect_object_header_at(lexemes : ArrayView[PdfLexeme], index : Int) -> Bool

    Return whether lexemes at index start an indirect-object header.

    pdf_number_view_int

    fn pdf_number_view_int(view : BytesView) -> Int?

    Parse an integer token view, returning None when the view is not an integer.

    pdf_object_length_name

    fn pdf_object_length_name() ->
    PdfName

    Return the canonical /Length name used by stream dictionaries.

    pdf_parse_indirect_object_from_bytes

    fn pdf_parse_indirect_object_from_bytes(data : Bytes) -> PdfParsedIndirectObject raise
    PdfError

    Parses one indirect object from owned PDF bytes.

    pdf_parse_indirect_object_from_view

    fn pdf_parse_indirect_object_from_view(data : BytesView) -> PdfParsedIndirectObject raise
    PdfError

    Parses one indirect object from a byte view.

    pdf_parse_indirect_object_lexemes

    fn pdf_parse_indirect_object_lexemes(lexemes : ArrayView[PdfLexeme]) -> PdfParsedIndirectObject raise
    PdfError

    Parses one indirect object from lexemes.

    Raises @core.PdfError::ParseIndirectObjectExpected if the input does not start with an indirect object header.

    pdf_parse_indirect_object_prefix_lexemes

    fn pdf_parse_indirect_object_prefix_lexemes(lexemes : ArrayView[PdfLexeme]) -> PdfParsedIndirectObject raise
    PdfError

    Parse an indirect-object prefix, tolerating a missing trailing endobj.

    pdf_parse_indirect_object_segment_at

    fn pdf_parse_indirect_object_segment_at(lexemes : ArrayView[PdfLexeme], index : Int) -> (PdfParsedIndirectObject, Int, Bool) raise
    PdfError

    Parse an indirect-object segment and report whether endobj was consumed.

    pdf_parse_indirect_object_segments

    Parse complete indirect-object segments and return a trailing prefix if present.

    pdf_parse_indirect_objects

    Parses every complete indirect object from a lexeme sequence.

    Raises @core.PdfError::ParseIndirectObjectExpected when an expected indirect object header is malformed.

    pdf_parse_lexemes

    Parses all top-level PDF objects from lexemes.

    Comments are skipped. Arrays and dictionaries are parsed recursively, and indirect-reference triples are collapsed into PdfIndirect objects.

    pdf_parse_object_from_bytes

    fn pdf_parse_object_from_bytes(data : Bytes) -> PdfObject raise
    PdfError

    Lexes and parses exactly one PDF object from owned PDF bytes.

    pdf_parse_object_from_view

    fn pdf_parse_object_from_view(data : BytesView) -> PdfObject raise
    PdfError

    Lexes and parses exactly one PDF object from a byte view.

    pdf_parse_single_lexeme_object

    fn pdf_parse_single_lexeme_object(lexemes : ArrayView[PdfLexeme]) -> PdfObject raise
    PdfError

    Parses exactly one top-level PDF object from lexemes.

    Raises @core.PdfError::ParseSingleObjectExpected if the input contains zero or more than one object.

    pdf_recurse_array

    fn pdf_recurse_array(transform : (PdfObject) -> PdfObject, values : ArrayView[PdfObject]) -> PdfObject

    Apply a one-level transformation to array elements.

    This helper does not recursively traverse nested dictionaries or arrays by itself; callers provide a transform that decides how each child object is rewritten.

    pdf_recurse_dict

    fn pdf_recurse_dict(transform : (PdfObject) -> PdfObject, entries : ArrayView[(
    PdfName
    , PdfObject)], preserve_order? : Bool) -> PdfObject

    Apply a one-level transformation to dictionary values.

    By default the resulting dictionary entries are reversed to match the historical CamlPDF construction order. Pass preserve_order=true when the incoming order must be retained.

    pdf_stream

    fn pdf_stream(dictionary : PdfObject, data : PdfStreamData) -> PdfObject

    Construct a PDF stream object from a dictionary object and stream data.

    The dictionary is stored as supplied. It is normally a PdfDictionary, but malformed inputs can carry other objects and will be reported by helpers that require dictionary metadata.

    pdf_stream_data_bytes

    fn pdf_stream_data_bytes(data : PdfStreamData) -> Bytes raise
    PdfError

    Return stream data as owned bytes, decrypting deferred data when needed.

    pdf_stream_data_view

    fn pdf_stream_data_view(data : PdfStreamData) -> BytesView raise
    PdfError

    Borrow or materialize stream data as a byte view.

    pdf_string_of_lexeme

    fn pdf_string_of_lexeme(lexeme : PdfLexeme) -> String

    Return CamlPDF-style debug text for a single lexeme.

    Only numbers, strings, names, and null get value-specific rendering; other token kinds are rendered as GenLexNone.

    pdf_string_of_lexemes

    fn pdf_string_of_lexemes(lexemes : ArrayView[PdfLexeme]) -> String

    Return CamlPDF-style debug text for a sequence of lexemes.

    Each lexeme is placed on its own line with a leading space.

    stream_to_get

    fn stream_to_get(input :
    ByteCursor
    , position : Int, length : Int) -> ToGet

    Construct a deferred stream-data descriptor without encryption.

    The returned value references input and reads length bytes starting at position when materialized.