core/encoding/xml

encoding_xml

Types

16

Document

Document :: struct { elements: [dynamic]Element, element_count: Element_ID, prologue: Attributes, encoding: Encoding, doctype: struct { // We only scan the <!DOCTYPE IDENT part and skip the rest. ident: string, rest: string, }, // If we encounter comments before the root node, and the option to intern comments is given, this is where they'll live. // Otherwise they'll be in the element tree. comments: [dynamic]string, // Internal tokenizer: ^Tokenizer, allocator: mem.Allocator, // Input. Either the original buffer, or a copy if `.Input_May_Be_Modified` isn't specified. input: []u8, strings_to_free: [dynamic]string, }Source

Error

Error :: enum int { // General return values. None = 0, General_Error = 1, Unexpected_Token = 2, Invalid_Token = 3, // Couldn't find, open or read file. File_Error = 4, // File too short. Premature_EOF = 5, // XML-specific errors. No_Prolog = 6, Invalid_Prolog = 7, Too_Many_Prologs = 8, No_DocType = 9, Too_Many_DocTypes = 10, DocType_Must_Preceed_Elements = 11, // If a DOCTYPE is present _or_ the caller // asked for a specific DOCTYPE and the DOCTYPE // and root tag don't match, we return `.Invalid_DocType`. Invalid_DocType = 12, Invalid_Tag_Value = 13, Mismatched_Closing_Tag = 14, Unclosed_Comment = 15, Comment_Before_Root_Element = 16, Invalid_Sequence_In_Comment = 17, Unsupported_Version = 18, Unsupported_Encoding = 19, // <!FOO are usually skipped. Unhandled_Bang = 20, Duplicate_Attribute = 21, Conflicting_Options = 22, }Source

Option_Flag

Option_Flag :: enum int { // If the caller says that input may be modified, we can perform in-situ parsing. // If this flag isn't provided, the XML parser first duplicates the input so that it can. Input_May_Be_Modified = 0, // Document MUST start with `<?xml` prologue. Must_Have_Prolog = 1, // Document MUST have a `<!DOCTYPE`. Must_Have_DocType = 2, // By default we skip comments. Use this option to intern a comment on a parented Element. Intern_Comments = 3, // How to handle unsupported parts of the specification, like <! other than <!DOCTYPE and <![CDATA[ Error_on_Unsupported = 4, Ignore_Unsupported = 5, // By default CDATA tags are passed-through as-is. // This option unwraps them when encountered. Unbox_CDATA = 6, // By default SGML entities like `&gt;`, `&#32;` and `&#x20;` are passed-through as-is. // This option decodes them when encountered. Decode_SGML_Entities = 7, // If a tag body has a comment, it will be stripped unless this option is given. Keep_Tag_Body_Comments = 8, }Source

Token_Kind

Token_Kind :: enum int { Invalid = 0, Ident = 1, Literal = 2, Rune = 3, String = 4, Double_Quote = 5, // " Single_Quote = 6, // ' Colon = 7, // : Eq = 8, // = Lt = 9, // < Gt = 10, // > Exclaim = 11, // ! Question = 12, // ? Hash = 13, // # Slash = 14, // / Dash = 15, // - Open_Bracket = 16, // [ Close_Bracket = 17, // ] EOF = 18, }Source

Constants

6

Procedures

32

scan_comment

scan_comment :: proc(t: ^Tokenizer) -> (comment: string, err: Error)Source

A comment ends when we see -->, preceded by a character that's not a dash.

"For compatibility, the string "--" (double-hyphen) must not occur within comments."

	See: https://www.w3.org/TR/2006/REC-xml11-20060816/#dt-comment

	Thanks to the length (4) of the comment start, we also have enough lookback,
	and the peek at the next byte asserts that there's at least one more character
	that's a `>`.

Procedure Groups

1

Reference search

Find anything

Documentation preferences

Settings

System theme variants

Used only while Theme is set to System.