Comments (2)
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.
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)
- Lots of implicit integer type conversion errors HOT 3
- commas in numeric output HOT 1
- 'plain' output with a defined field-separator HOT 9
- Add "--continuation" option to "xo" to allow multiple html lines
- Document "xo"'s --not-first option HOT 1
- "xo" need option to make JSON object wrapper HOT 1
- "xo" needs a means of handling lists and instances HOT 1
- Newline before closing brace in json output HOT 2
- libtool makes unreliable executable names HOT 1
- 1.3.1 Ubuntu 18.04 WSL missing so HOT 3
- typo HOT 2
- Fails to build with GCC on FreeBSD HOT 2
- check width of unicode characters
- FreeBSD's json format prints an unescaped new line before the final closing bracket HOT 2
- No man page for xo_emit_field() HOT 6
- Man pages not escaping some newlines (PR included) HOT 1
- XOF_UNDERSCORES: hyphens in topmost keys are not replaced HOT 2
- xo/xo.c#L99: add missing UNUSED marker for all unused flags HOT 2
- libxo inconsistent field truncation HOT 3
- Linux: <sys/sysctl.h> missing HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libxo.