Giter Site home page Giter Site logo

Comments (2)

philshafer avatar philshafer commented on June 27, 2024

Thanks! IMO, the semantics should be:

Start with a namelist that contains one element with empty name.
For each new node to be generated:
{

  • If the test is called for an xo_emit() that does not actually
    generate a JSON or XML node, no test is performed (it may or may not
    contain a valid node name).
  • For xo_emit, open_container or open_list check that the name of the
    node is not yet in the namelist.
    • If the name is found: WARN about duplicate use of this name.
  • For open_instance, the name of the instance must match the name in
    the first element of the namelist.
    • If the name differs: WARN about illegal other nodes in the xo_list.
  • Each xo_emit, open_container, open_list or open_instance puts its
    name into the element at the beginning of the namelist (which must
    be empty or in the case of an instance or leaf list may already
    contain that name).
    • If not empty or identical to instance name: WARN
  • Whenever a leaf, container or list is closed, an empty element is
    inserted at the beginning of the namelist. Leafs are implicitly
    closed (and an empty element inserted), unless the leaf is part of
    a leaf list (in which case the close_list will insert the empty
    element at the head of the namelist).
    }

When the xo_stack depth is reduced, the first element of the namelist
must be empty:

  • If not empty: WARN that some xo_close call is missing.

from libxo.

stesser avatar stesser commented on June 27, 2024

I'm wondering whether another test should be added after the test for open_instance:
If xo_emit() is used with the "l" modifier, then the key/tag name should be the same as that of a previous open_list. I.e., the test for leaf list elements should be identical to the test for instances.

In addition, a test should be added to prevent mixing of instances and leaf list elements of the same name in one list, as would be generated by:
xo_open_list("item");
xo_open_instance("item");
xo_close_instance("item");
xo_emit("{l:item/value}");
xo_close_list("item");

While both instances and leaf list elements are allowed in lists, the above would lead to bad JSON output.

from libxo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.