wavedrom / cli

CLI for WaveDrom
https://wavedrom.com
MIT License
61 stars 12 forks source link

Parse using YAML instead of JSON5. #17

Closed gsmecher closed 4 years ago

gsmecher commented 4 years ago

This pull request allows the use of YAML in addition to JSON.

Although YAML is nearly (and divisively) a superset of JSON, JSON5 is an extension in competition with YAML and no longer quite a subset. Hence, I'm halfway expecting an outright "no", because this removes functionality currently present in the command-line interface (and/or makes it inconsistent with the rest of the wavedrom package.) That would be OK.

If the idea doesn't offend, there are a couple of ways to skin this cat:

Why YAML? Because it allows the use of whitespace as an alternative to nested brackets and braces. Hence, step5.js could be expressed as:

signal:
  - {name: clk, wave: 'p..Pp..P'}
  - - Master
    - - ctrl
      - {name: write, wave: '01.0....'}
      - {name: read,  wave: '0...1..0'}
    - {name: addr,  wave: 'x3.x4..x', data: A1 A2}
    - {name: wdata, wave: 'x3.x....', data: D1}
  - {}
  - - Slave
    - {ctrl, name: ack,   wave: 'x01x0.1x'}
    - {name: rdata, wave: 'x.....4x', data: Q2}

This example shows YAML only as a syntactically richer alternative to JSON. There are also ways for YAML to allow injection of type information (via !Tags) and alternative structures (via &references) in ways that JSON can't. However, that opens up several other cans of worms: let's start here, and probably finish here too. Comments welcome.

drom commented 4 years ago

I am not interested in replacing JSON5 with YAML any time soon.

gsmecher commented 4 years ago

OK! Loud and clear -- and thanks for all your hard work. Lack of YAML isn't going to stop me from enthusiastically using wavedrom.