New $Special objects for __, SOA, EOA etc.

This commit is contained in:
Tony Garnock-Jones 2016-01-31 10:54:41 -05:00
parent 1107483c86
commit c2fa26f9ed
1 changed files with 9 additions and 5 deletions

View File

@ -1,9 +1,13 @@
var Immutable = require("immutable");
var __ = "__"; /* wildcard marker */
function $Special(name) {
this.name = name;
}
var SOA = "__["; // start of array
var EOA = "__]"; // end of array
var __ = new $Special("wildcard"); /* wildcard marker */
var SOA = new $Special("["); // start of array
var EOA = new $Special("]"); // end of array
function die(message) {
throw new Error(message);
@ -33,8 +37,8 @@ function isCapture(x) { return x instanceof $Capture || x === _$; }
function captureName(x) { return x instanceof $Capture ? x.name : null; }
function capturePattern(x) { return x instanceof $Capture ? x.pattern : __; }
var SOC = "__{{"; // start of capture
var EOC = "__}}"; // end of capture
var SOC = new $Special("{"); // start of capture
var EOC = new $Special("}"); // end of capture
function $Success(value) {
this.value = value;