gameServer2/src/protocol/hwprotocol.lalrpop
author unc0rr
Fri, 06 Jan 2017 01:00:21 +0300
changeset 12136 a4d22f197bd2
parent 12135 6273f89ab13d
permissions -rw-r--r--
Still trying to make parser work
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12136
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
     1
use std::string;
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
     2
use std::str::FromStr;
12135
6273f89ab13d Start on messages parser
unc0rr
parents:
diff changeset
     3
6273f89ab13d Start on messages parser
unc0rr
parents:
diff changeset
     4
use super::messages::HWProtocolMessage::*;
12136
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
     5
use super::messages::*;
12135
6273f89ab13d Start on messages parser
unc0rr
parents:
diff changeset
     6
6273f89ab13d Start on messages parser
unc0rr
parents:
diff changeset
     7
grammar;
6273f89ab13d Start on messages parser
unc0rr
parents:
diff changeset
     8
12136
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
     9
pub ProtocolMessage: HWProtocolMessage = {
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    10
    <SpecificMessage> "\n\n",
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    11
};
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    12
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    13
SpecificMessage: HWProtocolMessage = {
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    14
    "NICK" "\n" <ProtocolString> => Nick(<>),
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    15
    "PONG" => Pong,
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    16
    "PING" => Ping,
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    17
    "PROTO" "\n" <Num32> => Proto(<>),
12135
6273f89ab13d Start on messages parser
unc0rr
parents:
diff changeset
    18
};
6273f89ab13d Start on messages parser
unc0rr
parents:
diff changeset
    19
12136
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    20
Num32: u32 =
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    21
    <Digit*> => number(<>);
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    22
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    23
ProtocolString: String =
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    24
    <ProtocolChar*> => <>.join("");
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    25
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    26
ProtocolChar: &'input str =
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    27
    r"[^\n]" => <>;
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    28
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    29
Digit: u8 = {
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    30
    "0" => 0,
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    31
    "1" => 1,
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    32
    "2" => 2,
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    33
    "3" => 3,
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    34
    "4" => 4,
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    35
    "5" => 5,
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    36
    "6" => 6,
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    37
    "7" => 7,
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    38
    "8" => 8,
a4d22f197bd2 Still trying to make parser work
unc0rr
parents: 12135
diff changeset
    39
    "9" => 9,
12135
6273f89ab13d Start on messages parser
unc0rr
parents:
diff changeset
    40
};