@@ -320,7 +320,7 @@ encodeStartCodes scan = (scan', 0 : map snd name_code_pairs, sc_hdr)
320320-- generated file.
321321
322322extractActions :: Scheme -> Scanner -> (Scanner ,ShowS )
323- extractActions scheme scanner = (scanner{scannerTokens = new_tokens}, decl_str)
323+ extractActions scheme scanner = (scanner{scannerTokens = new_tokens}, decl_str . nl )
324324 where
325325 (new_tokens, decls) = unzip (zipWith f (scannerTokens scanner) act_names)
326326
@@ -333,61 +333,57 @@ extractActions scheme scanner = (scanner{scannerTokens = new_tokens}, decl_str)
333333 str " AlexPosn -> Char -> String -> Int -> ((Int, state) -> "
334334 . str res . str " ) -> (Int, state) -> " . str res
335335
336- mkDecl fun code = case scheme of
337- Default { defaultTypeInfo = Just (Nothing , actionty) } ->
338- str fun . str " :: " . str actionty . str " \n "
339- . str fun . str " = " . str code . nl
340- Default { defaultTypeInfo = Just (Just tyclasses, actionty) } ->
336+ mkDecl fun code = mkTySig fun
337+ . mkDef fun code
338+
339+ mkDef fun code = str fun . str " = " . str code . nl
340+
341+ mkTySig fun = case scheme of
342+ Default { defaultTypeInfo = Just (Nothing , actionty) } -> nl .
343+ str fun . str " :: " . str actionty . nl
344+ Default { defaultTypeInfo = Just (Just tyclasses, actionty) } -> nl .
341345 str fun . str " :: (" . str tyclasses . str " ) => " .
342- str actionty . str " \n " .
343- str fun . str " = " . str code . nl
344- GScan { gscanTypeInfo = Just (Nothing , tokenty) } ->
345- str fun . str " :: " . gscanActionType tokenty . str " \n "
346- . str fun . str " = " . str code . nl
347- GScan { gscanTypeInfo = Just (Just tyclasses, tokenty) } ->
346+ str actionty . nl
347+ GScan { gscanTypeInfo = Just (Nothing , tokenty) } -> nl .
348+ str fun . str " :: " . gscanActionType tokenty . nl
349+ GScan { gscanTypeInfo = Just (Just tyclasses, tokenty) } -> nl .
348350 str fun . str " :: (" . str tyclasses . str " ) => " .
349- gscanActionType tokenty . str " \n " .
350- str fun . str " = " . str code . nl
351- Basic { basicStrType = strty, basicTypeInfo = Just (Nothing , tokenty) } ->
351+ gscanActionType tokenty . nl
352+ Basic { basicStrType = strty, basicTypeInfo = Just (Nothing , tokenty) } -> nl .
352353 str fun . str " :: " . str (show strty) . str " -> "
353- . str tokenty . str " \n "
354- . str fun . str " = " . str code . nl
354+ . str tokenty . nl
355355 Basic { basicStrType = strty,
356- basicTypeInfo = Just (Just tyclasses, tokenty) } ->
356+ basicTypeInfo = Just (Just tyclasses, tokenty) } -> nl .
357357 str fun . str " :: (" . str tyclasses . str " ) => " .
358- str (show strty) . str " -> " . str tokenty . str " \n " .
359- str fun . str " = " . str code . nl
358+ str (show strty) . str " -> " . str tokenty . nl
360359 Posn { posnByteString = isByteString,
361- posnTypeInfo = Just (Nothing , tokenty) } ->
360+ posnTypeInfo = Just (Nothing , tokenty) } -> nl .
362361 str fun . str " :: AlexPosn -> " . str (strtype isByteString) . str " -> "
363- . str tokenty . str " \n "
364- . str fun . str " = " . str code . nl
362+ . str tokenty . nl
365363 Posn { posnByteString = isByteString,
366- posnTypeInfo = Just (Just tyclasses, tokenty) } ->
364+ posnTypeInfo = Just (Just tyclasses, tokenty) } -> nl .
367365 str fun . str " :: (" . str tyclasses . str " ) => AlexPosn -> " .
368- str (strtype isByteString) . str " -> " . str tokenty . str " \n " .
369- str fun . str " = " . str code . nl
366+ str (strtype isByteString) . str " -> " . str tokenty . nl
370367 Monad { monadByteString = isByteString,
371- monadTypeInfo = Just (Nothing , tokenty) } ->
368+ monadTypeInfo = Just (Nothing , tokenty) } -> nl .
372369 let
373370 actintty = if isByteString then " Int64" else " Int"
374371 in
375372 str fun . str " :: AlexInput -> " . str actintty . str " -> Alex ("
376- . str tokenty . str " )\n "
377- . str fun . str " = " . str code . nl
373+ . str tokenty . str " )" . nl
378374 Monad { monadByteString = isByteString,
379- monadTypeInfo = Just (Just tyclasses, tokenty) } ->
375+ monadTypeInfo = Just (Just tyclasses, tokenty) } -> nl .
380376 let
381377 actintty = if isByteString then " Int64" else " Int"
382378 in
383- str fun . str " :: (" . str tyclasses . str " ) => "
379+ str fun . str " :: (" . str tyclasses . str " ) =>"
384380 . str " AlexInput -> " . str actintty
385- . str " -> Alex (" . str tokenty . str " )\n "
386- . str fun . str " = " . str code . nl
387- _ -> str fun . str " = " . str code . nl
381+ . str " -> Alex (" . str tokenty . str " )" . nl
382+ _ -> id
388383
389384 act_names = map (\ n -> " alex_action_" ++ show (n:: Int )) [0 .. ]
390385
386+ decl_str :: ShowS
391387 decl_str = foldr (.) id [ decl | Just decl <- decls ]
392388
393389-- -----------------------------------------------------------------------------
0 commit comments