Skip to content

Commit

Permalink
checked in multi_bulk_reply.rl.
Browse files Browse the repository at this point in the history
  • Loading branch information
agentzh committed Dec 15, 2010
1 parent e472706 commit 5e01559
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/multi_bulk_reply.rl
@@ -0,0 +1,46 @@
%%{
machine multi_bulk_reply;

include common "common.rl";

action test_chunk_count {
ctx->chunks_read < ctx->chunk_count
}

action start_reading_chunk {
ctx->chunks_read = 0;
}

action start_reading_count {
ctx->chunk_count = 0;
}

action read_count {
ctx->chunk_count *= 10;
ctx->chunk_count += *p - '0';
dd("chunk count: %d", (int) ctx->chunk_count);
}

protected_chunk = chunk when test_chunk_count
;

chunk_count = (digit+ -- "0"+) >start_reading_count $read_count
;

response = "*" chunk_count CRLF
(protected_chunk+ >start_reading_chunk)
;

action multi_bulk_finalize {
dd("done!");
if (ctx->chunks_read == ctx->chunk_count) {
done = 1;
}
}


main := response @multi_bulk_finalize
;

}%%

0 comments on commit 5e01559

Please sign in to comment.