12136
|
1 |
use std::string;
|
|
2 |
use std::str::FromStr;
|
12135
|
3 |
|
|
4 |
use super::messages::HWProtocolMessage::*;
|
12136
|
5 |
use super::messages::*;
|
12135
|
6 |
|
|
7 |
grammar;
|
|
8 |
|
12136
|
9 |
pub ProtocolMessage: HWProtocolMessage = {
|
|
10 |
<SpecificMessage> "\n\n",
|
|
11 |
};
|
|
12 |
|
|
13 |
SpecificMessage: HWProtocolMessage = {
|
|
14 |
"NICK" "\n" <ProtocolString> => Nick(<>),
|
|
15 |
"PONG" => Pong,
|
|
16 |
"PING" => Ping,
|
|
17 |
"PROTO" "\n" <Num32> => Proto(<>),
|
12135
|
18 |
};
|
|
19 |
|
12136
|
20 |
Num32: u32 =
|
|
21 |
<Digit*> => number(<>);
|
|
22 |
|
|
23 |
ProtocolString: String =
|
|
24 |
<ProtocolChar*> => <>.join("");
|
|
25 |
|
|
26 |
ProtocolChar: &'input str =
|
|
27 |
r"[^\n]" => <>;
|
|
28 |
|
|
29 |
Digit: u8 = {
|
|
30 |
"0" => 0,
|
|
31 |
"1" => 1,
|
|
32 |
"2" => 2,
|
|
33 |
"3" => 3,
|
|
34 |
"4" => 4,
|
|
35 |
"5" => 5,
|
|
36 |
"6" => 6,
|
|
37 |
"7" => 7,
|
|
38 |
"8" => 8,
|
|
39 |
"9" => 9,
|
12135
|
40 |
};
|