diff --git a/doc/gf2-highlights.html b/doc/gf2-highlights.html index c61afade5..d028ff133 100644 --- a/doc/gf2-highlights.html +++ b/doc/gf2-highlights.html @@ -6,11 +6,11 @@

Grammatical Framework Version 2

-Highlights, preliminary version +Highlights, version 2.0

-13/10/2003 - 25/11 - 2/4/2004 +13/10/2003 - 25/11 - 2/4/2004 - 18/6

@@ -21,7 +21,7 @@ Highlights, preliminary version

Syntax of GF

-An accurate language specification is now available. +An accurate language specification is now available.

Summary of novelties

@@ -32,19 +32,22 @@ An accurate language specification is now available. concrete, and resource.
  • Replaces the file-based include system
  • Name space handling with qualified names -
  • Hierarchic structure (extend) + cross-cutting reuse (open) +
  • Hierarchic structure (single inheritance **) + + cross-cutting reuse (open)
  • Separate compilation, one module per file
  • Reuse of abstract+concrete as resource -
  • New module types: +
  • Parametrized modules: interface, instance, incomplete.
  • New experimental module types: transfer, union. +

    Canonical format GFC

  • The target of GF compiler; to reuse, just read in
  • Readable by Haskell/Java/C++/C applications +

    New features in expression language

  • Disjunctive patterns P | ... | Q. @@ -56,76 +59,94 @@ An accurate language specification is now available.
  • Pattern variables can be used on lhs's of oper definitions.
  • New Unicode transliterations (by Harad Hammarström). -

    New shell commands

    + +

    New shell commands and command functionalities

  • pi = print_info: information on an identifier in scope.
  • h = help now in long or short form, and on individual commands. -
  • All commands have both long and short names (see help). Long names - are a handy way to make scripts more readable. +
  • gt = generate_trees: all trees of a given + category or instantiations of a given incomplete term, up to a + given depth. +
  • gr = generate_random can now be given + an incomplete term as an argument, to constrain generation. +
  • so = show_opers shows all ope + operations with a given value type. +
  • pm = print_multi prints the multilingual + grammar resident in the current state to a ready-compiles + .gfcm file. +
  • All commands have both long and short names (see help). Short + names are easier to type, whereas long names + make scripts more readable. +
  • Meaningless command options generate warnings.

    New editor features

    -
  • Active text field (forthcoming, by Janna Khegai) -
  • Clipboard +
  • Active text field: click the middle button in the focus to send + in refinement through the parser. +
  • Clipboard: copy complex terms into the refine menu. +

    Improved implementation

    -
  • Haskell source code organized into subdirectories. -
  • BNF Converter used for defining the languages GF and GFC, which also +
  • Haskell source code is organized into subdirectories. +
  • BNF Converter is used for defining the languages GF and GFC, which also give reliable LaTeX documentation. -
  • Lexican rules sorted out by option -cflexer for efficient +
  • Lexical rules sorted out by option -cflexer for efficient parsing with large lexica. +
  • GHC optimizations and strictness flags are used for improving performance. -

    New parser (forthcoming)

    -
  • By Peter Ljunglöf, based on MCFG -
  • Much more efficient for morphology and discontinuous constituents -
  • Treatment of cyclic rules +

    New parser (work in progress)

    + +
  • By Peter Ljunglöf, based on MCFG. +
  • Much more efficient for morphology and discontinuous constituents. +
  • Treatment of cyclic rules. -

    Status (24/3/2004)

    +

    Status (18/6/2004)

    -Grammar compiler, editor GUIs, and shell work. +Grammar compiler, editor GUIs, and shell work for all platforms +(with restrictions for Solaris).

    The updated HelpFile (accessible through h command) -marks unsupported but expected features with *. +marks unsupported features present in GF 1.2 with *. +They will be supported again if interested users appear.

    -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).

    -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 pg -printer=old.

    -Example grammars and resource libraries are have been -converted. There is a new resource API with -many new constructions. The new versions lie in grammars/newresource. +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.

    A make facility works, finding out which modules have to be recompiled. -There is some room for improvement.

    -transfer modules have to be called by flags. - -

    - - 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. +

    How to use GF 1.* files

    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 package 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. +

    @@ -212,10 +241,6 @@ with a variant where the last letter is replaced by Z, e.g. instance is replaced by instancZ. This method is of course unsafe and should be replaced by something better. -

    - -The package 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 ({). The header gives File name extensions:

    Only gf 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. +

    + +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. + +

    + +Use the command po = print_options to see what +modules are in the state.

    @@ -374,6 +412,29 @@ To force compilation: +

    Module search paths

    + +Modules can reside in different directories. Use the path +flag to extend the directory search path. For instance, +
    +  -path=.:../resource/russian:../prelude
    +
    +enables files to be found in three different directories. +By default, only the current directory is included. +If a path flag is given, the current directory +. must be explicitly included if it is wanted. + +

    + +The path flag can be set in any of the following +places: +

    +A flag set on a command line overrides ones set in files. + diff --git a/src/GF/Compile/CheckGrammar.hs b/src/GF/Compile/CheckGrammar.hs index f7df7102d..c4de7beb1 100644 --- a/src/GF/Compile/CheckGrammar.hs +++ b/src/GF/Compile/CheckGrammar.hs @@ -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 diff --git a/src/GF/Grammar/Macros.hs b/src/GF/Grammar/Macros.hs index cdaea6734..5b82b5d1c 100644 --- a/src/GF/Grammar/Macros.hs +++ b/src/GF/Grammar/Macros.hs @@ -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 diff --git a/src/GF/Shell.hs b/src/GF/Shell.hs index e00382bff..014f5bd60 100644 --- a/src/GF/Shell.hs +++ b/src/GF/Shell.hs @@ -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