tools/protocolParser.hs
author unc0rr
Sat, 15 Aug 2015 16:23:00 +0300
branchqmlfrontend
changeset 11050 9b7c8c5a94e0
parent 11048 2edb24ed5ee0
child 11073 3ecf06107005
permissions -rw-r--r--
Some fixes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10898
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
     1
module Main where
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
     2
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
     3
import Text.PrettyPrint.HughesPJ
10904
ce265b038220 Some more work on network client implementation
unc0rr
parents: 10902
diff changeset
     4
import qualified Data.MultiMap as MM
ce265b038220 Some more work on network client implementation
unc0rr
parents: 10902
diff changeset
     5
import Data.Maybe
ce265b038220 Some more work on network client implementation
unc0rr
parents: 10902
diff changeset
     6
import Data.List
10927
336f5ad638be Fix jumpts table, build array of handlers (wip)
unc0rr
parents: 10925
diff changeset
     7
import Data.Char
11047
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
     8
import qualified Data.Set as Set
10898
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
     9
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    10
data HWProtocol = Command String [CmdParam]
11048
2edb24ed5ee0 Break it even more during refactoring
unC0Rr
parents: 11047
diff changeset
    11
2edb24ed5ee0 Break it even more during refactoring
unC0Rr
parents: 11047
diff changeset
    12
instance Ord HWProtocol where
2edb24ed5ee0 Break it even more during refactoring
unC0Rr
parents: 11047
diff changeset
    13
    (Command a _) `compare` (Command b _) = a `compare` b    
2edb24ed5ee0 Break it even more during refactoring
unC0Rr
parents: 11047
diff changeset
    14
instance Eq HWProtocol where
2edb24ed5ee0 Break it even more during refactoring
unC0Rr
parents: 11047
diff changeset
    15
    (Command a _) == (Command b _) = a == b
2edb24ed5ee0 Break it even more during refactoring
unC0Rr
parents: 11047
diff changeset
    16
10898
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    17
data CmdParam = Skip
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    18
              | SS
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    19
              | LS
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    20
              | IntP
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    21
              | Many [CmdParam]
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    22
data ClientStates = NotConnected
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    23
                  | JustConnected
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    24
                  | ServerAuth
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    25
                  | Lobby
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    26
10906
13fde38281fc Rendering some code
unc0rr
parents: 10904
diff changeset
    27
data ParseTree = PTPrefix String [ParseTree]
10927
336f5ad638be Fix jumpts table, build array of handlers (wip)
unc0rr
parents: 10925
diff changeset
    28
               | PTCommand String HWProtocol
10902
29519fe63fdd Will use own tree type
unc0rr
parents: 10900
diff changeset
    29
10898
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    30
cmd = Command
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    31
cmd1 s p = Command s [p]
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    32
cmd2 s p1 p2 = Command s [p1, p2]
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    33
11047
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    34
cmdParams2str (Command _ p) = "TCmdParam" ++ concatMap f p
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    35
    where
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    36
    f Skip = ""
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    37
    f SS = "S"
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    38
    f LS = "L"
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    39
    f IntP = "i"
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    40
    f (Many p) = ""
11048
2edb24ed5ee0 Break it even more during refactoring
unC0Rr
parents: 11047
diff changeset
    41
2edb24ed5ee0 Break it even more during refactoring
unC0Rr
parents: 11047
diff changeset
    42
cmdParams2handlerType (Command _ p) = "handler_" ++ concatMap f p
2edb24ed5ee0 Break it even more during refactoring
unC0Rr
parents: 11047
diff changeset
    43
    where
2edb24ed5ee0 Break it even more during refactoring
unC0Rr
parents: 11047
diff changeset
    44
    f Skip = "_"
2edb24ed5ee0 Break it even more during refactoring
unC0Rr
parents: 11047
diff changeset
    45
    f SS = "S"
2edb24ed5ee0 Break it even more during refactoring
unC0Rr
parents: 11047
diff changeset
    46
    f LS = "L"
2edb24ed5ee0 Break it even more during refactoring
unC0Rr
parents: 11047
diff changeset
    47
    f IntP = "i"
2edb24ed5ee0 Break it even more during refactoring
unC0Rr
parents: 11047
diff changeset
    48
    f (Many p) = 'M' : concatMap f p
11050
9b7c8c5a94e0 Some fixes
unc0rr
parents: 11048
diff changeset
    49
11047
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    50
cmdParams2record cmd@(Command _ p) = renderStyle style{lineLength = 80} $ 
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    51
    text "type " <> text (cmdParams2str cmd)
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    52
    <> text " = record" $+$ nest 4 (
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    53
    vcat (map (uncurry f) $ zip [1..] $ filter isRendered p) 
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    54
    $+$ text "end;")
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    55
    where
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    56
    isRendered Skip = False
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    57
    isRendered (Many _) = False
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    58
    isRendered _ = True
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    59
    f n Skip = empty
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    60
    f n SS = text "str" <> int n <> text ": shortstring;"
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    61
    f n LS = text "str" <> int n <> text ": longstring;"
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    62
    f n IntP = text "param" <> int n <> text ": LongInt;"
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    63
    f _ (Many _) = empty
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    64
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
    65
commandsDescription = [
10898
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    66
        cmd "CONNECTED" [Skip, IntP]
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    67
        , cmd1 "NICK" SS
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    68
        , cmd1 "PROTO" IntP
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    69
        , cmd1 "ASKPASSWORD" SS
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    70
        , cmd1 "SERVER_AUTH" SS
10904
ce265b038220 Some more work on network client implementation
unc0rr
parents: 10902
diff changeset
    71
        , cmd1 "JOINING" SS
10929
8ebf01f75d9f Mockup of protocol parser
unc0rr
parents: 10927
diff changeset
    72
        , cmd1 "TEAM_ACCEPTED" SS
8ebf01f75d9f Mockup of protocol parser
unc0rr
parents: 10927
diff changeset
    73
        , cmd1 "HH_NUM" $ Many [SS]
8ebf01f75d9f Mockup of protocol parser
unc0rr
parents: 10927
diff changeset
    74
        , cmd1 "TEAM_COLOR" $ Many [SS]
8ebf01f75d9f Mockup of protocol parser
unc0rr
parents: 10927
diff changeset
    75
        , cmd1 "TEAM_ACCEPTED" SS
10904
ce265b038220 Some more work on network client implementation
unc0rr
parents: 10902
diff changeset
    76
        , cmd1 "BANLIST" $ Many [SS]
ce265b038220 Some more work on network client implementation
unc0rr
parents: 10902
diff changeset
    77
        , cmd1 "JOINED" $ Many [SS]
10898
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    78
        , cmd1 "LOBBY:JOINED" $ Many [SS]
10904
ce265b038220 Some more work on network client implementation
unc0rr
parents: 10902
diff changeset
    79
        , cmd2 "LOBBY:LEFT" SS LS
ce265b038220 Some more work on network client implementation
unc0rr
parents: 10902
diff changeset
    80
        , cmd2 "CLIENT_FLAGS" SS $ Many [SS]
ce265b038220 Some more work on network client implementation
unc0rr
parents: 10902
diff changeset
    81
        , cmd2 "LEFT" SS $ Many [SS]
10902
29519fe63fdd Will use own tree type
unc0rr
parents: 10900
diff changeset
    82
        , cmd1 "SERVER_MESSAGE" LS
11050
9b7c8c5a94e0 Some fixes
unc0rr
parents: 11048
diff changeset
    83
        , cmd1 "ERROR" LS
10929
8ebf01f75d9f Mockup of protocol parser
unc0rr
parents: 10927
diff changeset
    84
        , cmd1 "NOTICE" LS
8ebf01f75d9f Mockup of protocol parser
unc0rr
parents: 10927
diff changeset
    85
        , cmd1 "WARNING" LS
10904
ce265b038220 Some more work on network client implementation
unc0rr
parents: 10902
diff changeset
    86
        , cmd1 "EM" $ Many [LS]
ce265b038220 Some more work on network client implementation
unc0rr
parents: 10902
diff changeset
    87
        , cmd1 "PING" $ Many [SS]
ce265b038220 Some more work on network client implementation
unc0rr
parents: 10902
diff changeset
    88
        , cmd2 "CHAT" SS LS
ce265b038220 Some more work on network client implementation
unc0rr
parents: 10902
diff changeset
    89
        , cmd2 "SERVER_VARS" SS LS
ce265b038220 Some more work on network client implementation
unc0rr
parents: 10902
diff changeset
    90
        , cmd2 "BYE" SS LS
10908
1bd7a3a28b18 Try another approach, WIP
unc0rr
parents: 10906
diff changeset
    91
        , cmd1 "INFO" $ Many [SS]
10929
8ebf01f75d9f Mockup of protocol parser
unc0rr
parents: 10927
diff changeset
    92
        , cmd1 "ROOMS" $ Many [SS]
10904
ce265b038220 Some more work on network client implementation
unc0rr
parents: 10902
diff changeset
    93
        , cmd "KICKED" []
10929
8ebf01f75d9f Mockup of protocol parser
unc0rr
parents: 10927
diff changeset
    94
        , cmd "RUN_GAME" []
8ebf01f75d9f Mockup of protocol parser
unc0rr
parents: 10927
diff changeset
    95
        , cmd "ROUND_FINISHED" []
10898
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    96
    ]
f373838129c2 Some futher work on flib net client part
unc0rr
parents:
diff changeset
    97
10929
8ebf01f75d9f Mockup of protocol parser
unc0rr
parents: 10927
diff changeset
    98
unknowncmd = PTPrefix "$" [PTCommand "$" $ Command "__UNKNOWN__" [Many [SS]]]
8ebf01f75d9f Mockup of protocol parser
unc0rr
parents: 10927
diff changeset
    99
10927
336f5ad638be Fix jumpts table, build array of handlers (wip)
unc0rr
parents: 10925
diff changeset
   100
groupByFirstChar :: [ParseTree] -> [(Char, [ParseTree])]
10904
ce265b038220 Some more work on network client implementation
unc0rr
parents: 10902
diff changeset
   101
groupByFirstChar = MM.assocs . MM.fromList . map breakCmd
11050
9b7c8c5a94e0 Some fixes
unc0rr
parents: 11048
diff changeset
   102
    where
9b7c8c5a94e0 Some fixes
unc0rr
parents: 11048
diff changeset
   103
    breakCmd (PTCommand (c:cs) params) = (c, PTCommand cs params)
10902
29519fe63fdd Will use own tree type
unc0rr
parents: 10900
diff changeset
   104
10927
336f5ad638be Fix jumpts table, build array of handlers (wip)
unc0rr
parents: 10925
diff changeset
   105
makePT cmd@(Command n p) = PTCommand n cmd
336f5ad638be Fix jumpts table, build array of handlers (wip)
unc0rr
parents: 10925
diff changeset
   106
10929
8ebf01f75d9f Mockup of protocol parser
unc0rr
parents: 10927
diff changeset
   107
buildParseTree cmds = [PTPrefix "!" $ (bpt $ map makePT cmds) ++ [unknowncmd]]
11050
9b7c8c5a94e0 Some fixes
unc0rr
parents: 11048
diff changeset
   108
bpt cmds = if not . null $ fst emptyNamed then cmdLeaf emptyNamed else subtree
10904
ce265b038220 Some more work on network client implementation
unc0rr
parents: 10902
diff changeset
   109
    where
11050
9b7c8c5a94e0 Some fixes
unc0rr
parents: 11048
diff changeset
   110
        emptyNamed = partition (\(_, (PTCommand n _:_)) -> null n) assocs
10904
ce265b038220 Some more work on network client implementation
unc0rr
parents: 10902
diff changeset
   111
        assocs = groupByFirstChar cmds
10906
13fde38281fc Rendering some code
unc0rr
parents: 10904
diff changeset
   112
        subtree = map buildsub assocs
10925
be9ce3dc3739 Produce some useful code
unc0rr
parents: 10908
diff changeset
   113
        buildsub (c, cmds) = let st = bpt cmds in if null $ drop 1 st then maybeMerge c st else PTPrefix [c] st
10927
336f5ad638be Fix jumpts table, build array of handlers (wip)
unc0rr
parents: 10925
diff changeset
   114
        maybeMerge c cmd@[PTCommand {}] = PTPrefix [c] cmd
10906
13fde38281fc Rendering some code
unc0rr
parents: 10904
diff changeset
   115
        maybeMerge c cmd@[PTPrefix s ss] = PTPrefix (c:s) ss
11050
9b7c8c5a94e0 Some fixes
unc0rr
parents: 11048
diff changeset
   116
        cmdLeaf ([(c, (hwc:_))], assocs2) = (PTPrefix [c] [hwc]) : map buildsub assocs2
10906
13fde38281fc Rendering some code
unc0rr
parents: 10904
diff changeset
   117
13fde38281fc Rendering some code
unc0rr
parents: 10904
diff changeset
   118
dumpTree = vcat . map dt
13fde38281fc Rendering some code
unc0rr
parents: 10904
diff changeset
   119
    where
13fde38281fc Rendering some code
unc0rr
parents: 10904
diff changeset
   120
    dt (PTPrefix s st) = text s $$ (nest 1 $ vcat $ map dt st)
13fde38281fc Rendering some code
unc0rr
parents: 10904
diff changeset
   121
    dt _ = empty
10904
ce265b038220 Some more work on network client implementation
unc0rr
parents: 10902
diff changeset
   122
11047
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
   123
pas2 = buildSwitch $ buildParseTree commandsDescription
10906
13fde38281fc Rendering some code
unc0rr
parents: 10904
diff changeset
   124
    where
13fde38281fc Rendering some code
unc0rr
parents: 10904
diff changeset
   125
        buildSwitch cmds = text "case getNextChar of" $$ (nest 4 . vcat $ map buildCase cmds) $$ elsePart
10927
336f5ad638be Fix jumpts table, build array of handlers (wip)
unc0rr
parents: 10925
diff changeset
   126
        buildCase (PTCommand {}) = text "#10: <call cmd handler>;"
10906
13fde38281fc Rendering some code
unc0rr
parents: 10904
diff changeset
   127
        buildCase (PTPrefix (s:ss) cmds) = quotes (char s) <> text ": " <> consumePrefix ss (buildSwitch cmds)
13fde38281fc Rendering some code
unc0rr
parents: 10904
diff changeset
   128
        consumePrefix "" = id
13fde38281fc Rendering some code
unc0rr
parents: 10904
diff changeset
   129
        consumePrefix str = (text "consume" <> (parens . quotes $ text str) <> semi $$)
13fde38281fc Rendering some code
unc0rr
parents: 10904
diff changeset
   130
        zeroChar = text "#0: state:= pstDisconnected;"
13fde38281fc Rendering some code
unc0rr
parents: 10904
diff changeset
   131
        elsePart = text "else <unknown cmd> end;"
10904
ce265b038220 Some more work on network client implementation
unc0rr
parents: 10902
diff changeset
   132
11047
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
   133
renderArrays (letters, commands, handlers) = vcat $ punctuate (char '\n') [cmds, l, s, bodies, c, structs]
10908
1bd7a3a28b18 Try another approach, WIP
unc0rr
parents: 10906
diff changeset
   134
    where
11048
2edb24ed5ee0 Break it even more during refactoring
unC0Rr
parents: 11047
diff changeset
   135
        maybeQuotes "$" = text "#0"
10925
be9ce3dc3739 Produce some useful code
unc0rr
parents: 10908
diff changeset
   136
        maybeQuotes s = if null $ tail s then quotes $ text s else text s
be9ce3dc3739 Produce some useful code
unc0rr
parents: 10908
diff changeset
   137
        l = text "const letters: array[0.." <> (int $ length letters - 1) <> text "] of char = "
be9ce3dc3739 Produce some useful code
unc0rr
parents: 10908
diff changeset
   138
            <> parens (hsep . punctuate comma $ map maybeQuotes letters) <> semi
be9ce3dc3739 Produce some useful code
unc0rr
parents: 10908
diff changeset
   139
        s = text "const commands: array[0.." <> (int $ length commands - 1) <> text "] of integer = "
be9ce3dc3739 Produce some useful code
unc0rr
parents: 10908
diff changeset
   140
            <> parens (hsep . punctuate comma $ map text commands) <> semi
10929
8ebf01f75d9f Mockup of protocol parser
unc0rr
parents: 10927
diff changeset
   141
        c = text "const handlers: array[0.." <> (int $ length fixedNames - 1) <> text "] of PHandler = "
11048
2edb24ed5ee0 Break it even more during refactoring
unC0Rr
parents: 11047
diff changeset
   142
            <> parens (hsep . punctuate comma $ map (text . (:) '@') handlerTypes) <> semi
2edb24ed5ee0 Break it even more during refactoring
unC0Rr
parents: 11047
diff changeset
   143
        handlerTypes = map cmdParams2handlerType . reverse $ sort commandsDescription
10929
8ebf01f75d9f Mockup of protocol parser
unc0rr
parents: 10927
diff changeset
   144
        fixedNames = map fixName handlers
10927
336f5ad638be Fix jumpts table, build array of handlers (wip)
unc0rr
parents: 10925
diff changeset
   145
        fixName = map fixChar
336f5ad638be Fix jumpts table, build array of handlers (wip)
unc0rr
parents: 10925
diff changeset
   146
        fixChar c | isLetter c = c
336f5ad638be Fix jumpts table, build array of handlers (wip)
unc0rr
parents: 10925
diff changeset
   147
                  | otherwise = '_'
10929
8ebf01f75d9f Mockup of protocol parser
unc0rr
parents: 10927
diff changeset
   148
        bodies = vcat $ punctuate (char '\n') $ map handlerBody fixedNames
8ebf01f75d9f Mockup of protocol parser
unc0rr
parents: 10927
diff changeset
   149
        handlerBody n = text "procedure handler_" <> text n <> semi
8ebf01f75d9f Mockup of protocol parser
unc0rr
parents: 10927
diff changeset
   150
            $+$ text "begin" 
8ebf01f75d9f Mockup of protocol parser
unc0rr
parents: 10927
diff changeset
   151
            $+$ text "end" <> semi
10933
f1da4126a61c Some more work on flib network
unc0rr
parents: 10931
diff changeset
   152
        cmds = text "type TCmdType = " <> parens (hsep $ punctuate comma $ map ((<>) (text "cmd_") . text) $ reverse fixedNames) <> semi
11047
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
   153
        structs = vcat (map text . Set.toList . Set.fromList $ map cmdParams2record commandsDescription)
10908
1bd7a3a28b18 Try another approach, WIP
unc0rr
parents: 10906
diff changeset
   154
11047
46482475af2b Generate parameters structures
unC0Rr
parents: 10933
diff changeset
   155
pas = renderArrays $ buildTables $ buildParseTree commandsDescription
10925
be9ce3dc3739 Produce some useful code
unc0rr
parents: 10908
diff changeset
   156
    where
10927
336f5ad638be Fix jumpts table, build array of handlers (wip)
unc0rr
parents: 10925
diff changeset
   157
        buildTables cmds = let (_, _, _, t1, t2, t3) = foldr walk (0, [0], -10, [], [], [[]]) cmds in (tail t1, tail t2, concat t3)
336f5ad638be Fix jumpts table, build array of handlers (wip)
unc0rr
parents: 10925
diff changeset
   158
        walk (PTCommand _ (Command n params)) (lc, s:sh, pc, tbl1, tbl2, (t3:tbl3)) =
10931
384765cd0caf Parse net commands, answer to pings
unc0rr
parents: 10929
diff changeset
   159
            (lc, 1:sh, pc - 1, "#10":tbl1, show pc:tbl2, (n:t3):tbl3)
10925
be9ce3dc3739 Produce some useful code
unc0rr
parents: 10908
diff changeset
   160
        walk (PTPrefix prefix cmds) l = lvldown $ foldr fpf (foldr walk (lvlup l) cmds) prefix
10927
336f5ad638be Fix jumpts table, build array of handlers (wip)
unc0rr
parents: 10925
diff changeset
   161
        lvlup (lc, sh, pc, tbl1, tbl2, tbl3) = (lc, 0:sh, pc, tbl1, tbl2, []:tbl3)
336f5ad638be Fix jumpts table, build array of handlers (wip)
unc0rr
parents: 10925
diff changeset
   162
        lvldown (lc, s1:s2:sh, pc, tbl1, t:tbl2, t31:t32:tbl3) = (lc, s1+s2:sh, pc, tbl1, (if null t32 then "0" else show s1):tbl2, (t31 ++ t32):tbl3)
336f5ad638be Fix jumpts table, build array of handlers (wip)
unc0rr
parents: 10925
diff changeset
   163
        fpf c (lc, s:sh, pc, tbl1, tbl2, tbl3) = (lc + 1, s+1:sh, pc, [c]:tbl1, "0":tbl2, tbl3)
10925
be9ce3dc3739 Produce some useful code
unc0rr
parents: 10908
diff changeset
   164
11050
9b7c8c5a94e0 Some fixes
unc0rr
parents: 11048
diff changeset
   165
main =
9b7c8c5a94e0 Some fixes
unc0rr
parents: 11048
diff changeset
   166
    putStrLn $ renderStyle style{lineLength = 80} $ pas
9b7c8c5a94e0 Some fixes
unc0rr
parents: 11048
diff changeset
   167
    --putStrLn $ renderStyle style{lineLength = 80} $ dumpTree $ buildParseTree commandsDescription