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.
xxxxxxxxxx
<html>
<head>
<meta charset="utf-8">
<title>PEG.js example</title>
<link rel="stylesheet" href="index.css">
<script src="https://d3js.org/d3.v3.min.js"></script>
<script src="/webvis/tmp/peg-0.9.0.min.js"></script>
<script src="https://underscorejs.org/underscore-min.js"></script>
<script src="https://backbonejs.org/backbone-min.js"></script>
<script src="backbone.d3view.js"></script>
<!-- your views go here -->
<script src="AppView.js"></script>
<script src="Editor.js"></script>
<script src="Table.js"></script>
<!-- your models go here -->
<script src="Data.js"></script>
</head>
<body>
<script src="index.js"></script>
</body>
</html>
Modified http://d3js.org/d3.v3.min.js to a secure url
Modified http://underscorejs.org/underscore-min.js to a secure url
Modified http://backbonejs.org/backbone-min.js to a secure url
https://d3js.org/d3.v3.min.js
https://underscorejs.org/underscore-min.js
https://backbonejs.org/backbone-min.js