From c0a3fe8ef0cc2296bc39efcc24673d19f996972c Mon Sep 17 00:00:00 2001 From: Guillaume DOTT Date: Fri, 6 Sep 2013 17:29:43 +0200 Subject: [PATCH] Add request before response in parser --- lib/biju/parser.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/biju/parser.rb b/lib/biju/parser.rb index 3c8495e..e422e9f 100644 --- a/lib/biju/parser.rb +++ b/lib/biju/parser.rb @@ -8,11 +8,11 @@ module Biju rule(:at_string) { request | response } # REQUEST - rule(:request) { str('+++') | str('A/') | (prefix >> (crlf.absent? >> any).repeat) } + rule(:request) { str('+++') | str('A/') | (prefix >> (cr.absent? >> lf.absent? >> any).repeat(0)) >> response.maybe } rule(:prefix) { str('AT') | str('at') } # RESPONSE - rule(:response) { (status | command) >> crlf } + rule(:response) { cr >> crlf >> (status | command) >> crlf } rule(:command) { mgl | pms | mserror } rule(:mserror) { str('+CMS ERROR').as(:cmd) >> str(': ') >> message } @@ -21,7 +21,8 @@ module Biju crlf >> status end rule(:pms) do - str('+CPMS').as(:cmd) >> str(': ') >> str('(').maybe >> array >> str(')').maybe + str('+CPMS').as(:cmd) >> str(': ') >> str('(').maybe >> array >> str(')').maybe >> + crlf >> crlf >> status end rule(:array) do