forked from GitHub/gf-core
*** empty log message ***
This commit is contained in:
@@ -1,8 +1,16 @@
|
|||||||
|
|
||||||
abstract MicroAbs = {
|
abstract MicroAbs = {
|
||||||
|
|
||||||
cat S;
|
cat S; V; VV; W;
|
||||||
|
|
||||||
fun vars : S;
|
fun
|
||||||
|
sv : V -> S;
|
||||||
|
vars : VV;
|
||||||
|
ww : W -> W;
|
||||||
|
svw : V -> W -> S;
|
||||||
|
|
||||||
|
supr : V -> V -> S;
|
||||||
|
supredup : S -> S -> S;
|
||||||
|
suplbl : V -> S;
|
||||||
|
reorder : V -> V -> V;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,26 @@
|
|||||||
|
|
||||||
concrete MicroCnc of MicroAbs = {
|
concrete MicroCnc of MicroAbs = open MicroRes in {
|
||||||
|
|
||||||
lincat S = {a : {s1:Str ; s2:Str}};
|
lincat
|
||||||
|
S = {s : Str};
|
||||||
|
VV = {a : {s1:Str ; s2:Str}};
|
||||||
|
V = {s1 : Str ; s2 : Str ; p : PQ};
|
||||||
|
W = {s : Num => Str ; p : PQ => Num};
|
||||||
|
|
||||||
lin vars = {a = variants { {s1="a" ; s2=variants{"b";"c"}} ; {s1="d";s2="e"} }};
|
lin
|
||||||
|
sv x = {s = x.s1 ++ x.s2};
|
||||||
|
vars = {a = variants { {s1="a" ; s2=variants{"b";"c"}} ; {s1="d";s2="e"} }};
|
||||||
|
ww x = {s = table {Sg => x.s!(x.p!P);
|
||||||
|
Pl => x.s!(x.p!Q Pl)};
|
||||||
|
p = table {P => Sg ; Q n => n}};
|
||||||
|
svw x y = {s = x.s2 ++ y.s!(y.p!x.p) ++ x.s1};
|
||||||
|
|
||||||
|
supr x y = {s = x.s1 ++ "a" ++ x.s2};
|
||||||
|
supredup x y = {s = x.s ++ "b" ++ x.s};
|
||||||
|
suplbl x = {s = x.s1};
|
||||||
|
reorder x y = {s1 = x.s2 ++ y.s1 ++ x.s1;
|
||||||
|
s2 = y.s2 ++ y.s1;
|
||||||
|
p = x.p};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,16 @@
|
|||||||
abstract SimpleAbs = {
|
abstract SimpleAbs = {
|
||||||
|
|
||||||
cat
|
cat
|
||||||
S; VP; NP; V; N; D;
|
S; VP; NP; V; N; D; P; PP;
|
||||||
|
|
||||||
fun
|
fun
|
||||||
cyclic : S -> S;
|
cyclic : S -> S;
|
||||||
mkS : NP -> V -> S;
|
mkS : NP -> VP -> S;
|
||||||
mkVP : V -> NP -> VP;
|
mkVP : V -> NP -> VP;
|
||||||
mkNP1 : D -> N -> NP;
|
mkNP1 : D -> N -> NP;
|
||||||
mkNP2 : N -> NP;
|
mkNP2 : N -> NP;
|
||||||
|
mkNP3 : NP -> PP -> NP;
|
||||||
|
mkPP : P -> NP -> PP;
|
||||||
|
|
||||||
robin : NP;
|
robin : NP;
|
||||||
dog : N;
|
dog : N;
|
||||||
@@ -18,6 +20,7 @@ love : V;
|
|||||||
hate : V;
|
hate : V;
|
||||||
one : D;
|
one : D;
|
||||||
all : D;
|
all : D;
|
||||||
|
inside : P;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ NP = {s : Str ; n : Num};
|
|||||||
V = {s : Num => Str};
|
V = {s : Num => Str};
|
||||||
N = {s : Num => Str};
|
N = {s : Num => Str};
|
||||||
D = {s : Str ; n : Num};
|
D = {s : Str ; n : Num};
|
||||||
|
P = {s : Str};
|
||||||
|
PP = {s : Str};
|
||||||
|
|
||||||
lin
|
lin
|
||||||
cyclic x = x;
|
cyclic x = x;
|
||||||
@@ -15,6 +17,8 @@ mkS x y = {s = x.s ++ y.s ! x.n};
|
|||||||
mkVP x y = {s = table {n => x.s ! n ++ y.s}};
|
mkVP x y = {s = table {n => x.s ! n ++ y.s}};
|
||||||
mkNP1 x y = {s = x.s ++ y.s ! x.n ; n = x.n};
|
mkNP1 x y = {s = x.s ++ y.s ! x.n ; n = x.n};
|
||||||
mkNP2 x = {s = x.s ! Pl ; n = Pl};
|
mkNP2 x = {s = x.s ! Pl ; n = Pl};
|
||||||
|
mkNP3 x y = {s = x.s ++ y.s; n = x.n};
|
||||||
|
mkPP x y = {s = x.s ++ y.s};
|
||||||
|
|
||||||
robin = {s = "Robin" ; n = Sg};
|
robin = {s = "Robin" ; n = Sg};
|
||||||
dog = {s = table {Sg => "dog" ; Pl => "dogs"}};
|
dog = {s = table {Sg => "dog" ; Pl => "dogs"}};
|
||||||
@@ -23,6 +27,7 @@ love = {s = table {Sg => "loves" ; Pl => "love"}};
|
|||||||
hate = {s = table {Sg => "hates" ; Pl => "hate"}};
|
hate = {s = table {Sg => "hates" ; Pl => "hate"}};
|
||||||
one = {s = "one" ; n = Sg};
|
one = {s = "one" ; n = Sg};
|
||||||
all = {s = "all" ; n = Pl};
|
all = {s = "all" ; n = Pl};
|
||||||
|
inside= {s = "in"};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -407,8 +407,8 @@ begindocument =
|
|||||||
"\\setlength{\\parskip}{2mm}" ++++
|
"\\setlength{\\parskip}{2mm}" ++++
|
||||||
"\\setlength{\\parindent}{0mm}" ++++
|
"\\setlength{\\parindent}{0mm}" ++++
|
||||||
"\\setlength{\\oddsidemargin}{0mm}" ++++
|
"\\setlength{\\oddsidemargin}{0mm}" ++++
|
||||||
"\\setlength{\\evensidemargin}{-2mm}" ++++
|
("\\setlength{\\evensidemargin}{"++"-2mm}") ++++ -- peb 27/5-04: to prevent hugs-mode
|
||||||
"\\setlength{\\topmargin}{-8mm}" ++++
|
("\\setlength{\\topmargin}{"++"-8mm}") ++++ -- from treating the rest as comments
|
||||||
"\\setlength{\\textheight}{240mm}" ++++
|
"\\setlength{\\textheight}{240mm}" ++++
|
||||||
"\\setlength{\\textwidth}{158mm}" ++++
|
"\\setlength{\\textwidth}{158mm}" ++++
|
||||||
"\\begin{document}\n"
|
"\\begin{document}\n"
|
||||||
@@ -416,6 +416,7 @@ begindocument =
|
|||||||
enddocument =
|
enddocument =
|
||||||
"\n\\end{document}\n"
|
"\n\\end{document}\n"
|
||||||
|
|
||||||
|
|
||||||
sortByLongest :: [[a]] -> [[a]]
|
sortByLongest :: [[a]] -> [[a]]
|
||||||
sortByLongest = sortBy longer where
|
sortByLongest = sortBy longer where
|
||||||
longer x y
|
longer x y
|
||||||
@@ -426,11 +427,14 @@ sortByLongest = sortBy longer where
|
|||||||
x' = length x
|
x' = length x
|
||||||
y' = length y
|
y' = length y
|
||||||
|
|
||||||
|
-- "combinations" is the same as "sequence"!!!
|
||||||
|
-- peb 30/5-04
|
||||||
combinations :: [[a]] -> [[a]]
|
combinations :: [[a]] -> [[a]]
|
||||||
combinations t = case t of
|
combinations t = case t of
|
||||||
[] -> [[]]
|
[] -> [[]]
|
||||||
aa:uu -> [a:u | a <- aa, u <- combinations uu]
|
aa:uu -> [a:u | a <- aa, u <- combinations uu]
|
||||||
|
|
||||||
|
|
||||||
mkTextFile :: String -> IO ()
|
mkTextFile :: String -> IO ()
|
||||||
mkTextFile name = do
|
mkTextFile name = do
|
||||||
s <- readFile name
|
s <- readFile name
|
||||||
|
|||||||
@@ -37,12 +37,15 @@ import GrammarToHaskell
|
|||||||
|
|
||||||
-- the cf parsing algorithms
|
-- the cf parsing algorithms
|
||||||
import ChartParser -- or some other CF Parser
|
import ChartParser -- or some other CF Parser
|
||||||
import NewChartParser
|
import qualified ParseCFviaCFG as PCF
|
||||||
import NewerChartParser
|
--import qualified ParseGFCviaCFG as PGFC
|
||||||
|
--import NewChartParser
|
||||||
|
--import NewerChartParser
|
||||||
|
|
||||||
-- grammar conversions -- peb 19/4-04
|
-- grammar conversions -- peb 19/4-04
|
||||||
-- see also customGrammarPrinter
|
-- see also customGrammarPrinter
|
||||||
import qualified ConvertGrammar as Cnv
|
import qualified ConvertGrammar as Cnv
|
||||||
|
import qualified PrintParser as Prt
|
||||||
|
|
||||||
import MyParser
|
import MyParser
|
||||||
|
|
||||||
@@ -174,9 +177,11 @@ customGrammarPrinter =
|
|||||||
-- add your own grammar printers here
|
-- add your own grammar printers here
|
||||||
-- grammar conversions, (peb)
|
-- grammar conversions, (peb)
|
||||||
,(strCI "gfc_show", show . grammar2canon . stateGrammarST)
|
,(strCI "gfc_show", show . grammar2canon . stateGrammarST)
|
||||||
,(strCI "tnf", prCanon . Cnv.convertCanonToTNF . stateGrammarST)
|
-- ,(strCI "tnf", prCanon . Cnv.convertCanonToTNF . stateGrammarST)
|
||||||
,(strCI "mcfg", Cnv.prMCFG . Cnv.convertCanonToMCFG . stateGrammarST)
|
,(strCI "emcfg", Prt.prt . Cnv.convertCanonToEMCFG . stateGrammarST)
|
||||||
,(strCI "mcfg_cf", Cnv.prCFG . Cnv.convertCanonToCFG . stateGrammarST)
|
,(strCI "emcfg_cf", Prt.prt . Cnv.convertCanonViaEMCFGtoCFG . stateGrammarST)
|
||||||
|
,(strCI "mcfg", Prt.prt . Cnv.convertCanonToMCFG . stateGrammarST)
|
||||||
|
,(strCI "mcfg_cf", Prt.prt . Cnv.convertCanonToCFG . stateGrammarST)
|
||||||
,(strCI "mcfg_show", show . Cnv.convertCanonToMCFG . stateGrammarST)
|
,(strCI "mcfg_show", show . Cnv.convertCanonToMCFG . stateGrammarST)
|
||||||
--- also include printing via grammar2syntax!
|
--- also include printing via grammar2syntax!
|
||||||
]
|
]
|
||||||
@@ -262,11 +267,14 @@ customParser =
|
|||||||
,(strCI "myparser", myParser)
|
,(strCI "myparser", myParser)
|
||||||
-- add your own parsers here
|
-- add your own parsers here
|
||||||
]
|
]
|
||||||
|
-- 31/5-04, peb:
|
||||||
|
++ [ (strCI ("new"++name), PCF.parse descr . stateCF) |
|
||||||
|
(descr, names) <- PCF.alternatives, name <- names ]
|
||||||
-- 21/5-04, peb:
|
-- 21/5-04, peb:
|
||||||
++ [ (strCI ("new"++name), newChartParser descr . stateCF) |
|
-- ++ [ (strCI ("new"++name), newChartParser descr . stateCF) |
|
||||||
(descr, names) <- newChartParserAlternatives, name <- names ]
|
-- (descr, names) <- newChartParserAlternatives, name <- names ]
|
||||||
++ [ (strCI ("newer"++name), newerChartParser descr . stateParserInfo) |
|
-- ++ [ (strCI ("newer"++name), newerChartParser descr . stateParserInfo) |
|
||||||
(descr, names) <- newerChartParserAlternatives, name <- names ]
|
-- (descr, names) <- newerChartParserAlternatives, name <- names ]
|
||||||
++ moreCustomParser
|
++ moreCustomParser
|
||||||
|
|
||||||
customTokenizer =
|
customTokenizer =
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import Option
|
|||||||
import Custom
|
import Custom
|
||||||
import ShellState
|
import ShellState
|
||||||
|
|
||||||
import qualified ExportParser as N
|
import qualified ParseGFCviaCFG as N
|
||||||
|
|
||||||
import Operations
|
import Operations
|
||||||
|
|
||||||
@@ -43,9 +43,9 @@ parseStringC opts0 sg cat s
|
|||||||
---- to test peb's new parser 6/10/2003
|
---- to test peb's new parser 6/10/2003
|
||||||
| oElem newParser opts0 = do
|
| oElem newParser opts0 = do
|
||||||
let pm = maybe "" id $ getOptVal opts0 useParser -- -parser=pm
|
let pm = maybe "" id $ getOptVal opts0 useParser -- -parser=pm
|
||||||
gr = grammar sg
|
gr = stateGrammarST sg
|
||||||
ct = cfCat2Cat cat
|
ct = cfCat2Cat cat
|
||||||
ts <- checkErr $ N.newParser pm gr (cfCat2Cat cat) s
|
ts <- checkErr $ N.newParser pm sg ct s -- peb 27/5-04 (changed gr -> sg)
|
||||||
mapM (checkErr . (annotate gr)) ts
|
mapM (checkErr . (annotate gr)) ts
|
||||||
|
|
||||||
| otherwise = do
|
| otherwise = do
|
||||||
@@ -58,11 +58,13 @@ parseStringC opts0 sg cat s
|
|||||||
tokens2trms opts sg cn parser (tok s)
|
tokens2trms opts sg cn parser (tok s)
|
||||||
|
|
||||||
tokens2trms :: Options ->StateGrammar ->Ident -> CFParser -> [CFTok] -> Check [Tree]
|
tokens2trms :: Options ->StateGrammar ->Ident -> CFParser -> [CFTok] -> Check [Tree]
|
||||||
tokens2trms opts sg cn parser as = do
|
tokens2trms opts sg cn parser toks = trees2trms opts sg cn toks trees info
|
||||||
let res@(trees,info) = parser as
|
where result = parser toks
|
||||||
ts0 <- return $ cfParseResults res -- removed nub, peb 25/5-04
|
info = snd result
|
||||||
-- ts0 <- return $ nub (cfParseResults res) -- nub gives quadratic behaviour!
|
trees = {- nub $ -} cfParseResults result -- peb 25/5-04: removed nub (O(n^2))
|
||||||
-- SortedList.nubsort is O(n log n)
|
|
||||||
|
trees2trms :: Options -> StateGrammar -> Ident -> [CFTok] -> [CFTree] -> String -> Check [Tree]
|
||||||
|
trees2trms opts sg cn as ts0 info = do
|
||||||
ts <- case () of
|
ts <- case () of
|
||||||
_ | null ts0 -> checkWarn "No success in cf parsing" >> return []
|
_ | null ts0 -> checkWarn "No success in cf parsing" >> return []
|
||||||
_ | raw -> do
|
_ | raw -> do
|
||||||
|
|||||||
Reference in New Issue
Block a user