Comparing version 16.1.0 to 16.1.2
@@ -25,25 +25,31 @@ /* | ||
rest = stream["rest"], | ||
memoStream = stream["memoStream"]; | ||
var provide, provideString, finish, parseIncState, parseInc, runIncState, runInc, runManyState, runManyStream, runMany; | ||
var Request = (function(chunk, k) { | ||
(this.chunk = chunk); | ||
(this.k = k); | ||
}); | ||
var Session = (function(done, k, chunks) { | ||
(this.done = done); | ||
(this.k = k); | ||
(this.chunks = chunks); | ||
}); | ||
memoStream = stream["memoStream"], | ||
provide, provideString, finish, parseIncState, parseInc, runIncState, runInc, runManyState, runManyStream, runMany, | ||
Request = (function(chunk, k) { | ||
var self = this; | ||
(self.chunk = chunk); | ||
(self.k = k); | ||
}), | ||
Session = (function(done, k, chunks) { | ||
var self = this; | ||
(self.done = done); | ||
(self.k = k); | ||
(self.chunks = chunks); | ||
}); | ||
(Session.prototype.addChunk = (function(c) { | ||
return new(Session)(this.done, this.k, this.chunks.concat(c)); | ||
var self = this; | ||
return new(Session)(self.done, self.k, self.chunks.concat(c)); | ||
})); | ||
(Session.prototype.hasChunk = (function(c) { | ||
return (c < this.chunks.length); | ||
var self = this; | ||
return (c < self.chunks.length); | ||
})); | ||
(Session.prototype.getChunk = (function(c) { | ||
return this.chunks[c]; | ||
var self = this; | ||
return self.chunks[c]; | ||
})); | ||
var IncrementalState = (function(chunk, state) { | ||
(this.chunk = chunk); | ||
(this.state = state); | ||
var self = this; | ||
(self.chunk = chunk); | ||
(self.state = state); | ||
}); | ||
@@ -53,3 +59,4 @@ Object.defineProperties(IncrementalState.prototype, ({ | ||
"get": (function() { | ||
return this.state.input; | ||
var self = this; | ||
return self.state.input; | ||
}) | ||
@@ -59,3 +66,4 @@ }), | ||
"get": (function() { | ||
return this.state.position; | ||
var self = this; | ||
return self.state.position; | ||
}) | ||
@@ -65,3 +73,4 @@ }), | ||
"get": (function() { | ||
return this.state.userState; | ||
var self = this; | ||
return self.state.userState; | ||
}) | ||
@@ -71,14 +80,18 @@ }) | ||
(IncrementalState.prototype.eq = (function(other) { | ||
return ((other && (other.chunk === this.chunk)) && this.state.eq(other.state)); | ||
var self = this; | ||
return ((other && (other.chunk === self.chunk)) && self.state.eq(other.state)); | ||
})); | ||
(IncrementalState.prototype.isEmpty = (function() { | ||
return this.state.isEmpty(); | ||
var self = this; | ||
return self.state.isEmpty(); | ||
})); | ||
(IncrementalState.prototype.first = (function() { | ||
return this.state.first(); | ||
var self = this; | ||
return self.state.first(); | ||
})); | ||
(IncrementalState.prototype.next = (function(x) { | ||
if (!this._next) { | ||
var chunk = this.chunk; | ||
(this._next = bind(next(this.state.next(x), getParserState), (function(innerState) { | ||
var self = this; | ||
if (!self._next) { | ||
var chunk = self.chunk; | ||
(self._next = bind(next(self.state.next(x), getParserState), (function(innerState) { | ||
return (innerState.isEmpty() ? (function(_, m, cok) { | ||
@@ -98,17 +111,20 @@ return new(Request)((chunk + 1), (function(i) { | ||
} | ||
return this._next; | ||
return self._next; | ||
})); | ||
(IncrementalState.prototype.setInput = (function(input) { | ||
return new(IncrementalState)(this.chunk, this.state.setInput(input)); | ||
var self = this; | ||
return new(IncrementalState)(self.chunk, self.state.setInput(input)); | ||
})); | ||
(IncrementalState.prototype.setPosition = (function(position) { | ||
return new(IncrementalState)(this.chunk, this.state.setPosition(position)); | ||
var self = this; | ||
return new(IncrementalState)(self.chunk, self.state.setPosition(position)); | ||
})); | ||
(IncrementalState.prototype.setUserState = (function(userState) { | ||
return new(IncrementalState)(this.chunk, this.state.setUserState(userState)); | ||
var self = this; | ||
return new(IncrementalState)(self.chunk, self.state.setUserState(userState)); | ||
})); | ||
var forceProvide = (function(r, c) { | ||
if (r.done) return r; | ||
var r2 = r.addChunk(c); | ||
var result = trampoline(r2.k(c)); | ||
var r2 = r.addChunk(c), | ||
result = trampoline(r2.k(c)); | ||
while (((result instanceof Request) && r2.hasChunk(result.chunk)))(result = trampoline(result.k(r2.getChunk( | ||
@@ -124,11 +140,8 @@ result.chunk)))); | ||
})); | ||
(finish = (function() { | ||
var complete = (function(r) { | ||
return r.k(); | ||
}); | ||
return (function(r) { | ||
return complete(forceProvide(r, NIL)); | ||
}); | ||
}) | ||
.call(this)); | ||
var complete = (function(r) { | ||
return r.k(); | ||
}); | ||
(finish = (function(r) { | ||
return complete(forceProvide(r, NIL)); | ||
})); | ||
(parseIncState = (function(p, state, ok, err) { | ||
@@ -148,18 +161,15 @@ var pok = (function(x, s) { | ||
})); | ||
(runIncState = (function() { | ||
var ok = (function(x) { | ||
return x; | ||
}), | ||
err = (function(x) { | ||
throw x; | ||
}); | ||
return (function(p, state) { | ||
return parseIncState(p, state, ok, err); | ||
}); | ||
}) | ||
.call(this)); | ||
var ok = (function(x) { | ||
return x; | ||
}), | ||
err = (function(x) { | ||
throw x; | ||
}); | ||
(runIncState = (function(p, state) { | ||
return parseIncState(p, state, ok, err); | ||
})); | ||
(runInc = (function(p, ud) { | ||
return runIncState(p, new(ParserState)(NIL, Position.initial, ud)); | ||
})); | ||
(runManyState = (function(p, state) { | ||
(runManyState = (function(p, state, toEnd) { | ||
var manyP = optional(NIL, (function(state, m, cok, cerr, eok, eerr) { | ||
@@ -166,0 +176,0 @@ return new(Tail)(p, state, m, (function(x, state, m) { |
@@ -22,7 +22,6 @@ /* | ||
ParserError = __o1["ParserError"], | ||
rec = __o1["rec"]; | ||
var times, atMostTimes, betweenTimes, then, between, sepBy1, sepBy, sepEndBy1, sepEndBy, endBy1, endBy, chainl1, chainl, | ||
chainr1, chainr; | ||
var _end = always(NIL); | ||
var _optionalValueParser = optional.bind(null, NIL); | ||
rec = __o1["rec"], | ||
times, atMostTimes, betweenTimes, then, between, sepBy1, sepBy, sepEndBy1, sepEndBy, endBy1, endBy, chainl1, chainl, | ||
chainr1, chainr, _end = always(NIL), | ||
_optionalValueParser = optional.bind(null, NIL); | ||
(times = (function(f, g) { | ||
@@ -29,0 +28,0 @@ return (function() { |
@@ -14,4 +14,4 @@ /* | ||
foldr = stream["foldr"], | ||
seshat = require("seshet"); | ||
var Tail, trampoline, ParserError, ParseError, MultipleError, UnknownError, UnexpectError, ExpectError, ParserState, | ||
seshat = require("seshet"), | ||
Tail, trampoline, ParserError, ParseError, MultipleError, UnknownError, UnexpectError, ExpectError, ParserState, | ||
Position, rec, Parser, RecParser, always, never, bind, eof, extract, getParserState, setParserState, | ||
@@ -21,34 +21,35 @@ modifyParserState, getState, setState, modifyState, getInput, setInput, getPosition, setPosition, fail, attempt, | ||
eager, binds, cons, append, enumerations, enumerationa, enumeration, many, many1, token, anyToken, memo, Memoer, | ||
exec, parseState, parseStream, parse, runState, runStream, run, testState, testStream, test; | ||
var map = Function.prototype.call.bind(Array.prototype.map); | ||
var identity = (function(x) { | ||
return x; | ||
}); | ||
var args = (function() { | ||
var args = arguments; | ||
return args; | ||
}); | ||
var constant = (function(x) { | ||
return (function() { | ||
exec, parseState, parseStream, parse, runState, runStream, run, testState, testStream, test, map = Function.prototype | ||
.call.bind(Array.prototype.map), | ||
identity = (function(x) { | ||
return x; | ||
}), | ||
args = (function() { | ||
var args = arguments; | ||
return args; | ||
}), | ||
constant = (function(x) { | ||
return (function() { | ||
return x; | ||
}); | ||
}), | ||
throwConstant = (function(err) { | ||
return (function() { | ||
throw err; | ||
}); | ||
}), | ||
flip = (function(f) { | ||
return (function(x, y) { | ||
return f(y, x); | ||
}); | ||
}); | ||
}); | ||
var throwConstant = (function(err) { | ||
return (function() { | ||
throw err; | ||
}); | ||
}); | ||
var flip = (function(f) { | ||
return (function(x, y) { | ||
return f(y, x); | ||
}); | ||
}); | ||
(Tail = (function(p, state, m, cok, cerr, eok, eerr) { | ||
(this.p = p); | ||
(this.state = state); | ||
(this.m = m); | ||
(this.cok = cok); | ||
(this.cerr = cerr); | ||
(this.eok = eok); | ||
(this.eerr = eerr); | ||
var self = this; | ||
(self.p = p); | ||
(self.state = state); | ||
(self.m = m); | ||
(self.cok = cok); | ||
(self.cerr = cerr); | ||
(self.eok = eok); | ||
(self.eerr = eerr); | ||
})); | ||
@@ -62,4 +63,5 @@ (trampoline = (function(f) { | ||
(Memoer = (function(memoer, frames) { | ||
(this.memoer = memoer); | ||
(this.frames = frames); | ||
var self = this; | ||
(self.memoer = memoer); | ||
(self.frames = frames); | ||
})); | ||
@@ -88,48 +90,61 @@ (Memoer.empty = new(Memoer)(seshat.create((function(x, y) { | ||
(Position = (function(i) { | ||
(this.index = i); | ||
var self = this; | ||
(self.index = i); | ||
})); | ||
(Position.initial = new(Position)(0)); | ||
(Position.prototype.toString = (function() { | ||
return ("" + this.index); | ||
var self = this; | ||
return ("" + self.index); | ||
})); | ||
(Position.prototype.increment = (function(tok) { | ||
return new(Position)((this.index + 1)); | ||
var self = this; | ||
return new(Position)((self.index + 1)); | ||
})); | ||
(Position.prototype.compare = (function(pos) { | ||
return (this.index - pos.index); | ||
var self = this; | ||
return (self.index - pos.index); | ||
})); | ||
(ParserState = (function(input, position, userState) { | ||
(this.input = input); | ||
(this.position = position); | ||
(this.userState = userState); | ||
var self = this; | ||
(self.input = input); | ||
(self.position = position); | ||
(self.userState = userState); | ||
})); | ||
(ParserState.prototype.eq = (function(other) { | ||
return ((other && (this.input === other.input)) && (this.userState === other.userState)); | ||
var self = this; | ||
return ((other && (self.input === other.input)) && (self.userState === other.userState)); | ||
})); | ||
(ParserState.prototype.isEmpty = (function() { | ||
return isEmpty(this.input); | ||
var self = this; | ||
return isEmpty(self.input); | ||
})); | ||
(ParserState.prototype.first = (function() { | ||
return first(this.input); | ||
var self = this; | ||
return first(self.input); | ||
})); | ||
(ParserState.prototype.next = (function(x) { | ||
if (!this._next) { | ||
var s = new(ParserState)(rest(this.input), this.position.increment(x), this.userState); | ||
(this._next = (function(_, m, cok) { | ||
var self = this; | ||
if (!self._next) { | ||
var s = new(ParserState)(rest(self.input), self.position.increment(x), self.userState); | ||
(self._next = (function(_, m, cok) { | ||
return cok(x, s, m); | ||
})); | ||
} | ||
return this._next; | ||
return self._next; | ||
})); | ||
(ParserState.prototype.setInput = (function(input) { | ||
return new(ParserState)(input, this.position, this.userState); | ||
var self = this; | ||
return new(ParserState)(input, self.position, self.userState); | ||
})); | ||
(ParserState.prototype.setPosition = (function(position) { | ||
return new(ParserState)(this.input, position, this.userState); | ||
var self = this; | ||
return new(ParserState)(self.input, position, self.userState); | ||
})); | ||
(ParserState.prototype.setUserState = (function(userState) { | ||
return new(ParserState)(this.input, this.position, userState); | ||
var self = this; | ||
return new(ParserState)(self.input, self.position, userState); | ||
})); | ||
(ParserError = (function(msg) { | ||
(this.message = msg); | ||
var self = this; | ||
(self.message = msg); | ||
})); | ||
@@ -140,4 +155,5 @@ (ParserError.prototype = new(Error)()); | ||
(ParseError = (function(position, msg) { | ||
(this.position = position); | ||
(this._msg = msg); | ||
var self = this; | ||
(self.position = position); | ||
(self._msg = msg); | ||
})); | ||
@@ -148,3 +164,4 @@ (ParseError.prototype = new(Error)()); | ||
(ParseError.prototype.toString = (function() { | ||
return ((this.name + ": ") + this.message); | ||
var self = this; | ||
return ((self.name + ": ") + self.message); | ||
})); | ||
@@ -155,3 +172,4 @@ Object.defineProperties(ParseError.prototype, ({ | ||
"get": (function() { | ||
return ((("At position:" + this.position) + " ") + this.errorMessage); | ||
var self = this; | ||
return ((("At position:" + self.position) + " ") + self.errorMessage); | ||
}) | ||
@@ -162,3 +180,4 @@ }), | ||
"get": (function() { | ||
return ((this._msg === undefined) ? "" : this._msg); | ||
var self = this; | ||
return ((self._msg === undefined) ? "" : self._msg); | ||
}) | ||
@@ -168,4 +187,5 @@ }) | ||
(MultipleError = (function(position, errors) { | ||
ParseError.call(this, position); | ||
(this.errors = (errors || [])); | ||
var self = this; | ||
ParseError.call(self, position); | ||
(self.errors = (errors || [])); | ||
})); | ||
@@ -177,3 +197,4 @@ (MultipleError.prototype = new(ParseError)()); | ||
"get": (function() { | ||
return (("[" + map(this.errors, (function(x) { | ||
var self = this; | ||
return (("[" + map(self.errors, (function(x) { | ||
return x.message; | ||
@@ -185,5 +206,6 @@ })) | ||
var ChoiceError = (function(position, pErr, qErr) { | ||
ParseError.call(this, position); | ||
(this._pErr = pErr); | ||
(this._qErr = qErr); | ||
var self = this; | ||
ParseError.call(self, position); | ||
(self._pErr = pErr); | ||
(self._qErr = qErr); | ||
}); | ||
@@ -195,7 +217,9 @@ (ChoiceError.prototype = new(MultipleError)()); | ||
"get": (function() { | ||
return [this._pErr].concat(this._qErr.errors); | ||
var self = this; | ||
return [self._pErr].concat(self._qErr.errors); | ||
}) | ||
})); | ||
(UnknownError = (function(position) { | ||
ParseError.call(this, position); | ||
var self = this; | ||
ParseError.call(self, position); | ||
})); | ||
@@ -209,4 +233,5 @@ (UnknownError.prototype = new(ParseError)()); | ||
(UnexpectError = (function(position, unexpected) { | ||
ParseError.call(this, position); | ||
(this.unexpected = unexpected); | ||
var self = this; | ||
ParseError.call(self, position); | ||
(self.unexpected = unexpected); | ||
})); | ||
@@ -218,9 +243,11 @@ (UnexpectError.prototype = new(ParseError)()); | ||
"get": (function() { | ||
return ("Unexpected:" + this.unexpected); | ||
var self = this; | ||
return ("Unexpected:" + self.unexpected); | ||
}) | ||
})); | ||
(ExpectError = (function(position, expected, found) { | ||
ParseError.call(this, position); | ||
(this.expected = expected); | ||
(this.found = found); | ||
var self = this; | ||
ParseError.call(self, position); | ||
(self.expected = expected); | ||
(self.found = found); | ||
})); | ||
@@ -232,3 +259,4 @@ (ExpectError.prototype = new(ParseError)()); | ||
"get": (function() { | ||
return (("Expected:" + this.expected) + (this.found ? (" Found:" + this.found) : "")); | ||
var self = this; | ||
return (("Expected:" + self.expected) + (self.found ? (" Found:" + self.found) : "")); | ||
}) | ||
@@ -239,3 +267,3 @@ })); | ||
var args = arguments; | ||
return value.apply(this, args); | ||
return value.apply(undefined, args); | ||
})); | ||
@@ -245,6 +273,9 @@ return value; | ||
(Parser = (function(name, p) { | ||
return Object.defineProperty(p, "displayName", ({ | ||
return (p.hasOwnProperty("displayName") ? Parser(name, (function() { | ||
var args = arguments; | ||
return p.apply(undefined, args); | ||
})) : Object.defineProperty(p, "displayName", ({ | ||
"value": name, | ||
"writable": false | ||
})); | ||
}))); | ||
})); | ||
@@ -267,5 +298,5 @@ (RecParser = (function(name, p) { | ||
return new(Tail)(p, state, m, (function(x, state, m) { | ||
return f(x)(state, m, cok, cerr, cok, cerr); | ||
return new(Tail)(f(x), state, m, cok, cerr, cok, cerr); | ||
}), cerr, (function(x, state, m) { | ||
return f(x)(state, m, cok, cerr, eok, eerr); | ||
return new(Tail)(f(x), state, m, cok, cerr, eok, eerr); | ||
}), eerr); | ||
@@ -322,8 +353,8 @@ }); | ||
})); | ||
}); | ||
var _fail = (function(e) { | ||
return bind(getPosition, (function(pos) { | ||
return never(e(pos)); | ||
})); | ||
}); | ||
}), | ||
_fail = (function(e) { | ||
return bind(getPosition, (function(pos) { | ||
return never(e(pos)); | ||
})); | ||
}); | ||
(fail = (function(msg) { | ||
@@ -392,9 +423,9 @@ var e = (msg ? ParseError : UnknownError); | ||
return (function EITHER(state, m, cok, cerr, eok, eerr) { | ||
var position = state["position"]; | ||
var peerr = (function(errFromP, _, mFromP) { | ||
var qeerr = (function(errFromQ, _, mFromQ) { | ||
return eerr(e(position, errFromP, errFromQ), state, mFromQ); | ||
var position = state["position"], | ||
peerr = (function(errFromP, _, mFromP) { | ||
var qeerr = (function(errFromQ, _, mFromQ) { | ||
return eerr(e(position, errFromP, errFromQ), state, mFromQ); | ||
}); | ||
return new(Tail)(q, state, mFromP, cok, cerr, eok, qeerr); | ||
}); | ||
return new(Tail)(q, state, mFromP, cok, cerr, eok, qeerr); | ||
}); | ||
return new(Tail)(p, state, m, cok, cerr, eok, peerr); | ||
@@ -432,22 +463,19 @@ }); | ||
})); | ||
var _end = always(NIL); | ||
var _optionalValueParser = optional.bind(null, NIL); | ||
var _joinParser = (function(joiner) { | ||
return (function(p1, p2) { | ||
return bind(p1, (function(v1) { | ||
return bind(p2, (function(v2) { | ||
return always(joiner(v1, v2)); | ||
var _end = always(NIL), | ||
_optionalValueParser = optional.bind(null, NIL), | ||
_joinParser = (function(joiner) { | ||
return (function(p1, p2) { | ||
return bind(p1, (function(v1) { | ||
return bind(p2, (function(v2) { | ||
return always(joiner(v1, v2)); | ||
})); | ||
})); | ||
})); | ||
}); | ||
}), | ||
toArray = (function(x) { | ||
return always(stream.toArray(x)); | ||
}); | ||
}); | ||
(eager = (function() { | ||
var toArray = (function(x) { | ||
return always(stream.toArray(x)); | ||
}); | ||
return (function(p) { | ||
return bind(p, toArray); | ||
}); | ||
}) | ||
.call(this)); | ||
(eager = (function(p) { | ||
return bind(p, toArray); | ||
})); | ||
(binds = (function(p, f) { | ||
@@ -471,52 +499,45 @@ return bind(eager(p), (function(x) { | ||
})(enumerationa, args)); | ||
(many = (function() { | ||
var manyError = throwConstant(new(ParserError)( | ||
"Many parser applied to a parser that accepts an empty string")); | ||
return (function(p) { | ||
var safeP = (function(state, m, cok, cerr, eok, eerr) { | ||
return new(Tail)(p, state, m, cok, cerr, manyError, eerr); | ||
}); | ||
return rec((function(self) { | ||
return _optionalValueParser(cons(safeP, self)); | ||
})); | ||
}); | ||
}) | ||
.call(this)); | ||
var manyError = throwConstant(new(ParserError)("Many parser applied to a parser that accepts an empty string")); | ||
(many = (function(p) { | ||
var safeP = (function(state, m, cok, cerr, eok, eerr) { | ||
return new(Tail)(p, state, m, cok, cerr, manyError, eerr); | ||
}); | ||
return rec((function(self) { | ||
return _optionalValueParser(cons(safeP, self)); | ||
})); | ||
})); | ||
(many1 = (function(p) { | ||
return cons(p, many(p)); | ||
})); | ||
(token = (function() { | ||
var defaultErr = (function(pos, tok) { | ||
return new(UnexpectError)(pos, ((tok === null) ? "end of input" : tok)); | ||
}); | ||
return (function(consume, onErr) { | ||
var errorHandler = (onErr || defaultErr); | ||
return (function TOKEN(state, m, cok, cerr, eok, eerr) { | ||
var position = state["position"]; | ||
if (state.isEmpty()) { | ||
return eerr(errorHandler(position, null), state, m); | ||
} else { | ||
var tok = state.first(); | ||
if (consume(tok)) { | ||
var pcok = (function(x, s, m) { | ||
var position = s["position"]; | ||
return cok(x, s, Memoer.prune(m, position)); | ||
}); | ||
return new(Tail)(state.next(tok), state, m, pcok, cerr, pcok, cerr); | ||
} | ||
return eerr(errorHandler(position, tok), state, m); | ||
} | ||
}); | ||
}); | ||
}) | ||
.call(this)); | ||
var defaultErr = (function(pos, tok) { | ||
return new(UnexpectError)(pos, ((tok === null) ? "end of input" : tok)); | ||
}); | ||
(token = (function(consume, onErr) { | ||
var errorHandler = (onErr || defaultErr); | ||
return (function TOKEN(state, m, cok, cerr, eok, eerr) { | ||
var position = state["position"]; | ||
if (state.isEmpty()) { | ||
return eerr(errorHandler(position, null), state, m); | ||
} else { | ||
var tok = state.first(); | ||
if (consume(tok)) { | ||
var pcok = (function(x, s, m) { | ||
var position = s["position"]; | ||
return cok(x, s, Memoer.prune(m, position)); | ||
}); | ||
return new(Tail)(state.next(tok), state, m, pcok, cerr, pcok, cerr); | ||
} | ||
return eerr(errorHandler(position, tok), state, m); | ||
} | ||
}); | ||
})); | ||
(anyToken = Parser("Any Token", token(constant(true)))); | ||
(memo = (function(p) { | ||
return (function(state, m, cok, cerr, eok, eerr) { | ||
var position = state["position"]; | ||
var key = ({ | ||
"id": p, | ||
"state": state | ||
}); | ||
var entry = Memoer.lookup(m, position, key); | ||
var position = state["position"], | ||
key = ({ | ||
"id": p, | ||
"state": state | ||
}), | ||
entry = Memoer.lookup(m, position, key); | ||
if (entry) { | ||
@@ -557,14 +578,11 @@ switch (entry[0]) { | ||
})); | ||
(runState = (function() { | ||
var ok = (function(x) { | ||
return x; | ||
}), | ||
err = (function(x) { | ||
throw x; | ||
}); | ||
return (function(p, state) { | ||
return parseState(p, state, ok, err); | ||
}); | ||
}) | ||
.call(this)); | ||
var ok = (function(x) { | ||
return x; | ||
}), | ||
err = (function(x) { | ||
throw x; | ||
}); | ||
(runState = (function(p, state) { | ||
return parseState(p, state, ok, err); | ||
})); | ||
(runStream = (function(p, s, ud) { | ||
@@ -576,10 +594,7 @@ return runState(p, new(ParserState)(s, Position.initial, ud)); | ||
})); | ||
(testState = (function() { | ||
var ok0 = constant(true), | ||
err0 = constant(false); | ||
return (function(p, state) { | ||
return parseState(p, state, ok0, err0); | ||
}); | ||
}) | ||
.call(this)); | ||
var ok0 = constant(true), | ||
err0 = constant(false); | ||
(testState = (function(p, state) { | ||
return parseState(p, state, ok0, err0); | ||
})); | ||
(testStream = (function(p, s, ud) { | ||
@@ -586,0 +601,0 @@ return testState(p, new(ParserState)(s, Position.initial, ud)); |
@@ -14,18 +14,19 @@ /* | ||
Parser = __o["Parser"], | ||
token = __o["token"]; | ||
var character, characters, string, trie, match, anyChar, letter, space, digit; | ||
var join = Function.prototype.call.bind(Array.prototype.join); | ||
var map = Function.prototype.call.bind(Array.prototype.map); | ||
var reduce = Function.prototype.call.bind(Array.prototype.reduce); | ||
var reduceRight = Function.prototype.call.bind(Array.prototype.reduceRight); | ||
var expectError = (function(msg) { | ||
return (function(pos, tok) { | ||
return new(ExpectError)(pos, msg, ((tok === null) ? "end of input" : tok)); | ||
token = __o["token"], | ||
character, characters, string, trie, match, anyChar, letter, space, digit, join = Function.prototype.call.bind( | ||
Array.prototype.join), | ||
map = Function.prototype.call.bind(Array.prototype.map), | ||
reduce = Function.prototype.call.bind(Array.prototype.reduce), | ||
reduceRight = Function.prototype.call.bind(Array.prototype.reduceRight), | ||
expectError = (function(msg) { | ||
return (function(pos, tok) { | ||
return new(ExpectError)(pos, msg, ((tok === null) ? "end of input" : tok)); | ||
}); | ||
}), | ||
StringError = (function(position, string, index, expected, found) { | ||
var self = this; | ||
ExpectError.call(self, position, expected, found); | ||
(self.string = string); | ||
(self.index = index); | ||
}); | ||
}); | ||
var StringError = (function(position, string, index, expected, found) { | ||
ExpectError.call(this, position, expected, found); | ||
(this.string = string); | ||
(this.index = index); | ||
}); | ||
(StringError.prototype = new(ExpectError)()); | ||
@@ -35,4 +36,5 @@ (StringError.prototype.constructor = StringError); | ||
"get": (function() { | ||
return ((((((("In string:'" + this.string) + "' at index:") + this.index) + ", Expected:") + this.expected) + | ||
" Found:") + (this.found ? this.found : "end of input")); | ||
var self = this; | ||
return ((((((("In string:'" + self.string) + "' at index:") + self.index) + ", Expected:") + self.expected) + | ||
" Found:") + (self.found ? self.found : "end of input")); | ||
}) | ||
@@ -64,42 +66,36 @@ })); | ||
})); | ||
(string = (function() { | ||
var reducer = (function(p, c, i, s) { | ||
return next(_character(c, (function(pos, tok) { | ||
return new(StringError)(pos, s, i, c, tok); | ||
})), p); | ||
}); | ||
return (function(s) { | ||
return attempt(reduceRight(s, reducer, always((s + "")))); | ||
}); | ||
}) | ||
.call(this)); | ||
(trie = (function() { | ||
var wordReduce = (function(parent, l) { | ||
(parent[l] = (parent[l] || ({}))); | ||
return parent[l]; | ||
}), | ||
wordsReduce = (function(trie, word) { | ||
var node = reduce(word, wordReduce, trie); | ||
(node[""] = word); | ||
return trie; | ||
}), | ||
makeTrie = (function(words) { | ||
return reduce(words, wordsReduce, ({})); | ||
}), | ||
_trie = (function(trie) { | ||
var keys = Object.keys(trie), | ||
paths = reduce(keys, (function(p, c) { | ||
if (c.length)(p[c] = _trie(trie[c])); | ||
return p; | ||
}), ({})), | ||
select = attempt(bind(characters(keys), (function(x) { | ||
return paths[x]; | ||
}))); | ||
return (trie.hasOwnProperty("") ? either(select, always(trie[""])) : select); | ||
}); | ||
return (function(words) { | ||
return attempt(_trie(makeTrie(words), "")); | ||
}); | ||
}) | ||
.call(this)); | ||
var reducer = (function(p, c, i, s) { | ||
return next(_character(c, (function(pos, tok) { | ||
return new(StringError)(pos, s, i, c, tok); | ||
})), p); | ||
}); | ||
(string = (function(s) { | ||
return attempt(reduceRight(s, reducer, always((s + "")))); | ||
})); | ||
var wordReduce = (function(parent, l) { | ||
(parent[l] = (parent[l] || ({}))); | ||
return parent[l]; | ||
}), | ||
wordsReduce = (function(trie, word) { | ||
var node = reduce(word, wordReduce, trie); | ||
(node[""] = word); | ||
return trie; | ||
}), | ||
makeTrie = (function(words) { | ||
return reduce(words, wordsReduce, ({})); | ||
}), | ||
_trie = (function(trie) { | ||
var keys = Object.keys(trie), | ||
paths = reduce(keys, (function(p, c) { | ||
if (c.length)(p[c] = _trie(trie[c])); | ||
return p; | ||
}), ({})), | ||
select = attempt(bind(characters(keys), (function(x) { | ||
return paths[x]; | ||
}))); | ||
return (trie.hasOwnProperty("") ? either(select, always(trie[""])) : select); | ||
}); | ||
(trie = (function(words) { | ||
return attempt(_trie(makeTrie(words), "")); | ||
})); | ||
(match = (function(pattern, expected) { | ||
@@ -106,0 +102,0 @@ return token(RegExp.prototype.test.bind(pattern), expectError(expected)); |
{ | ||
"name": "bennu", | ||
"version": "16.1.0", | ||
"version": "16.1.2", | ||
"description": "Parser Combinator Library", | ||
@@ -17,13 +17,12 @@ "author": "Matt Bierner", | ||
"combinatory parsing", | ||
"functional" | ||
], | ||
"functional"], | ||
"main": "index.js", | ||
"directories": { | ||
"lib": "dist_node" | ||
"lib": "dist_node/" | ||
}, | ||
"files": [ | ||
"dist_node/", | ||
"dependencies", | ||
"lib", | ||
"dependencies/", | ||
"lib/", | ||
"tests/", | ||
@@ -44,2 +43,2 @@ "index.js", | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
154962
2403