mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
small things
This commit is contained in:
@@ -6,11 +6,11 @@
|
||||
|
||||
<h1>Grammatical Framework Version 2</h1>
|
||||
|
||||
Highlights, preliminary version
|
||||
Highlights, version 2.0
|
||||
|
||||
<p>
|
||||
|
||||
13/10/2003 - 25/11 - 2/4/2004
|
||||
13/10/2003 - 25/11 - 2/4/2004 - 18/6
|
||||
|
||||
<p>
|
||||
|
||||
@@ -21,7 +21,7 @@ Highlights, preliminary version
|
||||
|
||||
<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>
|
||||
@@ -32,19 +32,22 @@ An accurate <a href="DocGF.ps.gz">language specification</a> is now available.
|
||||
<tt>concrete</tt>, and <tt>resource</tt>.
|
||||
<li> Replaces the file-based <tt>include</tt> system
|
||||
<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> 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>.
|
||||
<li> New experimental module types: <tt>transfer</tt>,
|
||||
<tt>union</tt>.
|
||||
|
||||
|
||||
<h4>Canonical format GFC</h4>
|
||||
|
||||
<li> The target of GF compiler; to reuse, just read in
|
||||
<li> Readable by Haskell/Java/C++/C applications
|
||||
|
||||
|
||||
<h4>New features in expression language</h4>
|
||||
|
||||
<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> 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>h</tt> = <tt>help</tt> now in long or short form,
|
||||
and on individual commands.
|
||||
<li> All commands have both long and short names (see help). Long names
|
||||
are a handy way to make scripts more readable.
|
||||
<li> <tt>gt</tt> = <tt>generate_trees</tt>: all trees of a given
|
||||
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>
|
||||
|
||||
<li> Active text field (forthcoming, by Janna Khegai)
|
||||
<li> Clipboard
|
||||
<li> Active text field: click the middle button in the focus to send
|
||||
in refinement through the parser.
|
||||
<li> Clipboard: copy complex terms into the refine menu.
|
||||
|
||||
|
||||
<h4>Improved implementation</h4>
|
||||
|
||||
<li> Haskell source code organized into subdirectories.
|
||||
<li> BNF Converter used for defining the languages GF and GFC, which also
|
||||
<li> Haskell source code is organized into subdirectories.
|
||||
<li> BNF Converter is used for defining the languages GF and GFC, which also
|
||||
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.
|
||||
<li> GHC optimizations and strictness flags are used for improving performance.
|
||||
|
||||
<h4>New parser (forthcoming)</h4>
|
||||
|
||||
<li> By Peter Ljunglöf, based on MCFG
|
||||
<li> Much more efficient for morphology and discontinuous constituents
|
||||
<li> Treatment of cyclic rules
|
||||
<h4>New parser (work in progress)</h4>
|
||||
|
||||
<li> By Peter Ljunglöf, based on MCFG.
|
||||
<li> Much more efficient for morphology and discontinuous constituents.
|
||||
<li> Treatment of cyclic rules.
|
||||
|
||||
|
||||
|
||||
<!-- 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>
|
||||
|
||||
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>
|
||||
|
||||
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
|
||||
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>
|
||||
|
||||
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>
|
||||
|
||||
Example grammars and resource libraries are have been
|
||||
converted. There is a new resource API with
|
||||
many new constructions. The new versions lie in <tt>grammars/newresource</tt>.
|
||||
Resource libraries
|
||||
and some example grammars and have been
|
||||
converted. Most old example grammars work without any changes.
|
||||
There is a new resource API with
|
||||
many new constructions.
|
||||
|
||||
<p>
|
||||
|
||||
A make facility works, finding out which modules have to be recompiled.
|
||||
There is some room for improvement.
|
||||
|
||||
<p>
|
||||
|
||||
<tt>transfer</tt> modules have to be called by flags.
|
||||
|
||||
<p>
|
||||
|
||||
|
||||
Soundness checking of module depencencies and completeness is not
|
||||
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.
|
||||
|
||||
|
||||
|
||||
<!-- NEW -->
|
||||
|
||||
<h2>How to use GF 1.* files</h2>
|
||||
|
||||
Backward compatibility with respect to old GF grammars has been
|
||||
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
|
||||
introduced in GF 1.2, which would interfere too much with the new
|
||||
module system.
|
||||
the old way in GF2. The main exceptions are some features that
|
||||
are rarely used.
|
||||
<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>
|
||||
|
||||
@@ -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
|
||||
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:
|
||||
<ul>
|
||||
<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
|
||||
from all kinds of modules)
|
||||
<li> <tt>gfc</tt>: canonical GF file (uses GFC syntax, is simply read
|
||||
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
|
||||
<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>
|
||||
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
|
||||
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>
|
||||
|
||||
@@ -374,6 +412,29 @@ To force compilation:
|
||||
|
||||
<!-- 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 -->
|
||||
|
||||
</body>
|
||||
|
||||
@@ -6,6 +6,7 @@ import Modules
|
||||
import Refresh ----
|
||||
|
||||
import TypeCheck
|
||||
import Values (cPredefAbs) ---
|
||||
|
||||
import PrGrammar
|
||||
import Lookup
|
||||
@@ -208,9 +209,9 @@ computeLType gr t = do
|
||||
where
|
||||
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)
|
||||
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 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 [
|
||||
termWith trm $ checkErr (lookupResType gr m ident)
|
||||
@@ -269,7 +270,7 @@ inferLType gr trm = case trm of
|
||||
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 [
|
||||
termWith trm $ checkErr (lookupResType gr m ident)
|
||||
@@ -402,6 +403,8 @@ inferLType gr trm = case trm of
|
||||
|
||||
check = checkLType env
|
||||
|
||||
isPredef m = elem m [cPredef,cPredefAbs]
|
||||
|
||||
justCheck ty te = check ty te >>= return . fst
|
||||
|
||||
-- for record fields, which may be typed
|
||||
|
||||
@@ -272,6 +272,7 @@ constPredefRes s = Q (IC "Predef") (zIdent s)
|
||||
|
||||
isPredefConstant t = case t of
|
||||
Q (IC "Predef") _ -> True
|
||||
Q (IC "PredefAbs") _ -> True
|
||||
_ -> False
|
||||
|
||||
mkSelects :: Term -> [Term] -> Term
|
||||
|
||||
@@ -128,7 +128,12 @@ execC co@(comm, opts0) sa@((st,(h,_)),a) = checkOptions st co >> case comm of
|
||||
ASTrm _ -> s2t a
|
||||
_ -> a
|
||||
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
|
||||
case (goFirstMeta (tree2loc trm) >>= refineRandom g 41 cgr) of
|
||||
Ok trm' -> returnArg (ATrms [loc2tree trm']) sa
|
||||
|
||||
Reference in New Issue
Block a user