Skip to content

Instantly share code, notes, and snippets.

@objmagic
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save objmagic/2e7ca47237a49dc5ab00 to your computer and use it in GitHub Desktop.

Select an option

Save objmagic/2e7ca47237a49dc5ab00 to your computer and use it in GitHub Desktop.
pair parser
(* parser generated from ``let seq_parser = (lit 'c') <~> (lit 'd')`` *)
fun s_178 ->
let res1_182 =
let ix_179 = s_178.Sparser.BasicFParser.index in
let f_180 = Sparser.BasicFParser.Failure s_178 in
if ix_179 < s_178.Sparser.BasicFParser.length
then
let e1_181 = (s_178.Sparser.BasicFParser.input).[ix_179] in
(if e1_181 = 'c'
then
Sparser.BasicFParser.Success
(e1_181,
{
s_178 with
Sparser.BasicFParser.index = (ix_179 + 1);
Sparser.BasicFParser.col =
(s_178.Sparser.BasicFParser.col + 1)
})
else f_180)
else f_180 in
match res1_182 with
| Sparser.BasicFParser.Success (r1_183,state1_184) ->
let res2_188 =
let ix_185 = state1_184.Sparser.BasicFParser.index in
let f_186 = Sparser.BasicFParser.Failure state1_184 in
if ix_185 < state1_184.Sparser.BasicFParser.length
then
let e1_187 = (state1_184.Sparser.BasicFParser.input).[ix_185] in
(if e1_187 = 'd'
then
Sparser.BasicFParser.Success
(e1_187,
{
state1_184 with
Sparser.BasicFParser.index = (ix_185 + 1);
Sparser.BasicFParser.col =
(state1_184.Sparser.BasicFParser.col + 1)
})
else f_186)
else f_186 in
(match res2_188 with
| Sparser.BasicFParser.Success (r2_189,state2_190) ->
Sparser.BasicFParser.Success ((r1_183, r2_189), state2_190)
| Sparser.BasicFParser.Failure _ -> Sparser.BasicFParser.Failure s_178)
| Sparser.BasicFParser.Failure _ -> Sparser.BasicFParser.Failure s_178
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment