/[gentoo-x86]/dev-haskell/alex/files/alex-2.3.5-missing-test.patch
Gentoo

Contents of /dev-haskell/alex/files/alex-2.3.5-missing-test.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download) (as text)
Sun Jul 31 15:38:07 2011 UTC (9 years, 4 months ago) by slyfox
Branch: MAIN
File MIME type: text/x-diff
Version bump. Added tests support.

(Portage version: 2.1.10.7/cvs/Linux x86_64)

1 commit 883587ca4feecab72381991533b2f686a57a4d57
2 Author: Sergei Trofimovich <slyfox@gentoo.org>
3 Date: Mon Jul 25 08:20:13 2011 +0300
4
5 added missing tokens_bytestring test
6
7 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
8
9 diff --git a/alex.cabal b/alex.cabal
10 index b262af7..c6f6e22 100644
11 --- a/alex.cabal
12 +++ b/alex.cabal
13 @@ -57,6 +57,7 @@ extra-source-files:
14 tests/tokens.x
15 tests/tokens_gscan.x
16 tests/tokens_posn.x
17 + tests/tokens_bytestring.x
18
19 flag small_base
20 description: Choose the new smaller, split-up base package.
21 diff --git a/tests/tokens_bytestring.x b/tests/tokens_bytestring.x
22 new file mode 100644
23 index 0000000..0cb23c8
24 --- /dev/null
25 +++ b/tests/tokens_bytestring.x
26 @@ -0,0 +1,46 @@
27 +{
28 +{-# LANGUAGE OverloadedStrings #-}
29 +module Main (main) where
30 +import System.Exit
31 +import Data.ByteString.Lazy.Char8 (unpack)
32 +}
33 +
34 +%wrapper "posn-bytestring"
35 +
36 +$digit = 0-9 -- digits
37 +$alpha = [a-zA-Z] -- alphabetic characters
38 +
39 +tokens :-
40 +
41 + $white+ ;
42 + "--".* ;
43 + let { tok (\p s -> Let p) }
44 + in { tok (\p s -> In p) }
45 + $digit+ { tok (\p s -> Int p (read (unpack s))) }
46 + [\=\+\-\*\/\(\)] { tok (\p s -> Sym p (head (unpack s))) }
47 + $alpha [$alpha $digit \_ \']* { tok (\p s -> Var p (unpack s)) }
48 +
49 +{
50 +-- Each right-hand side has type :: AlexPosn -> String -> Token
51 +
52 +-- Some action helpers:
53 +tok f p s = f p s
54 +
55 +-- The token type:
56 +data Token =
57 + Let AlexPosn |
58 + In AlexPosn |
59 + Sym AlexPosn Char |
60 + Var AlexPosn String |
61 + Int AlexPosn Int |
62 + Err AlexPosn
63 + deriving (Eq,Show)
64 +
65 +main = if test1 /= result1 then exitFailure
66 + else exitWith ExitSuccess
67 +
68 +test1 = alexScanTokens " let in 012334\n=+*foo bar__'"
69 +result1 = [Let (AlexPn 2 1 3),In (AlexPn 6 1 7),Int (AlexPn 9 1 10) 12334,Sym (AlexPn 16 2 1) '=',Sym (AlexPn 17 2 2) '+',Sym (AlexPn 18 2 3) '*',Var (AlexPn 19 2 4) "foo",Var (AlexPn 23 2 8) "bar__'"]
70 +
71 +
72 +}

  ViewVC Help
Powered by ViewVC 1.1.20