branch | qmlfrontend |
changeset 10933 | f1da4126a61c |
parent 10931 | 384765cd0caf |
child 11047 | 46482475af2b |
10931:384765cd0caf | 10933:f1da4126a61c |
---|---|
107 fixChar c | isLetter c = c |
107 fixChar c | isLetter c = c |
108 | otherwise = '_' |
108 | otherwise = '_' |
109 bodies = vcat $ punctuate (char '\n') $ map handlerBody fixedNames |
109 bodies = vcat $ punctuate (char '\n') $ map handlerBody fixedNames |
110 handlerBody n = text "procedure handler_" <> text n <> semi |
110 handlerBody n = text "procedure handler_" <> text n <> semi |
111 $+$ text "begin" |
111 $+$ text "begin" |
112 $+$ nest 4 ( |
|
113 text "state.cmd:= cmd_" <> text n <> semi |
|
114 ) |
|
115 $+$ text "end" <> semi |
112 $+$ text "end" <> semi |
116 cmds = text "type TCmdType = " <> parens (hsep $ punctuate comma $ map ((<>) (text "cmd_") . text) fixedNames) <> semi |
113 cmds = text "type TCmdType = " <> parens (hsep $ punctuate comma $ map ((<>) (text "cmd_") . text) $ reverse fixedNames) <> semi |
117 |
114 |
118 pas = renderArrays $ buildTables $ buildParseTree commands |
115 pas = renderArrays $ buildTables $ buildParseTree commands |
119 where |
116 where |
120 buildTables cmds = let (_, _, _, t1, t2, t3) = foldr walk (0, [0], -10, [], [], [[]]) cmds in (tail t1, tail t2, concat t3) |
117 buildTables cmds = let (_, _, _, t1, t2, t3) = foldr walk (0, [0], -10, [], [], [[]]) cmds in (tail t1, tail t2, concat t3) |
121 walk (PTCommand _ (Command n params)) (lc, s:sh, pc, tbl1, tbl2, (t3:tbl3)) = |
118 walk (PTCommand _ (Command n params)) (lc, s:sh, pc, tbl1, tbl2, (t3:tbl3)) = |