@@ -320,7 +320,7 @@ encodeStartCodes scan = (scan', 0 : map snd name_code_pairs, sc_hdr)
320
320
-- generated file.
321
321
322
322
extractActions :: 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 )
324
324
where
325
325
(new_tokens, decls) = unzip (zipWith f (scannerTokens scanner) act_names)
326
326
@@ -333,61 +333,57 @@ extractActions scheme scanner = (scanner{scannerTokens = new_tokens}, decl_str)
333
333
str " AlexPosn -> Char -> String -> Int -> ((Int, state) -> "
334
334
. str res . str " ) -> (Int, state) -> " . str res
335
335
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 .
341
345
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 .
348
350
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 .
352
353
str fun . str " :: " . str (show strty) . str " -> "
353
- . str tokenty . str " \n "
354
- . str fun . str " = " . str code . nl
354
+ . str tokenty . nl
355
355
Basic { basicStrType = strty,
356
- basicTypeInfo = Just (Just tyclasses, tokenty) } ->
356
+ basicTypeInfo = Just (Just tyclasses, tokenty) } -> nl .
357
357
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
360
359
Posn { posnByteString = isByteString,
361
- posnTypeInfo = Just (Nothing , tokenty) } ->
360
+ posnTypeInfo = Just (Nothing , tokenty) } -> nl .
362
361
str fun . str " :: AlexPosn -> " . str (strtype isByteString) . str " -> "
363
- . str tokenty . str " \n "
364
- . str fun . str " = " . str code . nl
362
+ . str tokenty . nl
365
363
Posn { posnByteString = isByteString,
366
- posnTypeInfo = Just (Just tyclasses, tokenty) } ->
364
+ posnTypeInfo = Just (Just tyclasses, tokenty) } -> nl .
367
365
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
370
367
Monad { monadByteString = isByteString,
371
- monadTypeInfo = Just (Nothing , tokenty) } ->
368
+ monadTypeInfo = Just (Nothing , tokenty) } -> nl .
372
369
let
373
370
actintty = if isByteString then " Int64" else " Int"
374
371
in
375
372
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
378
374
Monad { monadByteString = isByteString,
379
- monadTypeInfo = Just (Just tyclasses, tokenty) } ->
375
+ monadTypeInfo = Just (Just tyclasses, tokenty) } -> nl .
380
376
let
381
377
actintty = if isByteString then " Int64" else " Int"
382
378
in
383
- str fun . str " :: (" . str tyclasses . str " ) => "
379
+ str fun . str " :: (" . str tyclasses . str " ) =>"
384
380
. 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
388
383
389
384
act_names = map (\ n -> " alex_action_" ++ show (n:: Int )) [0 .. ]
390
385
386
+ decl_str :: ShowS
391
387
decl_str = foldr (.) id [ decl | Just decl <- decls ]
392
388
393
389
-- -----------------------------------------------------------------------------
0 commit comments