View project on GitHub

Purposes of YOM language

The aim of the YOM project is to organize some customers' data in simple and human-readable manner.
Source data may be saved/edited in this format, but they have to be converted into javascript objects for visualization and other processing.
The situation is very similar to when the data in CSV format may be stored/edited separately from their pattern in a spreadsheet or database.
But unlike CSV, which allows you to store tabular data, YOM is used to store data with hierarchical (tree-like) structures of arbitrary depth.
Examples of such data are given below.

TL;DR YOM solves about the same problem as the XML, but for those cases where the data is completely separated from the markup.
In this case XML is redundant and less human-readable, since all nodes look like <node> .... </node>

YOM by Examples

Example #1 (simple taxonomy tree)

animals [cat, dog, elephant {big, gray}],
plants [deciduous   [oak, maple, baobab],
        other   [fir, cactus]

Example #2 (menu for some imaginary app)

File [
    New, Open, Save,
    Remove {disabled}
View [
    Text [ANSI {default}, UTF-8],
Help [On-line, Forum, About]

Example #3 (some Web page structure)

Header {height:10} [
    Controls [Help Button, Search Pane]
Main [
    Teaser, News,
    Articles [1, 2, ..., N]
Footer [Status Bar [Info1, Info2], Powered By, Copyright notice {color: gold}]

Example #4 (contents of this page)

Purposes of YOM language [

YOM by Examples [
    Example /#1 [blah-blah]
    Example /#2 [blah-blah]
    Example /#3 [blah]

And so on...

(Semi-)Formal Definition

  • Items (nodes) are delimited by ',' (comma) or \n (line feed)
  • Node may have optional set of named attributes (in curly brackets)
  • Node may have optional set (array) of subnodes (in square brackets)

That's all!

Ah, yeah...

  • Whitespace at the beginning and end of a node's string is ignored.
    Empty lines are ignored too.
    Use '{}' or '[]' to make the "empty node"
  • '/' (slash) is used for escaping. So '/x' makes to treat 'x' literally (ex: '/,' --> ',' , '//' --> '/' etc.)
    It's to allow commas and brackets be in the text.
  • Each attribute is a pair of the name and optional value. The name is separated from the value (if any) by ':' (colon) or '=' (equals sign).
    If attribute has no an explicit value (ex. {gray, big}) then it is implicitly equal to true.
    Attributes are delimited by ',' (comma)
  • Any of the symbols '\' | '+' | '-' may be used at the line end to make the line continuation.
    It allows multiline node texts.
  • Special symbol '#' (number sign | hash sign | octothorpe (!?)) is used for special processing:
    1) # comments; if there is a space blank after '#' then a subsequent node is entirely ignored. It allows to make comments in the source
    2) #<name>. The <name> should start with letter, '' or '$' and continues with letter, digit, '' or '$'. It adds the prop "hash": {<name>: true} to a subsequent node.

Comments example

Normal text # this is ignored to the end of line
2nd node's text # inline comment here, 3rd node's text
# [
   Multiline comment:
   2nd line of the comment,
   etc. etc. etc.

What's in the result

YOM parser converts YOM formatted text and returns the javascript object of the form:

    hash: {"hash_name": true},     // if any
    text: "string",                // a text value of the node
    attr:   {a1: v1, a2: v2, ...}, // attributes of the node
    nodes: [{}, {}, ...]           // arrray of subnodes;
                                   //   each element is {[hash,] text, attr, nodes};
                                   //   and so on, recursively

Relation to other data formats

YOM is based on nested parentheses idea by Sir Arthur Cayley
Similar format is The Newick tree format

Q & A

Q: Why YOM? what it means?
A: "do Your Own Model"

Q: Do you know that word 'Yom' has another meaning?
A: I realized it, but it was late. It's not by intention. It's just a coincidence. Really, I wrote YOM at night.