mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-14 21:52:51 -06:00
GF/src is now for 2.9, and the new sources are in src-3.0 - keep it this way until the release of GF 3
This commit is contained in:
43
src-3.0/GF/OldParsing/GCFG.hs
Normal file
43
src-3.0/GF/OldParsing/GCFG.hs
Normal file
@@ -0,0 +1,43 @@
|
||||
----------------------------------------------------------------------
|
||||
-- |
|
||||
-- Maintainer : PL
|
||||
-- Stability : (stable)
|
||||
-- Portability : (portable)
|
||||
--
|
||||
-- > CVS $Date: 2005/04/11 13:52:53 $
|
||||
-- > CVS $Author: peb $
|
||||
-- > CVS $Revision: 1.1 $
|
||||
--
|
||||
-- Simplistic GFC format
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
module GF.OldParsing.GCFG where
|
||||
|
||||
import GF.Printing.PrintParser
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
type Grammar c n l t = [Rule c n l t]
|
||||
data Rule c n l t = Rule (Abstract c n) (Concrete l t)
|
||||
deriving (Eq, Ord, Show)
|
||||
|
||||
data Abstract cat name = Abs cat [cat] name
|
||||
deriving (Eq, Ord, Show)
|
||||
data Concrete lin term = Cnc lin [lin] term
|
||||
deriving (Eq, Ord, Show)
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
instance (Print c, Print n, Print l, Print t) => Print (Rule n c l t) where
|
||||
prt (Rule abs cnc) = prt abs ++ " := " ++ prt cnc ++ "\n"
|
||||
prtList = concatMap prt
|
||||
|
||||
instance (Print c, Print n) => Print (Abstract c n) where
|
||||
prt (Abs cat args name) = prt name ++ ". " ++ prt cat ++
|
||||
( if null args then ""
|
||||
else " -> " ++ prtSep " " args )
|
||||
|
||||
instance (Print l, Print t) => Print (Concrete l t) where
|
||||
prt (Cnc lcat args term) = prt term ++ " : " ++ prt lcat ++
|
||||
( if null args then ""
|
||||
else " [ " ++ prtSep " " args ++ " ]" )
|
||||
Reference in New Issue
Block a user