Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
parse.c File Reference

VM opcode snippet for parsing XML text into a document handle. More...

Go to the source code of this file.

Functions

 free_value (drop)
 push_value (vm, make_int(0))

Variables

case OP_XML_PARSE
 break

Detailed Description

VM opcode snippet for parsing XML text into a document handle.

This snippet is included by vm.c and implements OP_XML_PARSE.

Opcode: OP_XML_PARSE

  • Stack effect: pop (string xml_text) → push (int doc_handle | 0)
  • Behavior: Parses the given XML string into an in-memory xmlDoc. On success, a positive document handle is allocated via the XML handle registry and pushed. On failure (malformed XML, OOM), 0 is pushed.
  • Initialization: Ensures libxml2 is initialized once (xmlInitParser()).
  • Gating: If FUN_WITH_XML2 is disabled, the input is discarded and 0 is pushed.

Notes

  • The handle must later be released via appropriate XML VM opcodes that free documents; leaking handles will leak memory.
  • The parser is invoked with XML_PARSE_NONET to disallow network access.

Example // stack: [ "<root/>" ] OP_XML_PARSE // → [ 1 ] (example handle)

Definition in file parse.c.

Function Documentation

◆ free_value()

free_value(drop)

◆ push_value()

push_value(vm,
make_int(0) )

Variable Documentation

◆ break

break

Definition at line 64 of file parse.c.

◆ OP_XML_PARSE

case OP_XML_PARSE

Definition at line 35 of file parse.c.