mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-27 13:32:51 -06:00
"Committed_by_peb"
This commit is contained in:
22
grammars/ljung/thesis/CopyMorphism.gf
Normal file
22
grammars/ljung/thesis/CopyMorphism.gf
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
-- the example 4.1 from Ljunglöf (2004, page 82)
|
||||||
|
|
||||||
|
concrete CopyMorphism of CopyMorphismAbs = {
|
||||||
|
|
||||||
|
lincat
|
||||||
|
S = { s : Str };
|
||||||
|
A = { s1 : Str; s2 : Str };
|
||||||
|
|
||||||
|
lin
|
||||||
|
|
||||||
|
f x = { s = x.s1 ++ x.s2 };
|
||||||
|
|
||||||
|
g x y = { s1 = x.s1 ++ y.s1;
|
||||||
|
s2 = x.s2 ++ y.s2 };
|
||||||
|
|
||||||
|
ac = { s1 = "a"; s2 = "c" };
|
||||||
|
|
||||||
|
bd = { s1 = "b"; s2 = "d" };
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
15
grammars/ljung/thesis/CopyMorphismAbs.gf
Normal file
15
grammars/ljung/thesis/CopyMorphismAbs.gf
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
-- the example 4.1 from Ljunglöf (2004, page 82)
|
||||||
|
|
||||||
|
abstract CopyMorphismAbs = {
|
||||||
|
|
||||||
|
cat S; A;
|
||||||
|
|
||||||
|
fun
|
||||||
|
|
||||||
|
f : A -> S;
|
||||||
|
g : A -> A -> A;
|
||||||
|
ac : A;
|
||||||
|
bd : A;
|
||||||
|
|
||||||
|
}
|
||||||
26
grammars/ljung/thesis/Erasing.gf
Normal file
26
grammars/ljung/thesis/Erasing.gf
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
-- the example 4.1 from Ljunglöf (2004, page 82)
|
||||||
|
|
||||||
|
concrete Erasing of ErasingAbs = {
|
||||||
|
|
||||||
|
lincat
|
||||||
|
S = { s : Str };
|
||||||
|
A = { s1 : Str; s2 : Str };
|
||||||
|
B = { s : Str };
|
||||||
|
C = { s : Str };
|
||||||
|
|
||||||
|
lin
|
||||||
|
|
||||||
|
f x = { s = x.s1 };
|
||||||
|
|
||||||
|
g x y z = { s1 = x.s2 ++ y.s;
|
||||||
|
s2 = x.s1 ++ z.s };
|
||||||
|
|
||||||
|
a = { s1 = "a1"; s2 = "a2" };
|
||||||
|
|
||||||
|
b = { s = "b" };
|
||||||
|
|
||||||
|
c = { s = "c" };
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
21
grammars/ljung/thesis/ErasingAbs.gf
Normal file
21
grammars/ljung/thesis/ErasingAbs.gf
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
-- the example 4.1 from Ljunglöf (2004, page 82)
|
||||||
|
|
||||||
|
abstract ErasingAbs = {
|
||||||
|
|
||||||
|
cat S; A; B; C;
|
||||||
|
|
||||||
|
fun
|
||||||
|
|
||||||
|
f : A -> S;
|
||||||
|
|
||||||
|
g : A -> B -> C -> A;
|
||||||
|
|
||||||
|
a : A;
|
||||||
|
|
||||||
|
b : B;
|
||||||
|
|
||||||
|
c : C;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,9 +5,9 @@
|
|||||||
-- Stability : (stable)
|
-- Stability : (stable)
|
||||||
-- Portability : (portable)
|
-- Portability : (portable)
|
||||||
--
|
--
|
||||||
-- > CVS $Date: 2005/05/27 11:37:57 $
|
-- > CVS $Date: 2005/08/08 09:01:25 $
|
||||||
-- > CVS $Author: aarne $
|
-- > CVS $Author: peb $
|
||||||
-- > CVS $Revision: 1.16 $
|
-- > CVS $Revision: 1.17 $
|
||||||
--
|
--
|
||||||
-- (Description of the module)
|
-- (Description of the module)
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
@@ -147,7 +147,7 @@ prefixPathName p f = case f of
|
|||||||
c:_ | isSep c -> f -- do not prefix [Unix style] absolute paths
|
c:_ | isSep c -> f -- do not prefix [Unix style] absolute paths
|
||||||
_ -> case p of
|
_ -> case p of
|
||||||
"" -> f
|
"" -> f
|
||||||
_ -> p ++ "/" ++ f -- / actually works on windows
|
_ -> p ++ "/" ++ f -- note: / actually works on windows
|
||||||
|
|
||||||
justInitPath :: FilePath -> FilePath
|
justInitPath :: FilePath -> FilePath
|
||||||
justInitPath = reverse . drop 1 . dropWhile (not . isSep) . reverse
|
justInitPath = reverse . drop 1 . dropWhile (not . isSep) . reverse
|
||||||
@@ -303,7 +303,8 @@ readFileIOE f = ioe $ catch (readFile f >>= return . return)
|
|||||||
-- intended semantics: if file is not found, try @\$GF_LIB_PATH\/file@
|
-- intended semantics: if file is not found, try @\$GF_LIB_PATH\/file@
|
||||||
-- (even if file is an absolute path, but this should always fail)
|
-- (even if file is an absolute path, but this should always fail)
|
||||||
-- it returns not only contents of the file, but also the path used
|
-- it returns not only contents of the file, but also the path used
|
||||||
-- FIXME: unix-specific, / is \ on Windows
|
--
|
||||||
|
-- FIXME: unix-specific, \/ is \\ on Windows
|
||||||
readFileLibraryIOE :: String -> FilePath -> IOE (FilePath, String)
|
readFileLibraryIOE :: String -> FilePath -> IOE (FilePath, String)
|
||||||
readFileLibraryIOE ini f =
|
readFileLibraryIOE ini f =
|
||||||
ioe $ catch ((do {s <- readFile initPath; return (return (initPath,s))}))
|
ioe $ catch ((do {s <- readFile initPath; return (return (initPath,s))}))
|
||||||
|
|||||||
@@ -1,3 +1,15 @@
|
|||||||
|
----------------------------------------------------------------------
|
||||||
|
-- |
|
||||||
|
-- Maintainer : PL
|
||||||
|
-- Stability : (stable)
|
||||||
|
-- Portability : (portable)
|
||||||
|
--
|
||||||
|
-- > CVS $Date: 2005/08/08 09:01:25 $
|
||||||
|
-- > CVS $Author: peb $
|
||||||
|
-- > CVS $Revision: 1.5 $
|
||||||
|
--
|
||||||
|
-- MCFG parsing, the active algorithm
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
module GF.Parsing.MCFG.Active (parse, parseR) where
|
module GF.Parsing.MCFG.Active (parse, parseR) where
|
||||||
|
|
||||||
@@ -20,7 +32,7 @@ import GF.Infra.Print
|
|||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
-- * parsing
|
-- * parsing
|
||||||
|
|
||||||
--parse :: (Ord n, Ord c, Ord l, Ord t) => String -> MCFParser c n l t
|
parse :: (Ord n, Ord c, Ord l, Ord t) => String -> MCFParser c n l t
|
||||||
parse strategy pinfo starts toks =
|
parse strategy pinfo starts toks =
|
||||||
trace2 "MCFG.Active - strategy" (if isBU strategy then "BU"
|
trace2 "MCFG.Active - strategy" (if isBU strategy then "BU"
|
||||||
else if isTD strategy then "TD" else "None") $
|
else if isTD strategy then "TD" else "None") $
|
||||||
@@ -28,7 +40,7 @@ parse strategy pinfo starts toks =
|
|||||||
Final (Abs cat rhs fun) found rrecs <- chartLookup chart Fin ]
|
Final (Abs cat rhs fun) found rrecs <- chartLookup chart Fin ]
|
||||||
where chart = process strategy pinfo starts toks
|
where chart = process strategy pinfo starts toks
|
||||||
|
|
||||||
--parse :: (Ord n, Ord c, Ord l, Ord t) => String -> MCFParser c n l t
|
-- parseR :: (Ord n, Ord c, Ord l, Ord t) => String -> MCFParser c n l t
|
||||||
parseR strategy pinfo starts =
|
parseR strategy pinfo starts =
|
||||||
trace2 "MCFG.Active Range - strategy" (if isBU strategy then "BU"
|
trace2 "MCFG.Active Range - strategy" (if isBU strategy then "BU"
|
||||||
else if isTD strategy then "TD" else "None") $
|
else if isTD strategy then "TD" else "None") $
|
||||||
|
|||||||
@@ -1,3 +1,15 @@
|
|||||||
|
----------------------------------------------------------------------
|
||||||
|
-- |
|
||||||
|
-- Maintainer : PL
|
||||||
|
-- Stability : (stable)
|
||||||
|
-- Portability : (portable)
|
||||||
|
--
|
||||||
|
-- > CVS $Date: 2005/08/08 09:01:25 $
|
||||||
|
-- > CVS $Author: peb $
|
||||||
|
-- > CVS $Revision: 1.2 $
|
||||||
|
--
|
||||||
|
-- MCFG parsing, the active algorithm (alternative version)
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
module GF.Parsing.MCFG.Active2 (parse) where
|
module GF.Parsing.MCFG.Active2 (parse) where
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,15 @@
|
|||||||
|
----------------------------------------------------------------------
|
||||||
|
-- |
|
||||||
|
-- Maintainer : PL
|
||||||
|
-- Stability : (stable)
|
||||||
|
-- Portability : (portable)
|
||||||
|
--
|
||||||
|
-- > CVS $Date: 2005/08/08 09:01:25 $
|
||||||
|
-- > CVS $Author: peb $
|
||||||
|
-- > CVS $Revision: 1.4 $
|
||||||
|
--
|
||||||
|
-- MCFG parsing, the incremental algorithm
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
module GF.Parsing.MCFG.Incremental (parse, parseR) where
|
module GF.Parsing.MCFG.Incremental (parse, parseR) where
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,15 @@
|
|||||||
|
----------------------------------------------------------------------
|
||||||
|
-- |
|
||||||
|
-- Maintainer : PL
|
||||||
|
-- Stability : (stable)
|
||||||
|
-- Portability : (portable)
|
||||||
|
--
|
||||||
|
-- > CVS $Date: 2005/08/08 09:01:25 $
|
||||||
|
-- > CVS $Author: peb $
|
||||||
|
-- > CVS $Revision: 1.3 $
|
||||||
|
--
|
||||||
|
-- MCFG parsing, the incremental algorithm (alternative version)
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
module GF.Parsing.MCFG.Incremental2 (parse) where
|
module GF.Parsing.MCFG.Incremental2 (parse) where
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,15 @@
|
|||||||
|
----------------------------------------------------------------------
|
||||||
|
-- |
|
||||||
|
-- Maintainer : PL
|
||||||
|
-- Stability : (stable)
|
||||||
|
-- Portability : (portable)
|
||||||
|
--
|
||||||
|
-- > CVS $Date: 2005/08/08 09:01:25 $
|
||||||
|
-- > CVS $Author: peb $
|
||||||
|
-- > CVS $Revision: 1.5 $
|
||||||
|
--
|
||||||
|
-- MCFG parsing, the naive algorithm
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
module GF.Parsing.MCFG.Naive (parse, parseR) where
|
module GF.Parsing.MCFG.Naive (parse, parseR) where
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,15 @@
|
|||||||
|
---------------------------------------------------------------------
|
||||||
|
-- |
|
||||||
|
-- Maintainer : PL
|
||||||
|
-- Stability : (stable)
|
||||||
|
-- Portability : (portable)
|
||||||
|
--
|
||||||
|
-- > CVS $Date: 2005/08/08 09:01:25 $
|
||||||
|
-- > CVS $Author: peb $
|
||||||
|
-- > CVS $Revision: 1.5 $
|
||||||
|
--
|
||||||
|
-- Definitions of ranges, and operations on ranges
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
module GF.Parsing.MCFG.Range
|
module GF.Parsing.MCFG.Range
|
||||||
( Range(..), makeRange, concatRange, rangeEdge, edgeRange, minRange, maxRange,
|
( Range(..), makeRange, concatRange, rangeEdge, edgeRange, minRange, maxRange,
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
{-- Module --------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Filename: ApproxParse.hs
|
-- |
|
||||||
Author: Håkan Burden
|
-- Maintainer : PL
|
||||||
Time-stamp: <2005-04-18, 14:56>
|
-- Stability : (stable)
|
||||||
|
-- Portability : (portable)
|
||||||
Description: An agenda-driven implementation of the active algorithm 4.3.4,
|
--
|
||||||
parsing through context-free approximation as described in
|
-- > CVS $Date: 2005/08/08 09:01:25 $
|
||||||
Ljunglöf (2004)
|
-- > CVS $Author: peb $
|
||||||
------------------------------------------------------------------------------}
|
-- > CVS $Revision: 1.4 $
|
||||||
|
--
|
||||||
|
-- MCFG parsing, through context-free approximation
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
module GF.Parsing.MCFG.ViaCFG where
|
module GF.Parsing.MCFG.ViaCFG where
|
||||||
|
|
||||||
|
|||||||
@@ -41,10 +41,11 @@ sub check_headerline {
|
|||||||
if ($#ARGV >= 0) {
|
if ($#ARGV >= 0) {
|
||||||
@FILES = @ARGV;
|
@FILES = @ARGV;
|
||||||
} else {
|
} else {
|
||||||
@dirs = qw{. api canonical cf cfgm compile for-ghc-nofud
|
# @dirs = qw{. api canonical cf cfgm compile for-ghc-nofud
|
||||||
grammar infra notrace parsers shell
|
# grammar infra notrace parsers shell
|
||||||
source speech translate useGrammar util visualization
|
# source speech translate useGrammar util visualization
|
||||||
GF GF/* GF/*/* GF/*/*/*};
|
# GF GF/* GF/*/* GF/*/*/*};
|
||||||
|
@dirs = qw{GF GF/* GF/*/* GF/*/*/*};
|
||||||
@FILES = grep(!/\/(Par|Lex)(GF|GFC|CFG)\.hs$/,
|
@FILES = grep(!/\/(Par|Lex)(GF|GFC|CFG)\.hs$/,
|
||||||
glob "{".join(",",@dirs)."}/*.hs");
|
glob "{".join(",",@dirs)."}/*.hs");
|
||||||
}
|
}
|
||||||
@@ -70,7 +71,9 @@ for $file (@FILES) {
|
|||||||
# the module header
|
# the module header
|
||||||
$hdr_module = $module = "";
|
$hdr_module = $module = "";
|
||||||
|
|
||||||
s/^ (--+ \s* \n) +//sx;
|
s/^ \{-\# \s+ OPTIONS \s+ -cpp \s+ \#-\} //sx; # removing ghc options (cpp)
|
||||||
|
s/^ \s+ //sx; # removing initial whitespace
|
||||||
|
s/^ (--+ \s* \n) +//sx; # removing initial comment lines
|
||||||
unless (s/^ -- \s \| \s* \n//sx) {
|
unless (s/^ -- \s \| \s* \n//sx) {
|
||||||
push @ERR, "Incorrect module header";
|
push @ERR, "Incorrect module header";
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user