saxtojson

v0.0.10
Converts sax file into json

sax2json

Converts .sax file (yes, I made up this format) into json.

Epic sax guy

Installation

Don't have one. Just clone this repository.

Usage

Brace yourself... execute bin/sax2json or require lib/sax2jsonjs.

Sax definition

Sax file is a collection of commands.

Command:

  • collection of arguments separated by white space. First argument must be a string. Block can only be the last argument.

  • comment (line starting with # and optional trailing white spaces)

  • empty line

Argument is a string or block.

String is a set of chars enclosed by double quotation marks. Quotation marks can be ommited.

Block is a set equally indented commands.

Parsing

Input

click "a[name=b]" 
    equal "title" "foo"
    ok 2 > 1

Output

[[
    "click", "a[name=b]", [[
        "equal",
        "title",
        "foo"
    ], [
        "ok":
        "2",
        ">",
        "1"
    ]]
]]

Tests

nodeunit test/sax2json.js 	
npm i saxtojson

Metadata

Downloads

Maintainers