packages feed

astview-utils (empty) → 0.1

raw patch · 5 files changed

+108/−0 lines, 5 filesdep +basedep +containersdep +sybsetup-changed

Dependencies added: base, containers, syb

Files

+ LICENSE view
@@ -0,0 +1,23 @@+astview: View abstract syntax trees for your custom languages and+parsers in a graphical (GTK+) application.++Copyright (C) 2009 Sebastian Menge and Pascal Hof++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+``Software''), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be+included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHOR(s) BE LIABLE FOR ANY CLAIM, DAMAGES OR+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR+OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ astview-utils.cabal view
@@ -0,0 +1,20 @@+Name:            astview-utils+Version:         0.1+License:         BSD4+License-File:    LICENSE+Author:          +                 Pascal Hof <pascal.hof@udo.edu>, +                 Sebastian Menge <sebastian.menge@udo.edu>+Maintainer:      Sebastian Menge <sebastian.menge@udo.edu>+Synopsis:        Interfacing between hint and astview+Description:     see README++Category:        Language++Cabal-Version:   >= 1.2+Build-Type:      Simple++Library+  Hs-Source-Dirs:  src+  Exposed-Modules: Language.Astview.Parser, Language.Astview.DataTree+  Build-Depends:   base>=4 && <5, containers, syb
+ src/Language/Astview/DataTree.hs view
@@ -0,0 +1,42 @@+module Language.Astview.DataTree where++-- syb+import Data.Generics (Data+                     ,extQ+                     ,gmapQ+                     ,showConstr+                     ,toConstr)++-- containers+import Data.Tree (Tree(Node,rootLabel))++-- | Trealise Data to Tree (from SYB 2, sec. 3.4 )+data2tree :: Data a => a -> Tree String+data2tree = gdefault `extQ` atString+  where +    atString x = Node x []+    gdefault x = Node (showConstr $ toConstr x) (gmapQ data2tree x) +    +flat :: Tree String -> Tree String+flat = id -- do nothing, see commentary below++++++{- -- try to flatten degenerated trees (lists of cons)+++flat (Node a xs) = Node a xs --(flat <$> (children False =<< xs))    ++-- use a boolean marker to notice whether we are inside a list (True) +-- or should start a new list, then recurse+children :: Bool -> Tree String -> [Tree String]+children False (Node "(:)" [left,right])        = [Node ("ListOf"++(rootLabel left)) (left:(children True right)) ]+children True  (Node "(:)" [left,Node "[]" []]) = [left]+children True  (Node "(:)" [left,right])        = left:(children True right)+children _ (Node a xs) + | null xs  =  [Node a []]+ |otherwise =  [Node a xs]+children x y = error ("No pattern match for children " ++ show x ++ " " ++ (drawTree y))+-}
+ src/Language/Astview/Parser.hs view
@@ -0,0 +1,21 @@+{-# LANGUAGE Rank2Types, DeriveDataTypeable #-}++module Language.Astview.Parser where++import Data.Generics (Data,Typeable)+import Data.Tree++data ParseError = ParseError+                deriving (Show,Data,Typeable)++-- | consists of a unique name, a list of extensions and the parse +-- function.+data Parser = Parser +  { name :: String -- ^unique name+  , exts  :: [String] -- ^file extensions assotiated with +  , tree :: String -> Tree String+  } deriving (Typeable)++instance Eq Parser where+  Parser n1 _ _ == Parser n2 _ _ = n1 ==n2+