summaryrefslogtreecommitdiff
path: root/src/compiler/GF
AgeCommit message (Collapse)Author
2015-08-13GF Shell: "ph | wf -file=foo.gfs" now works as advertisedhallgren
The print_history command was among the commands implemented in an ad-hoc way instead of being handled by the command line interpreter, which means it could not be used in a pipe, as in the example in the help info. The refactoring in the previous patch made this old bug easy to fix. Also fixed a bug in the "empty" command, introduced when moving the PGF from CommandEnv to GFEnv. TODO: fix the undocumented eh command. A comment in the help info for print_history, and some commented out old code, suggest that eh means "execute_history", but at present it does nothing...
2015-08-13GF Shell: refactoring for improved modularity and reusability:hallgren
+ Generalize the CommandInfo type by parameterizing it on the monad instead of just the environment. + Generalize the commands defined in GF.Command.{Commands,Commands2,CommonCommands,SourceCommands,HelpCommand} to work in any monad that supports the needed operations. + Liberate GF.Command.Interpreter from the IO monad. Also, move the current PGF from CommandEnv to GFEnv in GF.Interactive, making the command interpreter even more generic. + Use a state monad to maintain the state of the interpreter in GF.{Interactive,Interactive2}.
2015-08-12GF Shell: turn set_encoding into a common commandhallgren
Implemented in GF.Command.CommonCommands instead of GF.Interactive & GF.Interactive2.
2015-08-12GF.Interactive2: cleanuphallgren
2015-08-12GF shell: source commands (cc, sd, so, ss & dg) can now be used in pipeshallgren
These commands are now implemented as regular commands (i.e. using the CommandInfo data type) in the new module GF.Command.SourceCommands. The list of commands exported from GF.Command.Commmands now called pgfCommands instead of allCommands. The list allCommands of all commands is now assembled from sourceCommands, pgfCommands, commonCommands and helpCommand in GF.Interactive.
2015-08-12Move welcome message from GF.Interactive & GF.Interactive2 to ↵hallgren
GF.Command.Messages ...to avoid the duplication.
2015-08-11GF shell: make environment types abstract, comment out some dead codehallgren
2015-08-10gf -cshell: improved help for the 'import' commandhallgren
2015-08-10Factor out common code from GF.Command.Commands and GF.Command.Commands2hallgren
Created module GF.Command.CommonCommands with ~250 lines of code for commands that do not depend on the type of PGF in the environemnt, either because they don't use the PGF or because they are just documented here and implemented elsewhere. TODO: further refactoring so that documentation and implementation of *all* commands can be kept together.
2015-08-10gf -cshell: preliminary support for the C run-time system in the GF shellhallgren
Some C run-time functionality is now available in the GF shell, by starting GF with 'gf -cshell' or 'gf -crun'. Only limited functionality is available when running the shell in these modes: - You can only import .pgf files, not source files. - The -retain flag can not be used and the commands that require it to work are not available. - Only 18 of the 40 commands available in the usual shell have been implemented. The 'linearize' and 'parse' commands are the only ones that call the C run-time system, and they support only a limited set of options and flags. Use the 'help' commmands for details. - A new command 'generate_all', that calls PGF2.generateAll, has been added. Unfortuntaly, using it causes 'segmentation fault'. This is implemented by adding two new modules: GF.Command.Commands2 and GF.Interactive2. They are copied and modified versions of GF.Command.Commands and GF.Interactive, respectively. Code for unimplemented commands and other code that has not been adapted to the C run-time system has been left in place, but commented out, pending further work.
2015-08-10Refactor GF shell modules to improve modularity and reusabilityhallgren
+ Move type CommandInfo from GF.Command.Commands to a new module GF.Commands.CommandInfo and make it independent of the PGF type. + Make the module GF.Command.Interpreter independent of the PGF type and eliminate the import of GF.Command.Commands. + Move the implementation of the "help" command to its own module GF.Command.Help
2015-06-23Bump version of .gfo and .pgf files, improve error messages on version mismatchhallgren
Becacuse of the new special tokens added to the Symbol type, .gfo and .pgf files produced with the current version of GF can not always be used with older versions of GF and the PGF run-time system. The PGF version number was increased from (2,0) to (2,1). GF can still read version (2,0) and (1,0), so old PGF files continue to work. The GFO version was increased from "GF03" to "GF04".
2015-05-11"flags case_sensitive=off" makes the parser case insensitivekrasimir
2015-05-11added all orthographic primitiveskrasimir
2015-05-05GF.Haskell: small pretty printing improvementhallgren
2015-05-05GF.CompileOne: use random numbers to avoid temporary file name clasheshallgren
When using make -j to compile examples/app or examples/phrasebook, since the dependencies are not completely specified in the Makefiles, it can happen that the same file is compiled at the same by more than one process, resulting in an error when they try to write the same .gfo.tmp file. Adding a random number to the temporary file name avoids this problem.
2015-04-20drop the dependency to FSTkrasimir
2015-04-17gf -server: include grammar modification time in the info returned by /version hallgren
2015-04-14Translating linearization functions to Haskell: move Haskell AST and pretty ↵hallgren
printer to GF.Haskell For further separation of pretty printing concerns from conversion concerns, the Haskell AST and pretty printer has been moved to its own module, GF.Haskell, also allowing it to be reused in other places where Haskell code is generated.
2015-04-07GF.Compile.ConcreteToHaskell: some documentationhallgren
2015-03-31GF.CompileInParallel: get rid of the cryptic 'thread blocked indefinitely in ↵hallgren
an MVar operation' message after compilation errors Instead show a message saying how many modules were affected by the compilation errors.
2015-03-13GF.CompileInParallel: fix a Win32 problemhallgren
Recognize \ in addition to / when extracting path components.
2015-03-11GF.Server: request logging: increase length limit from 100 500 chars per fieldhallgren
2015-03-05remove some more old codekrasimir
2015-03-05removed some operations in GeneratePMCFG. They didn't work well with ↵krasimir
variants and are now obsolete with the new partial evaluator
2015-03-04GF.Compile.Compute.ConcreteNew: add dynamic table conversionhallgren
If the enumaration of table parameter values fails during the static traversal phase, try again in the dynamic computation phase, when the values of bound variables are known. This is necessary to properly deal with generic table construction in opers, like the ones found in prelude/Coordination.gf, e.g. consTable : (P : PType) -> ... = \P ... -> {s1 = table P {...} ; ... }
2015-03-04GF.Compile.Compute.ConcreteNew: some refactoring for readabilityhallgren
2015-03-02Fix to avoid "error (no reason given) OCCURRED IN optimizing <cat>"hallgren
GF.Compile.Optimize.mkLinReference can fail and cause this error because the helper function inside it applies msum to a list that might be empty (if there is a record type that does not contain a field of type Str). This means that it can return mzero::Err, i.e. Bad "error (no reason given)" which can slip through the top level test that only catches Bad "no string".
2015-02-27GF shell: fixed problems with previous change of the -retain flaghallgren
Because the prompt included the name of the abstract syntax, the loading of the PGF was forced even if -retain was used. Even worse, if an error occured while loading the PGF, it was repeated and caught every time the prompt was printed, creating an infite loop. The solution is to not print the name of the abstract syntax when the grammar is imported with -retain, which is the way things were before anyway.
2015-02-27GF shell: create a PGF also when the -retain flag is usedhallgren
The commands available in the shell after import -retain are now a superset of the commands available after import without -retain. The PGF is created lazily, so there should be no performance penalty if the PGF isn't needed. If there are errors, they won't be reported until a command that uses the PGF is entered.
2015-02-20added option -plus-as-bind which treats (+) as a bind when used with runtime ↵krasimir
variables
2015-02-20remove the meta prob flagskrasimir
2015-02-20PGF Service: limit the number of parallel calls to the C run-time parse ↵hallgren
function to 4 by default The limit can be changed with the -j flag
2015-02-16Changes for compatibility with ghc-7.10-rc2hallgren
2 modules: Name clashes caused by Applicative-Monad change in Prelude 2 modules: Ambiguities caused by Foldable/Traversable in Prelude 2 modules: Backwards incompatible changes in time-1.5 for defaultTimeLocale 9 modules: {-# LANGUAGE FlexibleContexts #-} (because GHC checks inferred types now, in addition to explicitly given type signatures) Also silenced warnings about tab characters in source files.
2015-02-12Translating linearization functions to Haskell: more simplificationshallgren
+ Some additional simplifying rewrites. + Use an intermediate representation for Haskell types, for separation of concerns and cleaner code. + Pretty printer layout tuning + Code cleanup.
2015-02-11Translating linearization functions to Haskell: simplify the generated ↵hallgren
Haskell code Introduced an intermediate representation for the generated Haskell expressions. This allows pretty printing concerns to be separated from conversion concerns, and makes it easy to apply some simplifying rewrites to the generated expressions, e.g. [x] ++ [y] ==> [x,y] pure f <*> x ==> f <$> x f <$> pure x ==> pure (f x) join (pure x) ==> x
2015-02-09Translating linearization functions to Haskell: support for variantshallgren
By adding the flag -haskell=variants to the command line, GF will now generate linearization functions in Haskell that support variants. Variants are represented as lists in Haskell. Variants inside pre { ... } expressions are still ignored. TODO: apply some monad laws to generate more compact code (using an intermediate representation of the generated Haskell code, instead of pretty printing directly from the GF code).
2015-01-19Translating linearization functions to Haskell: move a common record type to ↵hallgren
PGF.Haskell Move the Haskell representation of the common linearization type {s:T} to the shared module PGF.Haskell, so that the same overloaded projection function proj_s can be used for all concrete syntaxes.
2015-01-14Translating linearization functions to Haskell: better treatment of special ↵hallgren
tokens Common code has been lifted out from the generated Haskell modules to an auxiliary module PGF.Haskell, which is currently included in the regular PGF library, although it is independent of it and probably belongs in a separate library. The type Str used by linearization functions is now based on a token type Tok, which is defined in PGF.Haskell. PGF.Haskell.Tok is similar to the type GF.Data.Str.Tok, but it has constructors for the special tokens BIND, SOFT_BIND and CAPIT, and there is a function fromStr :: Str -> String that computes the effects of these special tokens.
2015-01-08Translating linearization functions to Haskell: add support for pre {...}hallgren
STILL TODO: - variants - better treatment of special tokens BIND, SOFT_BIND & CAPIT.
2015-01-07Translating linearization functions to Haskell: use qualified names to avoid ↵hallgren
name clashes All languages in the Phasebook can now be converted to compilable Haskell code. STILL TODO: - variants - pre { ... }
2015-01-06Translating linearization functions to Haskell: significant code size reductionshallgren
+ Instead of including lists of parameter values generated by GF, generate code to enumerate parameter values (in the same order as GF). This seems to give a factor of 2-3 code size reduction in the Phrasebook (e.g. from 84MB to 25MB for Hin, from 338MB to 154MB for Fre). + Deduplicate table entries, i.e. convert "table [..,E,..,E,..,E,..]" into "let x = E in table [..,x,..,x,..,x,..]". This gives even more significant code size reduction in some cases, e.g. from 569MB to 15MB for PhrasebookFin. All phrasebook languages can now be converted to compilable Haskell code, except PhrasebookPes, which still has the name clash problem.
2015-01-06More work on translating linearization functions to Haskellhallgren
Many Phrasebook languages can now be converted to compilable Haskell code. Some languages (Fre, Hin, Snd, Urd) generate too much Haskell code to be practically useful (e.g. 338MB for Fre). One language (Fin) took too long to convert to Haskell. One language (Pes) has problems with name clashes in the generated Haskell code. STILL TODO: - variants - pre { ... } - reduce code duplication for large tables - generate qualified names to avoid name clashes
2014-12-11Work in progress on translating linearization functions to Haskellhallgren
The translation is currently good enough to translate all concrete syntaxes of the Foods and Letter grammars, and some concrete syntaxes of the Phrasebook grammar (e.g. PhrasebookEng & PhrasebookSpa works, but there are problems with e.g. PhrasebookSwe and PhrasebookChi) This functionality is enabled by running gf -make -output-format=haskell -haskell=concrete ... TODO: - variants - pre { ... } - eta expansion of linearization functions - record subtyping can still cause type errors in the Haskell code in some cases - reduce code large tables
2014-12-11GF.Grammar.Macros: generalize the type of collectOphallgren
New type: collectOp :: Monoid m => (Term -> m) -> Term -> m
2014-12-11GF.Server: remove some code duplicationhallgren
2014-12-08Haddock documentation: expose exportPGF, some other small improvementshallgren
2014-12-05Eliminate the record extension operator from the Value type returned by the ↵hallgren
partial evaluator It was used only in cases where a lock field needed to be added to a run-time variable, like e.g. in examples/phrasebook/SentencesTha.gf: lin PGreetingMale g = mkText (lin Text g) (lin Text (ss "ครับ")) | g ; PGreetingFemale g = mkText (lin Text g) (lin Text (ss "ค่ะ")) | g ; But lock fields are only meaningful during type checking and can safely be ignored in later passes.
2014-11-10Documentation improvements and cleanup relating to the IOE monadhallgren
Renamed appIOE to tryIOE (it is analogous to 'try' in the standard libraries). Removed unused IOE operations & documented the remaining ones. Removed/simplified superfluous uses of IOE operations.
2014-11-10Some work to improve the structure of the haddock documenationhallgren