Skip to content

Instantly share code, notes, and snippets.

@ccorcos
Created March 2, 2017 04:38
Show Gist options
  • Save ccorcos/c571d40bc730a08b86fc7248b94faff0 to your computer and use it in GitHub Desktop.
Save ccorcos/c571d40bc730a08b86fc7248b94faff0 to your computer and use it in GitHub Desktop.
const char = c =>
new Parser(stream => {
if (stream.length === 0) {
return new Failure('unexpected end', stream))
}
const value = stream.head()
if (value === c) {
return new Success(value, stream.move(1))
}
return new Failure('char did not match', stream))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment