gameServer2/src/protocol/hwprotocol.lalrpop
changeset 12132 1525923cd7e3
parent 12131 a4d22f197bd2
child 12133 81df2e1f9ae9
equal deleted inserted replaced
12131:a4d22f197bd2 12132:1525923cd7e3
     1 use std::string;
       
     2 use std::str::FromStr;
       
     3 
       
     4 use super::messages::HWProtocolMessage::*;
       
     5 use super::messages::*;
       
     6 
       
     7 grammar;
       
     8 
       
     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(<>),
       
    18 };
       
    19 
       
    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,
       
    40 };