summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2005-12-01 17:58:31 +0000
committeraarne <aarne@cs.chalmers.se>2005-12-01 17:58:31 +0000
commitda22eac1803ea4e29dd88888157918878f75d149 (patch)
tree91d01a6110cc9159a93e729a56b68f2d7ad9dfac
parent56f62f31d88348e25636e13d9f8f57a04c1b0b74 (diff)
making apply_transfer work
-rw-r--r--doc/gf-history.html31
-rw-r--r--gf-logo.gifbin0 -> 1369 bytes
-rw-r--r--index.html15
-rw-r--r--src/GF/Compile/ShellState.hs14
-rw-r--r--src/GF/Infra/Modules.hs8
-rw-r--r--src/GF/Shell/HelpFile.hs11
-rw-r--r--src/GF/Shell/ShellCommands.hs2
-rw-r--r--src/HelpFile11
8 files changed, 83 insertions, 9 deletions
diff --git a/doc/gf-history.html b/doc/gf-history.html
index 52dc4319b..ed0669a1b 100644
--- a/doc/gf-history.html
+++ b/doc/gf-history.html
@@ -13,6 +13,37 @@ Changes in functionality since May 17, 2005, release of GF Version 2.2
</center>
<p>
+1/12 (BB,AR) The command <tt>at = apply_transfer</tt>, which applies
+a transfer function to a term. This is used for noncompositional
+translation. Transfer functions are defined in a special transfer
+language (file suffix <tt>.tr</tt>), which is compiled into a
+run-time transfer core language (file suffix <tt>.trc</tt>).
+The compiler is included in <tt>GF/transfer</tt>. The following is
+a complete example of how to try out transfer:
+<pre>
+ % cd GF/transfer
+ % make -- compile the trc compiler
+ % cd examples -- GF/transfer/examples
+ % ../compile_to_core -i../lib numerals.tr
+ % mv numerals.trc ../../examples/numerals
+ % cd ../../examples/numerals -- GF/examples/numerals
+ % gf
+ > i decimal.gf
+ > i BinaryDigits.gf
+ > i numerals.trc
+ > p -lang=Cncdecimal "123" | at num2bin | l
+ 1 0 0 1 1 0 0 1 1 1 0
+</pre>
+Other relevant commands are:
+<ul>
+<li> <tt>i file.trc</tt>: import a transfer module
+<li> <tt>pg -printer=transfer</tt>: create a syntax datatype in <tt>.tr</tt> format
+</ul>
+For more information on the commands, see <tt>help</tt>. Documentation on
+the transfer language: to appear.
+
+<p>
+
17/11 (AR) Made it possible for lexers to be nondeterministic.
Now with a simple-minded implementation that the parser is sent
each lexing result in turn. The option <tt>-cut</tt> is used for
diff --git a/gf-logo.gif b/gf-logo.gif
new file mode 100644
index 000000000..283534cfa
--- /dev/null
+++ b/gf-logo.gif
Binary files differ
diff --git a/index.html b/index.html
index bdcbb7c1b..94c6f8371 100644
--- a/index.html
+++ b/index.html
@@ -1,5 +1,5 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html><head><title>GF Version 2.3</title></head>
+<html><head><title>GF Version 2.3+</title></head>
<body bgcolor="#ffffff" text="#000000">
@@ -20,11 +20,24 @@ July 1, 2005.
</p><h2>News</h2>
+<i>December 1, 2005</i>.
+Publicly accessible
+<a href="http://www.cs.chalmers.se/Cs/Research/Language-technology/darcs/GF/doc/darcs.html">
+Darcs repository</a>
+for latest sources and documents. The snapshots are no longer updated.
+
+<p>
+
<i>September 22, 2005</i>.
<a href="http://www.cs.chalmers.se/~bringert/gf/downloads/snapshots/">
Snapshots</a>: latest source and linux binary packages, for testers
and developers. See
<a href="doc/gf-history.html">GF history</a> for the latest changes.
+<br>
+<b>Notice</b> (1/12):
+Use the
+<a href="http://www.cs.chalmers.se/Cs/Research/Language-technology/darcs/GF/doc/darcs.html">
+Darcs repository</a> instead!
<p>
diff --git a/src/GF/Compile/ShellState.hs b/src/GF/Compile/ShellState.hs
index 09209fa2d..bbae69efe 100644
--- a/src/GF/Compile/ShellState.hs
+++ b/src/GF/Compile/ShellState.hs
@@ -357,21 +357,18 @@ stateGrammarOfLang :: ShellState -> Language -> StateGrammar
stateGrammarOfLang st0 l = StGr {
absId = err (const (identC "Abs")) id $ M.abstractOfConcrete allCan l, ---
cncId = l,
- grammar = can,
+ grammar = allCan,
cf = maybe emptyCF id (lookup l (cfs st)),
mcfg = maybe [] id $ lookup l $ mcfgs st,
cfg = maybe [] id $ lookup l $ cfgs st,
pInfo = maybe (Prs.buildPInfo [] []) id $ lookup l $ pInfos st,
morpho = maybe emptyMorpho id (lookup l (morphos st)),
probs = maybe emptyProbs id (lookup l (probss st)),
- loptions = errVal noOptions $ lookupOptionsCan can
+ loptions = errVal noOptions $ lookupOptionsCan allCan
}
where
- st = purgeShellState $ st0 {concrete = Just l}
+ st = purgeShellState $ errVal st0 $ changeMain (Just l) st0
allCan = canModules st
- can = allCan
----- can = M.partOfGrammar allCan
----- (l, maybe M.emptyModInfo id (lookup l (M.modules allCan)))
grammarOfLang :: ShellState -> Language -> CanonGrammar
cfOfLang :: ShellState -> Language -> CF
@@ -413,6 +410,7 @@ stateAbstractGrammar st = StGr {
globalOptions :: ShellState -> Options
allLanguages :: ShellState -> [Language]
+allTransfers :: ShellState -> [Ident]
allCategories :: ShellState -> [G.Cat]
allStateGrammars :: ShellState -> [StateGrammar]
allStateGrammarsWithNames :: ShellState -> [(Language, StateGrammar)]
@@ -421,7 +419,9 @@ allActiveStateGrammarsWithNames :: ShellState -> [(Language, StateGrammar)]
allActiveGrammars :: ShellState -> [StateGrammar]
globalOptions = gloptions
-allLanguages = map (fst . fst) . concretes
+--allLanguages = map (fst . fst) . concretes
+allLanguages = M.allConcreteModules . canModules
+allTransfers = map fst . transfers
allCategories = map fst . allCatsOf . canModules
allStateGrammars = map snd . allStateGrammarsWithNames
diff --git a/src/GF/Infra/Modules.hs b/src/GF/Infra/Modules.hs
index f8c56d3e6..723cf7f3d 100644
--- a/src/GF/Infra/Modules.hs
+++ b/src/GF/Infra/Modules.hs
@@ -35,7 +35,8 @@ module GF.Infra.Modules (
lookupModule, lookupModuleType, lookupModMod, lookupInfo,
allModMod, isModAbs, isModRes, isModCnc, isModTrans,
sameMType, isCompilableModule, isCompleteModule,
- allAbstracts, greatestAbstract, allResources, greatestResource, allConcretes
+ allAbstracts, greatestAbstract, allResources,
+ greatestResource, allConcretes, allConcreteModules
) where
import GF.Infra.Ident
@@ -391,3 +392,8 @@ greatestResource gr = case allResources gr of
allConcretes :: Eq i => MGrammar i f a -> i -> [i]
allConcretes gr a =
[i | (i, ModMod m) <- modules gr, mtype m == MTConcrete a, isCompleteModule m]
+
+-- | all concrete modules for any abstract
+allConcreteModules :: Eq i => MGrammar i f a -> [i]
+allConcreteModules gr =
+ [i | (i, ModMod m) <- modules gr, MTConcrete _ <- [mtype m], isCompleteModule m]
diff --git a/src/GF/Shell/HelpFile.hs b/src/GF/Shell/HelpFile.hs
index 3162bd88a..82d3a9713 100644
--- a/src/GF/Shell/HelpFile.hs
+++ b/src/GF/Shell/HelpFile.hs
@@ -51,6 +51,7 @@ txtHelpFile =
"\n .gfe example-based grammar files (only with the -ex option)" ++
"\n .ebnf Extended BNF format" ++
"\n .cf Context-free (BNF) format" ++
+ "\n .trc TransferCore format" ++
"\n options:" ++
"\n -old old: parse in GF<2.0 format (not necessary)" ++
"\n -v verbose: give lots of messages " ++
@@ -219,6 +220,15 @@ txtHelpFile =
"\n p -cat=S -mcfg \"jag är gammal\" -- parse an S with the MCFG" ++
"\n rf examples.txt | p -lines -- parse each non-empty line of the file" ++
"\n" ++
+ "\nat, apply_transfer: at (Module.Fun | Fun)" ++
+ "\n Transfer a term using Fun from Module, or the topmost transfer" ++
+ "\n module. Transfer modules are given in the .trc format. They are" ++
+ "\n shown by the 'po' command." ++
+ "\n flags:" ++
+ "\n -lang typecheck the result in this lang instead of default lang" ++
+ "\n examples:" ++
+ "\n p -lang=Cncdecimal \"123\" | at num2bin | l -- convert dec to bin" ++
+ "\n" ++
"\ntt, test_tokenizer: tt String" ++
"\n Show the token list sent to the parser when String is parsed." ++
"\n HINT: can be useful when debugging the parser." ++
@@ -588,6 +598,7 @@ txtHelpFile =
"\n -printer=unpar a gfc grammar with parameters eliminated" ++
"\n -printer=functiongraph abstract syntax functions in 'dot' format" ++
"\n -printer=typegraph abstract syntax categories in 'dot' format" ++
+ "\n -printer=transfer Transfer language datatype (.tr file format)" ++
"\n -printer=gfcm M gfcm file (default for pm)" ++
"\n -printer=header M gfcm file with header (for GF embedded in Java)" ++
"\n -printer=graph M module dependency graph in 'dot' (graphviz) format" ++
diff --git a/src/GF/Shell/ShellCommands.hs b/src/GF/Shell/ShellCommands.hs
index b9ab2c01b..bf7d4f1ff 100644
--- a/src/GF/Shell/ShellCommands.hs
+++ b/src/GF/Shell/ShellCommands.hs
@@ -124,6 +124,7 @@ testValidFlag :: ShellState -> Command -> OptFunId -> String -> Err ()
testValidFlag st co f x = case f of
"cat" -> testIn (map prQIdent_ (allCategories st))
"lang" -> testIn (map prt (allLanguages st))
+ "transfer" -> testIn (map prt (allTransfers st))
"res" -> testIn (map prt (allResources (srcModules st)))
"number" -> testN
"printer" -> case co of
@@ -181,6 +182,7 @@ optionsOfCommand co = case co of
CGenerateTrees -> both "metas" "atoms depth alts cat lang number"
CPutTerm -> flags "transform number"
CWrapTerm _ -> opts "c"
+ CApplyTransfer _ -> flags "lang transfer"
CMorphoAnalyse -> both "short" "lang"
CTestTokenizer -> flags "lexer"
CComputeConcrete _ -> flags "res"
diff --git a/src/HelpFile b/src/HelpFile
index c446d9c2c..d87be7d05 100644
--- a/src/HelpFile
+++ b/src/HelpFile
@@ -22,6 +22,7 @@ i, import: i File
.gfe example-based grammar files (only with the -ex option)
.ebnf Extended BNF format
.cf Context-free (BNF) format
+ .trc TransferCore format
options:
-old old: parse in GF<2.0 format (not necessary)
-v verbose: give lots of messages
@@ -190,6 +191,15 @@ p, parse: p String
p -cat=S -mcfg "jag är gammal" -- parse an S with the MCFG
rf examples.txt | p -lines -- parse each non-empty line of the file
+at, apply_transfer: at (Module.Fun | Fun)
+ Transfer a term using Fun from Module, or the topmost transfer
+ module. Transfer modules are given in the .trc format. They are
+ shown by the 'po' command.
+ flags:
+ -lang typecheck the result in this lang instead of default lang
+ examples:
+ p -lang=Cncdecimal "123" | at num2bin | l -- convert dec to bin
+
tt, test_tokenizer: tt String
Show the token list sent to the parser when String is parsed.
HINT: can be useful when debugging the parser.
@@ -559,6 +569,7 @@ q, quit: q
-printer=unpar a gfc grammar with parameters eliminated
-printer=functiongraph abstract syntax functions in 'dot' format
-printer=typegraph abstract syntax categories in 'dot' format
+ -printer=transfer Transfer language datatype (.tr file format)
-printer=gfcm M gfcm file (default for pm)
-printer=header M gfcm file with header (for GF embedded in Java)
-printer=graph M module dependency graph in 'dot' (graphviz) format