small things

This commit is contained in:
aarne
2004-06-18 13:14:50 +00:00
parent 1ecf09836a
commit e0d4eff9cb
4 changed files with 116 additions and 46 deletions

View File

@@ -6,11 +6,11 @@
<h1>Grammatical Framework Version 2</h1> <h1>Grammatical Framework Version 2</h1>
Highlights, preliminary version Highlights, version 2.0
<p> <p>
13/10/2003 - 25/11 - 2/4/2004 13/10/2003 - 25/11 - 2/4/2004 - 18/6
<p> <p>
@@ -21,7 +21,7 @@ Highlights, preliminary version
<h2>Syntax of GF</h2> <h2>Syntax of GF</h2>
An accurate <a href="DocGF.ps.gz">language specification</a> is now available. An accurate <a href="DocGF.pdf">language specification</a> is now available.
<h2>Summary of novelties</h2> <h2>Summary of novelties</h2>
@@ -32,19 +32,22 @@ An accurate <a href="DocGF.ps.gz">language specification</a> is now available.
<tt>concrete</tt>, and <tt>resource</tt>. <tt>concrete</tt>, and <tt>resource</tt>.
<li> Replaces the file-based <tt>include</tt> system <li> Replaces the file-based <tt>include</tt> system
<li> Name space handling with qualified names <li> Name space handling with qualified names
<li> Hierarchic structure (<tt>extend</tt>) + cross-cutting reuse (<tt>open</tt>) <li> Hierarchic structure (single inheritance <tt>**</tt>) +
cross-cutting reuse (<tt>open</tt>)
<li> Separate compilation, one module per file <li> Separate compilation, one module per file
<li> Reuse of <tt>abstract</tt>+<tt>concrete</tt> as <tt>resource</tt> <li> Reuse of <tt>abstract</tt>+<tt>concrete</tt> as <tt>resource</tt>
<li> New module types: <li> Parametrized modules:
<tt>interface</tt>, <tt>instance</tt>, <tt>incomplete</tt>. <tt>interface</tt>, <tt>instance</tt>, <tt>incomplete</tt>.
<li> New experimental module types: <tt>transfer</tt>, <li> New experimental module types: <tt>transfer</tt>,
<tt>union</tt>. <tt>union</tt>.
<h4>Canonical format GFC</h4> <h4>Canonical format GFC</h4>
<li> The target of GF compiler; to reuse, just read in <li> The target of GF compiler; to reuse, just read in
<li> Readable by Haskell/Java/C++/C applications <li> Readable by Haskell/Java/C++/C applications
<h4>New features in expression language</h4> <h4>New features in expression language</h4>
<li> Disjunctive patterns <tt>P | ... | Q</tt>. <li> Disjunctive patterns <tt>P | ... | Q</tt>.
@@ -56,76 +59,94 @@ An accurate <a href="DocGF.ps.gz">language specification</a> is now available.
<li> Pattern variables can be used on lhs's of <tt>oper</tt> definitions. <li> Pattern variables can be used on lhs's of <tt>oper</tt> definitions.
<li> New Unicode transliterations (by Harad Hammarström). <li> New Unicode transliterations (by Harad Hammarström).
<h4>New shell commands</h4>
<h4>New shell commands and command functionalities</h4>
<li> <tt>pi</tt> = <tt>print_info</tt>: information on an identifier in scope. <li> <tt>pi</tt> = <tt>print_info</tt>: information on an identifier in scope.
<li> <tt>h</tt> = <tt>help</tt> now in long or short form, <li> <tt>h</tt> = <tt>help</tt> now in long or short form,
and on individual commands. and on individual commands.
<li> All commands have both long and short names (see help). Long names <li> <tt>gt</tt> = <tt>generate_trees</tt>: all trees of a given
are a handy way to make scripts more readable. category or instantiations of a given incomplete term, up to a
given depth.
<li> <tt>gr</tt> = <tt>generate_random</tt> can now be given
an incomplete term as an argument, to constrain generation.
<li> <tt>so</tt> = <tt>show_opers</tt> shows all <tt>ope</tt>
operations with a given value type.
<li> <tt>pm</tt> = <tt>print_multi</tt> prints the multilingual
grammar resident in the current state to a ready-compiles
<tt>.gfcm</tt> file.
<li> All commands have both long and short names (see help). Short
names are easier to type, whereas long names
make scripts more readable.
<li> Meaningless command options generate warnings.
<h4>New editor features</h4> <h4>New editor features</h4>
<li> Active text field (forthcoming, by Janna Khegai) <li> Active text field: click the middle button in the focus to send
<li> Clipboard in refinement through the parser.
<li> Clipboard: copy complex terms into the refine menu.
<h4>Improved implementation</h4> <h4>Improved implementation</h4>
<li> Haskell source code organized into subdirectories. <li> Haskell source code is organized into subdirectories.
<li> BNF Converter used for defining the languages GF and GFC, which also <li> BNF Converter is used for defining the languages GF and GFC, which also
give reliable LaTeX documentation. give reliable LaTeX documentation.
<li> Lexican rules sorted out by option <tt>-cflexer</tt> for efficient <li> Lexical rules sorted out by option <tt>-cflexer</tt> for efficient
parsing with large lexica. parsing with large lexica.
<li> GHC optimizations and strictness flags are used for improving performance.
<h4>New parser (forthcoming)</h4>
<li> By Peter Ljunglöf, based on MCFG <h4>New parser (work in progress)</h4>
<li> Much more efficient for morphology and discontinuous constituents
<li> Treatment of cyclic rules <li> By Peter Ljunglöf, based on MCFG.
<li> Much more efficient for morphology and discontinuous constituents.
<li> Treatment of cyclic rules.
<!-- NEW --> <!-- NEW -->
<h2>Status (24/3/2004)</h2> <h2>Status (18/6/2004)</h2>
Grammar compiler, editor GUIs, and shell work. Grammar compiler, editor GUIs, and shell work for all platforms
(with restrictions for Solaris).
<p> <p>
The updated <tt>HelpFile</tt> (accessible through <tt>h</tt> command) The updated <tt>HelpFile</tt> (accessible through <tt>h</tt> command)
marks unsupported but expected features with <tt>*</tt>. marks unsupported features present in GF 1.2 with <tt>*</tt>.
They will be supported again if interested users appear.
<p> <p>
GF1 grammars can be automatically translated to GF2 (although result not as good GF1 grammars can be automatically translated to GF2 (although the
result is not as good
as manual, since indentation and comments are destroyed). The results can be as manual, since indentation and comments are destroyed). The results can be
saved in GF2 files, but this is not necessary. saved in GF2 files, but this is not necessary.
Some rarely used GF1 features are no longer supported (see next section).
<p> <p>
It is also possible to write a GF2 grammar back to GF1. It is also possible to write a GF2 grammar back to GF1, with the
command <tt>pg -printer=old</tt>.
<p> <p>
Example grammars and resource libraries are have been Resource libraries
converted. There is a new resource API with and some example grammars and have been
many new constructions. The new versions lie in <tt>grammars/newresource</tt>. converted. Most old example grammars work without any changes.
There is a new resource API with
many new constructions.
<p> <p>
A make facility works, finding out which modules have to be recompiled. A make facility works, finding out which modules have to be recompiled.
There is some room for improvement.
<p> <p>
<tt>transfer</tt> modules have to be called by flags.
<p>
Soundness checking of module depencencies and completeness is not Soundness checking of module depencencies and completeness is not
complete. This means that some errors may show up too late. complete. This means that some errors may show up too late.
@@ -134,15 +155,23 @@ complete. This means that some errors may show up too late.
Latex and XML printing of grammars do not work yet. Latex and XML printing of grammars do not work yet.
<!-- NEW --> <!-- NEW -->
<h2>How to use GF 1.* files</h2> <h2>How to use GF 1.* files</h2>
Backward compatibility with respect to old GF grammars has been Backward compatibility with respect to old GF grammars has been
a central goal. All GF grammars, from version 0.9, should work in a central goal. All GF grammars, from version 0.9, should work in
the old way in GF2. The main exception is the <tt>package</tt> system the old way in GF2. The main exceptions are some features that
introduced in GF 1.2, which would interfere too much with the new are rarely used.
module system. <ul>
<li> The <tt>package</tt> system introduced in GF 1.2, cannot be
interpreted in the module system of GF 2.0, since packages are in
mutual scope with the top level.
<li> <tt>tokenizer</tt> pragmas are cannot be parsed any more. In GF
1.2, they are already replaced by <tt>lexer</tt> flags.
<li> <tt>var</tt> pragmas cannot be parsed any more.
</ul>
<p> <p>
@@ -212,10 +241,6 @@ with a variant where the last letter is replaced by <tt>Z</tt>, e.g.
<tt>instance</tt> is replaced by <tt>instancZ</tt>. This method is of course <tt>instance</tt> is replaced by <tt>instancZ</tt>. This method is of course
unsafe and should be replaced by something better. unsafe and should be replaced by something better.
<p>
The <tt>package</tt> format of GF 1.2 is made obsolete
by the module system. It is not handled properly by GF2.
@@ -334,10 +359,13 @@ first left bracket (<tt>{</tt>). The header gives
File name extensions: File name extensions:
<ul> <ul>
<li> <tt>gf</tt>: GF source file (uses GF syntax, is type checked and compiled) <li> <tt>gf</tt>: GF source file (uses GF syntax, is type checked and compiled)
<li> <tt>gfc</tt>: canonical GF file (uses GFC syntax, is only read in; produced <li> <tt>gfc</tt>: canonical GF file (uses GFC syntax, is simply read
from all kinds of modules) in instead of compiled; produced from all kinds of modules)
<li> <tt>gfr</tt>: GF resource file (uses GF syntax, is only read in; produced from <li> <tt>gfr</tt>: GF resource file (uses GF syntax, is only read in; produced from
<tt>resource</tt> modules) <tt>resource</tt> modules)
<li> <tt>gfcm</tt>: canonical multilingual GF file
(uses GFC syntax, is only read in; produced
from a set of <tt>abstract</tt> and <tt>conctrete</tt> modules)
</ul> </ul>
Only <tt>gf</tt> files should ever be written/edited manually! Only <tt>gf</tt> files should ever be written/edited manually!
@@ -359,6 +387,16 @@ Inside the GF shell, also time stamps of modules read into memory are
taken into account. Thus a module need not be read from a file if the taken into account. Thus a module need not be read from a file if the
module is in the memory and the file has not been modified. module is in the memory and the file has not been modified.
<p>
If the compilation of a grammar fails at some module, the state of the
GF shell contains all modules read up to that point. This makes it
faster to compile the faulty module again after fixing it.
<p>
Use the command <tt>po</tt> = <tt>print_options</tt> to see what
modules are in the state.
<p> <p>
@@ -374,6 +412,29 @@ To force compilation:
<!-- NEW --> <!-- NEW -->
<h2>Module search paths</h2>
Modules can reside in different directories. Use the <tt>path</tt>
flag to extend the directory search path. For instance,
<pre>
-path=.:../resource/russian:../prelude
</pre>
enables files to be found in three different directories.
By default, only the current directory is included.
If a <tt>path</tt> flag is given, the current directory
<tt>.</tt> must be explicitly included if it is wanted.
<p>
The <tt>path</tt> flag can be set in any of the following
places:
<ul>
<li> when invoking GF: <tt>gf -path=xxx</tt>
<li> when importing a module: <tt>i -path=xxx Foo.gf</tt>
<li> as a pragma in a topmost file: <tt>--# -path=xxx</tt>
</ul>
A flag set on a command line overrides ones set in files.
<!-- NEW --> <!-- NEW -->
</body> </body>

View File

@@ -6,6 +6,7 @@ import Modules
import Refresh ---- import Refresh ----
import TypeCheck import TypeCheck
import Values (cPredefAbs) ---
import PrGrammar import PrGrammar
import Lookup import Lookup
@@ -208,9 +209,9 @@ computeLType gr t = do
where where
comp ty = case ty of comp ty = case ty of
Q m _ | m == cPredef -> return ty Q m c | elem c [cPredef,cPredefAbs] -> return ty
Q m ident -> do Q m ident -> checkIn ("Q" +++ show m) $ do
ty' <- checkErr (lookupResDef gr m ident) ty' <- checkErr (lookupResDef gr m ident)
if ty' == ty then return ty else comp ty' --- is this necessary to test? if ty' == ty then return ty else comp ty' --- is this necessary to test?
@@ -259,7 +260,7 @@ checkReservedId x = let c = prt x in
inferLType :: SourceGrammar -> Term -> Check (Term, Type) inferLType :: SourceGrammar -> Term -> Check (Term, Type)
inferLType gr trm = case trm of inferLType gr trm = case trm of
Q m ident | m==cPredef -> termWith trm $ checkErr (typPredefined ident) Q m ident | isPredef m -> termWith trm $ checkErr (typPredefined ident)
Q m ident -> checks [ Q m ident -> checks [
termWith trm $ checkErr (lookupResType gr m ident) termWith trm $ checkErr (lookupResType gr m ident)
@@ -269,7 +270,7 @@ inferLType gr trm = case trm of
prtFail "cannot infer type of constant" trm prtFail "cannot infer type of constant" trm
] ]
QC m ident | m==cPredef -> termWith trm $ checkErr (typPredefined ident) QC m ident | isPredef m -> termWith trm $ checkErr (typPredefined ident)
QC m ident -> checks [ QC m ident -> checks [
termWith trm $ checkErr (lookupResType gr m ident) termWith trm $ checkErr (lookupResType gr m ident)
@@ -402,6 +403,8 @@ inferLType gr trm = case trm of
check = checkLType env check = checkLType env
isPredef m = elem m [cPredef,cPredefAbs]
justCheck ty te = check ty te >>= return . fst justCheck ty te = check ty te >>= return . fst
-- for record fields, which may be typed -- for record fields, which may be typed

View File

@@ -272,6 +272,7 @@ constPredefRes s = Q (IC "Predef") (zIdent s)
isPredefConstant t = case t of isPredefConstant t = case t of
Q (IC "Predef") _ -> True Q (IC "Predef") _ -> True
Q (IC "PredefAbs") _ -> True
_ -> False _ -> False
mkSelects :: Term -> [Term] -> Term mkSelects :: Term -> [Term] -> Term

View File

@@ -128,7 +128,12 @@ execC co@(comm, opts0) sa@((st,(h,_)),a) = checkOptions st co >> case comm of
ASTrm _ -> s2t a ASTrm _ -> s2t a
_ -> a _ -> a
case a' of case a' of
ATrms (trm:_) -> do ATrms (trm:_) -> case tree2exp trm of
G.EInt _ -> do
putStrLn "Warning: Number argument deprecated, use gr -number=n instead"
ts <- randomTreesIO opts gro (optIntOrN opts flagNumber 1)
returnArg (ATrms ts) sa
_ -> do
g <- newStdGen g <- newStdGen
case (goFirstMeta (tree2loc trm) >>= refineRandom g 41 cgr) of case (goFirstMeta (tree2loc trm) >>= refineRandom g 41 cgr) of
Ok trm' -> returnArg (ATrms [loc2tree trm']) sa Ok trm' -> returnArg (ATrms [loc2tree trm']) sa