10898
|
1 |
module Main where
|
|
2 |
|
|
3 |
import Text.PrettyPrint.HughesPJ
|
|
4 |
|
|
5 |
data HWProtocol = Command String [CmdParam]
|
|
6 |
data CmdParam = Skip
|
|
7 |
| SS
|
|
8 |
| LS
|
|
9 |
| IntP
|
|
10 |
| Many [CmdParam]
|
|
11 |
data ClientStates = NotConnected
|
|
12 |
| JustConnected
|
|
13 |
| ServerAuth
|
|
14 |
| Lobby
|
|
15 |
|
10902
|
16 |
data ParseTree = PTChar Char [ParseTree]
|
|
17 |
| PTCommand HWProtocol
|
|
18 |
|
10898
|
19 |
cmd = Command
|
|
20 |
cmd1 s p = Command s [p]
|
|
21 |
cmd2 s p1 p2 = Command s [p1, p2]
|
|
22 |
|
10902
|
23 |
breakCmd (Command (c:cs) params) = (c, Command cs params)
|
|
24 |
|
10898
|
25 |
commands = [
|
|
26 |
cmd "CONNECTED" [Skip, IntP]
|
|
27 |
, cmd1 "NICK" SS
|
|
28 |
, cmd1 "PROTO" IntP
|
|
29 |
, cmd1 "ASKPASSWORD" SS
|
|
30 |
, cmd1 "SERVER_AUTH" SS
|
|
31 |
, cmd1 "LOBBY:JOINED" $ Many [SS]
|
10902
|
32 |
, cmd2 "LOBBY:LEFT" $ SS SS
|
|
33 |
, cmd2 "CLIENT_FLAGS" $ SS $ Many [SS]
|
|
34 |
, cmd1 "SERVER_MESSAGE" LS
|
10898
|
35 |
]
|
|
36 |
|
10902
|
37 |
|
|
38 |
|
10900
|
39 |
pas =
|
|
40 |
|
|
41 |
main = putStrLn $ render pas
|