All examples By author By category About

nitaku

Space-separated values (PEG.js)

An example of a simple Domain-Specific Language created with PEG.js.

The language is a sort-of TSV, where spaces separate cell values, and the header row is mandatory. The grammar allows C-like identifiers within the header, and integers only as values. A brutal check on the number of columns is also performed, to ensure the well-formedness of the code.

Valid code produces an array of objects representing the described data, that is then rendered as a table in a separate view.

Basic error messages are available in the editor's status bar.