mirror of
https://github.com/mrkkrp/megaparsec.git
synced 2024-12-24 16:51:38 +03:00
parent
3276ef770c
commit
fd8ecf5d03
@ -448,7 +448,7 @@ makeTokenParser languageDef
|
||||
|
||||
charControl = do{ char '^'
|
||||
; code <- upper
|
||||
; return (toEnum (fromEnum code - fromEnum 'A'))
|
||||
; return (toEnum (fromEnum code - fromEnum 'A' + 1))
|
||||
}
|
||||
|
||||
charNum = do{ code <- decimal
|
||||
|
15
parsec.cabal
15
parsec.cabal
@ -1,6 +1,6 @@
|
||||
name: parsec
|
||||
version: 3.1.6
|
||||
cabal-version: >= 1.6
|
||||
cabal-version: >= 1.8
|
||||
license: BSD3
|
||||
license-file: LICENSE
|
||||
author: Daan Leijen <daan@microsoft.com>, Paolo Martini <paolo@nemail.it>
|
||||
@ -63,3 +63,16 @@ library
|
||||
build-depends: mtl, bytestring, text >= 0.2 && < 1.3
|
||||
extensions: ExistentialQuantification, PolymorphicComponents, MultiParamTypeClasses, FlexibleInstances, FlexibleContexts, DeriveDataTypeable, CPP
|
||||
ghc-options: -O2
|
||||
|
||||
Test-Suite tests
|
||||
type: exitcode-stdio-1.0
|
||||
hs-source-dirs: test
|
||||
main-is: Main.hs
|
||||
other-modules:
|
||||
Tokens
|
||||
build-depends:
|
||||
base,
|
||||
parsec,
|
||||
HUnit == 1.2.*,
|
||||
test-framework >= 0.6 && < 0.9,
|
||||
test-framework-hunit >= 0.2 && < 0.4
|
10
test/Main.hs
Normal file
10
test/Main.hs
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
import Test.Framework
|
||||
|
||||
import Tokens ( tokensTests )
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
defaultMain
|
||||
[ testGroup "Text.Parsec.Tokens" tokensTests
|
||||
]
|
29
test/Tokens.hs
Normal file
29
test/Tokens.hs
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
module Tokens
|
||||
( tokensTests
|
||||
) where
|
||||
|
||||
import Test.HUnit hiding ( Test )
|
||||
import Test.Framework
|
||||
import Test.Framework.Providers.HUnit
|
||||
|
||||
import Text.Parsec
|
||||
import Text.Parsec.String
|
||||
import qualified Text.Parsec.Token as P
|
||||
import Text.Parsec.Language (haskellDef)
|
||||
|
||||
tokensTests :: [Test]
|
||||
tokensTests =
|
||||
return $
|
||||
testCase "Control Char Parsing" $
|
||||
parseString "\"test\\^Bstring\"" @?= "test\^Bstring"
|
||||
|
||||
where
|
||||
parseString :: String -> String
|
||||
parseString input =
|
||||
case parse parser "Example" input of
|
||||
Left{} -> error "Parse failure"
|
||||
Right str -> str
|
||||
|
||||
parser :: Parser String
|
||||
parser = P.stringLiteral $ P.makeTokenParser haskellDef
|
Loading…
Reference in New Issue
Block a user