tools/protocolParser.hs
author unc0rr
Sat, 25 Apr 2015 23:46:09 +0300
branchqmlfrontend
changeset 10900 6a805e822074
parent 10898 f373838129c2
child 10902 29519fe63fdd
permissions -rw-r--r--
Some hedgewars coding a week keeps doctor away

module Main where

import Text.PrettyPrint.HughesPJ
import Data.Tree

data HWProtocol = Command String [CmdParam]
data CmdParam = Skip
              | SS
              | LS
              | IntP
              | Many [CmdParam]
data ClientStates = NotConnected
                  | JustConnected
                  | ServerAuth
                  | Lobby

cmd = Command
cmd1 s p = Command s [p]
cmd2 s p1 p2 = Command s [p1, p2]

commands = [
        cmd "CONNECTED" [Skip, IntP]
        , cmd1 "NICK" SS
        , cmd1 "PROTO" IntP
        , cmd1 "ASKPASSWORD" SS
        , cmd1 "SERVER_AUTH" SS
        , cmd1 "LOBBY:JOINED" $ Many [SS]
    ]

pas = 
    
main = putStrLn $ render pas