Last active
August 29, 2015 14:24
-
-
Save MarchLiu/787e85cc5515894d2fd5 to your computer and use it in GitHub Desktop.
sep and sep1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sep = function(s, p) { | |
var fun = function(state){ | |
return choice(sep1(s, p), []) | |
}; | |
parsec(fun); | |
return fun; | |
}; | |
sep.prototype = parsec; | |
var sep1 = function(s, p) { | |
var fun = function(state){ | |
p.bind(function(state, x){ | |
var re = new Array() | |
re[0]=x | |
re.contact(many(s.then(p))) | |
}) | |
var result = op(state); | |
var arr = new Array(); | |
arr.push(result); | |
arr.contact(sep(op,sp)(state)); | |
}; | |
parsec(fun); | |
return fun; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment