1 using System.Net.Http;
2 using HttpTokens;
3
4 parser HttpStatusLineParser
5 {
6 uselexer HttpLexer;
7 main;
8
9 using Http.text;
10
11 StatusLine : HttpStatus
12 ::= (HttpVersion:v SP StatusCode:sc SP ReasonPhrase:rp){ return HttpStatus(v, sc, rp); }
13 ;
14
15 HttpVersion(var string s) : string
16 ::= (ALPHA{ s.Append(lexer.GetChar(pos)); }
17 ALPHA{ s.Append(lexer.GetChar(pos)); }
18 ALPHA{ s.Append(lexer.GetChar(pos)); }
19 ALPHA{ s.Append(lexer.GetChar(pos)); pass = s == "HTTP"; }
20 SLASH{ s.Append('/'); } (DIGIT{ s.Append(lexer.GetChar(pos)); })+ DOT{ s.Append('.'); } (DIGIT{ s.Append(lexer.GetChar(pos)); })+
21 )
22 {
23 return s;
24 }
25 ;
26
27 StatusCode(var string s) : ushort
28 ::= (DIGIT{ s.Append(lexer.GetChar(pos)); }
29 DIGIT{ s.Append(lexer.GetChar(pos)); }
30 DIGIT{ s.Append(lexer.GetChar(pos)); }
31 )
32 {
33 return ParseUShort(s);
34 }
35 ;
36
37 ReasonPhrase(var string s) : string
38 ::= ((text:t{ s.Append(t); })+){ return s; }
39 ;
40 }
41