ChristmasTree 0.2.1 → 0.2.1.1
raw patch · 11 files changed
+36/−386 lines, 11 filesdep −haskell98dep ~fglnew-uploaderPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies removed: haskell98
Dependency ranges changed: fgl
API changes (from Hackage documentation)
- Text.GRead: instance (Show a) => Show (GReadResult a)
+ Text.GRead: instance Show a => Show (GReadResult a)
- Text.GRead: gread :: (Gram a) => String -> GReadResult a
+ Text.GRead: gread :: Gram a => String -> GReadResult a
- Text.GRead.Grammar: grammar :: (Gram a) => DGrammar a
+ Text.GRead.Grammar: grammar :: Gram a => DGrammar a
- Text.GShow: gshow :: (GShow a) => a -> String
+ Text.GShow: gshow :: GShow a => a -> String
- Text.GShow: gshowsPrec :: (GShow a) => Int -> a -> ShowS
+ Text.GShow: gshowsPrec :: GShow a => Int -> a -> ShowS
Files
- ChristmasTree.cabal +20/−14
- examples/Test.hs +0/−127
- examples/Test2.hs +0/−45
- examples/TestDerive.hs +0/−128
- examples/TestShow.hs +0/−62
- src/Text/GRead.hs +4/−2
- src/Text/GRead/Grammar.hs +2/−2
- src/Text/GRead/Transformations/GramTrafo.hs +1/−1
- src/Text/GRead/Transformations/Group.hs +6/−3
- src/Text/GRead/Transformations/LeftCorner.hs +1/−1
- src/Text/GRead/Transformations/LeftFact.hs +2/−1
ChristmasTree.cabal view
@@ -1,7 +1,7 @@-cabal-version: >=1.2.3+cabal-version: >=1.2.3.1 build-type: Simple name: ChristmasTree-version: 0.2.1+version: 0.2.1.1 license: LGPL license-file: COPYRIGHT maintainer: Marcos Viera <mviera@fing.edu.uy>@@ -11,16 +11,22 @@ category: Parsing stability: Experimental copyright: Universiteit Utrecht-build-depends: base >= 4 && < 5, haskell98, template-haskell >= 2.4, containers,- fgl == 5.4.2.2, TTTAS >= 0.4 , uulib >= 0.9.11 -exposed-modules: Text.GRead, Text.GShow, - Text.GRead.Derive, Text.GRead.Grammar,- Text.GRead.Derive.BindingGroup,- Text.GRead.Transformations.GramTrafo, - Text.GRead.Transformations.Group, - Text.GRead.Transformations.LeftCorner,- Text.GRead.Transformations.LeftFact -extensions: Arrows, GADTs, TemplateHaskell-hs-source-dirs: src extra-source-files: README, LICENSE-LGPL, ChristmasTree.bib-ghc-options: -Wall++library+ exposed-modules: Text.GRead, Text.GShow, + Text.GRead.Derive, Text.GRead.Grammar,+ Text.GRead.Derive.BindingGroup,+ Text.GRead.Transformations.GramTrafo, + Text.GRead.Transformations.Group, + Text.GRead.Transformations.LeftCorner,+ Text.GRead.Transformations.LeftFact + build-depends: base >= 4 && < 5, template-haskell >= 2.4, containers,+ fgl >= 5.4.2 && < 5.4.3, TTTAS >= 0.4 , uulib >= 0.9.11 + extensions: Arrows, GADTs, TemplateHaskell+ hs-source-dirs: src+++ ++
− examples/Test.hs
@@ -1,127 +0,0 @@-module Test where--import Text.GRead-import Language.AbstractSyntax.TTTAS--infixl 5 :<:, :+:-infixr 6 :>:, :*:--data T1 = T1 :<: T1- | T1 :>: T1- | C1- deriving (Read, Show)--data T2 a = T2 a :+: T2 a- | a :*: T2 a- | C2- deriving (Read, Show)--data T3 = T3 T4 | C3- deriving (Read, Show)-data T4 = T4 T3 | C4- deriving (Read, Show)---_0 = Zero-_1 = Suc _0-_2 = Suc _1---instance Gram T1 where- grammar = DGrammar _0 envT1--envT1 :: Env DGram ((),T1) ((),T1) -envT1 = consD (nonts _0) Empty - where- nonts _T1 = DLNontDefs- [ ( DRef (_T1, 5) - , DPS [ dNont (_T1, 5) .#. dTerm ":<:" .#.- dNont (_T1, 6) .#. dEnd infixL ]- )- , ( DRef (_T1, 6) - , DPS [ dNont (_T1, 7) .#. dTerm ":>:" .#.- dNont (_T1, 6) .#. dEnd infixR ] - ) - , ( DRef (_T1,10) - , DPS [ dTerm "C1" .#. dEnd (const C1)- , dTerm "(" .#. dNont (_T1,0) .#. - dTerm ")" .#. dEnd parenT ] - )- ]- infixL e1 _ e2 = e2 :<: e1- infixR e1 _ e2 = e2 :>: e1 ---instance Gram a => Gram (T2 a) where- grammar = DGrammar _0 envT2 --envT2 :: (Gram a) => Env DGram (((),a),T2 a)- (((),a),T2 a)-envT2 = consD (nonts _0 _1) $ - consG grammar Empty- where- nonts _T2 _A = DLNontDefs- [ ( DRef (_T2, 5) - , DPS [ dNont (_T2, 6) .#. dTerm ":+:" .#.- dNont (_T2, 6) .#. dEnd infixP ] - )- , ( DRef (_T2, 6)- , DPS [ dNont (_A, 7) .#. dTerm ":*:" .#. - dNont (_T2, 7) .#. dEnd infixT ] - )- , ( DRef (_T2,10) - , DPS [ dTerm "C2" .#. dEnd (const C2)- , dTerm "(" .#. dNont (_T2,0) .#. - dTerm ")" .#. dEnd parenT ] - )- ]- infixP e1 _ e2 = e2 :+: e1- infixT e1 _ e2 = e2 :*: e1 --envT3T4 :: Env DGram (((), T4), T3) (((), T4), T3)-envT3T4 = consD (nonts3 _0 _1) $- consD (nonts4 _1 _0) Empty - where- nonts3 _T3 _T4 = DLNontDefs- [ ( DRef (_T3,10) - , DPS [ dTerm "T3" .#. dNont (_T4,0) .#. - dEnd consT3 - , dTerm "C3" .#. dEnd (const C3) - , dTerm "(" .#. dNont (_T3,0) .#. - dTerm ")" .#. dEnd parenT - ]- )- ]- nonts4 _T4 _T3 = DLNontDefs- [ ( DRef (_T4,10) - , DPS [ dTerm "T4" .#. dNont (_T3,0) .#. - dEnd consT4 - , dTerm "C4" .#. dEnd (const C4) - , dTerm "(" .#. dNont (_T4,0) .#. - dTerm ")" .#. dEnd parenT - ]- )- ]- consT3 a = const (T3 a) - consT4 a = const (T4 a) --instance Gram T3 where- grammar = DGrammar _0 envT3T4--instance Gram T4 where- grammar = DGrammar _1 envT3T4--read' :: (Gram a) => String -> a-read' input = case gread input of- Ok a -> a- Rep _ (m:_) -> error $ show m--v1 = read' "C1 :>: C1 :>: C1" :: T1-v2 = read' "C1 :<: C1 :<: C1" :: T1-v3 = read' "C1 :>: C1 :<: C1 :>: C1" :: T1-v4 = read' "(((((((((((((C1)))))))))))))" :: T1-v5 = read' "(C1 :>: C1) :*: C2 :+: C2" :: T2 T1-v6 = read' "T3 T4 T3 T4 C3" :: T3-v7 = read' "T4 T3 T4 T3 T4 C3" :: T4-v8 = read' "bla" :: T1 -- error-
− examples/Test2.hs
@@ -1,45 +0,0 @@-{-# OPTIONS -XScopedTypeVariables -XRankNTypes #-}-{-# LANGUAGE TemplateHaskell #-}--module Test2 where--import Text.GRead-import Text.GRead.Derive--infixl 5 :<:, :+:-infixr 6 :>:, :*:--data T1 = T1 :<: T1- | T1 :>: T1- | C1- deriving (Read, Show)--data T2 a = T2 a :+: T2 a- | a :*: T2 a- | C2- deriving (Read, Show)--data T3 = T3 T4 | C3- deriving (Read, Show)-data T4 = T4 T3 | C4- deriving (Read, Show)--$(deriveGrammar ''T1)-$(deriveGrammar ''T2)-$(deriveGrammar ''T3)-$(deriveGrammar ''T4)--read' :: (Gram a) => String -> a-read' input = case gread input of- Ok a -> a- Rep _ (m:_) -> error $ show m--v1 = read' "C1 :>: C1 :>: C1" :: T1-v2 = read' "C1 :<: C1 :<: C1" :: T1-v3 = read' "C1 :>: C1 :<: C1 :>: C1" :: T1-v4 = read' "(((((((((((((C1)))))))))))))" :: T1-v5 = read' "(C1 :>: C1) :*: C2 :+: C2" :: T2 T1-v6 = read' "T3 T4 T3 T4 C3" :: T3-v7 = read' "T4 T3 T4 T3 T4 C3" :: T4-v8 = read' "bla" :: T1 -- error-
− examples/TestDerive.hs
@@ -1,128 +0,0 @@-{-# OPTIONS -XScopedTypeVariables -XRank2Types #-}-{-# LANGUAGE TemplateHaskell #-}-module TestDerive where--import Text.GRead-import Text.GRead.Derive---data T1 = T1 :<: T1- | T1 :>: T1- | C1- deriving Show--data T2 a = T2 a :+: T2 a- | a :*: T2 a- | C2- deriving Show--data T3 = T3 T4 | C3- deriving Show--data T4 = T4 T3 | C4- deriving Show--data T5 = T5 T6 | C5- deriving Show--data T6 = T6 T7- deriving Show--data T7 = T7 T5- deriving Show--data T8 = T8 (T2 T8) - | C8- deriving Show--data T9 = T9 (T2 T10) - | C9- deriving Show--data T10 = T10 T9- deriving Show--data T11 = T11 (T2 T11) - (T2 T12) - deriving Show--data T12 = T12 T11- deriving Show--data T13 = T13- deriving Show--data T14 a b = T14 a b- deriving Show--data T15 = T15 :-: T1- | C15--data T16 = T1 :.: T16- | C16---$(deriveGrammar ''T1)-$(deriveGrammar ''T2)-$(deriveGrammar ''T3)-$(deriveGrammar ''T4)-$(deriveGrammar ''T5)-$(deriveGrammar ''T6)-$(deriveGrammar ''T7)-$(deriveGrammar ''T8)-$(deriveGrammar ''T9)-$(deriveGrammar ''T10)-$(deriveGrammar ''T11)-$(deriveGrammar ''T12)--$(deriveGrammar ''T13)--$(deriveGrammar ''T14)--- $(deriveGrammar ''T15) -- doesn't work--- $(deriveGrammar ''T16) -- doesn't work---data BT a b c d e - = BT (BT a b c d e) (BT a b c d e) - | O_A a | O_B b | O_C c | O_D d | O_E e - | O_movl | O_movw | O_movb | O_movzbw | O_movzbl | O_movzwl - | O_movsbw | O_movsbl | O_movswl | O_pushl | O_popl - | O_pushfl | O_popfl | O_notl | O_notw | O_notb | O_sall | O_salw | O_salb- | O_sarl | O_sarw | O_sarb | O_shrl | O_shrw | O_shrb- | O_roll | O_rolw | O_rolb | O_rorl | O_rorw | O_rorb- | O_shldl | O_shrdl | O_addl | O_addw | O_addb- | O_adcl | O_subl | O_subw | O_subb | O_sbbl- | O_imull | O_imulw | O_imulb | O_mull | O_divl | O_divw | O_divb- | O_idivl | O_xorl | O_xorw | O_xorb | O_andl | O_andw | O_andb- | O_orl | O_orw | O_orb | O_incl | O_incw | O_incb- | O_decl | O_decw | O_decb | O_negl | O_negw | O_negb- | O_testl | O_testw | O_testb | O_leal | O_cmpl | O_cmpw | O_cmpb- | O_cmpsb | O_scasb | O_movsl | O_movsw | O_movsb- | O_stosl | O_stosw | O_stosb | O_leave | O_ret | O_call | O_jmp- | O_je | O_jne | O_jl | O_jle | O_jg | O_jge | O_js | O_jns- | O_jz | O_jnz | O_jc | O_jnc | O_jo | O_jno | O_ja | O_jae- | O_jb | O_jbe | O_jp | O_seta | O_setae | O_setb | O_setbe- | O_sete | O_setne | O_setl | O_setle | O_setg | O_setge- | O_setc | O_setcb | O_btl | O_btsl | O_btrl | O_btcl- | O_cld | O_cltd | O_cwtl | O_cbtw | O_rep | O_repz | O_repnz- | O_fild | O_fildl | O_fildll | O_fsubp | O_fsubr | O_fsubrp - | O_fsubrl | O_fsubrs | O_fsubs | O_fsubl | O_fsub- | O_faddp | O_fadds | O_faddl | O_fadd | O_fiaddl- | O_fmul | O_fmuls | O_fmull | O_fmulp- | O_fimull | O_fdiv | O_fdivp | O_fdivr | O_fdivrs | O_fdivrl | O_fdivrp- | O_fidivl | O_fidivrl | O_fdivl | O_fdivs- | O_fprem | O_fstp | O_fsts | O_fstps | O_fstl | O_fstpl | O_fstpt | O_fst- | O_fistl | O_fistpl | O_fistpll- | O_fld | O_flds | O_fldl | O_fldt | O_fldz | O_fld1 | O_fldl2e | O_fldln2- | O_fchs | O_fsin | O_fcos | O_fptan | O_fsqrt | O_fpatan | O_fabs- | O_f2xm1 | O_fscale | O_fyl2x- | O_fucom | O_fucomp | O_fucompp- | O_fcomp | O_fcompp | O_fcoml | O_fcompl | O_ficompl- | O_fcoms | O_fcom | O_fcomps | O_fnstsw | O_fnstcw - | O_fldcw | O_frndint | O_fxch | O_sahf | O_nop- deriving (Show, Eq, Read)--$(deriveGrammar ''BT)---res = gread "BT O_nop BT (O_B T10 C9) (O_E T14 C1 C3)" :: GReadResult (BT T1 T10 T11 T12 (T14 T1 T3))
− examples/TestShow.hs
@@ -1,62 +0,0 @@-{-# OPTIONS -XScopedTypeVariables -XRank2Types #-}-{-# LANGUAGE TemplateHaskell #-}--module TestShow where--import Text.GRead-import Text.GRead.Derive--import Text.GShow--import Language.Haskell.TH-import Language.Haskell.TH.Syntax---data T1 = T1- deriving Show-$(deriveShow ''T1)--s1 = gshow T1--data T2 a = T2--$(deriveShow ''T2)--s2 = gshow (T2 :: (T2 T1))--data T3 a = T3 a- deriving Show--$(deriveShow ''T3)--s3 = gshow $ T3 T1--infixl 5 :<:-infixr 6 :>:--data T4 a = T4 a :<: a- | T4 a :>: T4 a- | C4- deriving Show--data T5 = T5- deriving Show--$(deriveShow ''T4)-$(deriveShow ''T5)--s41 = gshow (C4 :>: C4 :>: C4 :>: C4 :: T4 T5)-s42 = gshow ((C4 :>: C4) :>: C4 :: T4 T5)-s43 = gshow (C4 :>: (C4 :>: C4) :: T4 T5)-s44 = gshow (C4 :>: C4 :>: C4 :<: T5 :: T4 T5)-s45 = gshow (C4 :>: C4 :>: C4 :<: T5 :<: T5 :: T4 T5)--$(deriveGrammar ''T4)-$(deriveGrammar ''T5)--v41 = gread s41 :: GReadResult (T4 T5)-v42 = gread s42 :: GReadResult (T4 T5)-v43 = gread s43 :: GReadResult (T4 T5)-v44 = gread s44 :: GReadResult (T4 T5)-v45 = gread s45 :: GReadResult (T4 T5)-
src/Text/GRead.hs view
@@ -1,4 +1,6 @@-{-# OPTIONS -fglasgow-exts #-}+{-# LANGUAGE RankNTypes,+ MagicHash,+ ScopedTypeVariables #-} {-| Alternative approach of 'read' that composes grammars instead @@ -42,7 +44,7 @@ import Text.GRead.Transformations.Group import UU.Parsing hiding (Symbol,parse,Ok) import qualified UU.Parsing as UU-import List (findIndex)+import Data.List (findIndex) -- | Type of error repair messages.
src/Text/GRead/Grammar.hs view
@@ -1,5 +1,5 @@-{-# OPTIONS -fglasgow-exts #-}-+{-# LANGUAGE ExistentialQuantification,+ RankNTypes #-} {- | Representation of Data Type Grammars.
src/Text/GRead/Transformations/GramTrafo.hs view
@@ -1,4 +1,4 @@-{-# OPTIONS -fglasgow-exts #-}+{-# LANGUAGE RankNTypes #-} module Text.GRead.Transformations.GramTrafo where
src/Text/GRead/Transformations/Group.hs view
@@ -1,4 +1,6 @@-{-# OPTIONS -fglasgow-exts -XArrows #-}+{-# LANGUAGE Arrows,+ RankNTypes,+ ScopedTypeVariables #-} module Text.GRead.Transformations.Group where @@ -63,8 +65,9 @@ group :: DGrammar a -> Grammar a-group gram - = let trafo = proc x -> +group (gram :: DGrammar a)+ = let trafo :: forall s t . Trafo Unit Productions s t (Ref a s)+ trafo = proc x -> do (ListDR rs) <- (gGrammar gram) -< x returnA -< plookup 0 rs in case runTrafo trafo Unit undefined of
src/Text/GRead/Transformations/LeftCorner.hs view
@@ -1,4 +1,4 @@-{-# OPTIONS -fglasgow-exts -XArrows #-}+{-# LANGUAGE Arrows, RankNTypes #-} module Text.GRead.Transformations.LeftCorner (leftcorner) where
src/Text/GRead/Transformations/LeftFact.hs view
@@ -1,4 +1,5 @@-{-# OPTIONS -fglasgow-exts -XArrows #-}+{-# LANGUAGE Arrows,+ ExistentialQuantification #-} module Text.GRead.Transformations.LeftFact (leftfactoring) where