moving a few things to deprecated

This commit is contained in:
aarne
2009-12-09 09:47:16 +00:00
parent 101df06f6c
commit c8ceed08ef
676 changed files with 0 additions and 0 deletions

334
deprecated/homepage.html Normal file
View File

@@ -0,0 +1,334 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html><head><title>GF Version 2.9</title></head>
<body bgcolor="#ffffff" text="#000000">
<center>
<img src="gf-logo.gif">
<h1>Grammatical Framework</h1>
<h2>Version 2.9</h2>
December 21, 2007.
<p>
</center>
<hr>
<a href=
"doc">Documentation</a>
|
<a href=
"download/">Download</a>
|
<a href=
"doc/darcs.html">LatestCode</a>
|
<a href=
"doc/gf-quickstart.html">QuickStart</a>
|
<a href=
"doc/gf-tutorial.html">Tutorial</a>
|
<a href=
"doc/gf-refman.html">ReferenceManual</a>
|
<a href="lib/resource/doc/synopsis.html">Libraries</a>
|
<a href=
"http://www.cs.chalmers.se/~bringert/gf/translate/">NumeralDemo</a>
|
<a href=
"http://www.cs.chalmers.se/~markus/gramlets/letter-applet.html">LetterDemo</a>
<hr>
<p>
</p><h2>News</h2>
<i>June 25, 2008</i>.
<a href="doc/gf3-release.html">GF 3.0</a>
coming soon! Version 2.9f is now frozen and no longer
available in darcs. But <a href="download/GF-2.9f.tgz">here</a> is a tarball
with the final version of 2.9 sources.
<p>
<i>March 20, 2008</i>. Ten years of GF!
<ul>
<li> <a href="doc/nancy-slides.pdf">The first public talk</a> at INRIA Nancy,
20 March 1998.
<li> <a href="doc/GF-0.1.tgz">GF Version 0.1</a> source code from XRCE Grenoble
18 March 1998 (Requires the
<a href="http://www.cs.chalmers.se/~augustss/hbc/hbc.html">HBC Haskell Compiler</a>
in "no-pedantic" mode).
</ul>
<p>
<i>December 21, 2007</i>.
<ul>
<li> GF 2.9 is mainly a bug fix version;
<li> preview version of GF3: get the
<a href=
"http://www.cs.chalmers.se/Cs/Research/Language-technology/darcs/GF/doc/darcs.html">
latest sources</a> and compile with <tt>make gfc</tt>
<li> new version of the <a href="doc/gf-tutorial.html">tutorial</a>
<li> new <a href="doc/gf-refman.html">reference manual</a>
<li> <a href="demos/resource-api/editor.html">resource api browser</a>
using interactive editing
</ul>
<p>
<a href="doc/old-news.html">News before 2.9</a>.
</p><h2>What is GF?</h2>
The Grammatical Framework (=GF) is a grammar formalism based on type
theory. It consists of
<ul>
<li> a special-purpose programming language
</li><li> a compiler of the language
</li><li> a generic grammar processor
</li></ul>
The compiler reads
GF grammars from user-provided files,
and the generic grammar processor performs
various tasks with the grammars:
<ul>
<li> generation
</li><li> parsing
</li><li> translation
</li><li> type checking
</li><li> computation
</li><li> paraphrasing
</li><li> random and exhaustive generation
</li><li> syntax editing
</li></ul>
GF particularly addresses four aspects of grammars:
<ul>
<li> multilinguality (parallel grammars for different languages)
</li><li> semantics (semantic conditions of well-formedness, semantic
properties of expressions)
<li> modularity and grammar engineering
<li> reuse of grammars in different formats and as software components
</ul>
GF provides an easy way to experiment with grammars written in
different formats, including the ubiquitous BNF and EBNF formats.
The <a href="doc/gf-compiler.png">GF compilation chart</a> gives a
summary of the supported input and output formats (the nodes in ellipses).
<br>
For instance, if you want to create a finite-state automaton
in the HTK SLF format (to use for speech recognition), all you have to do
is to write an EBNF grammar in a file <tt>foo.ebnf</tt> and type
<pre>
echo "pg -printer=slf" | gf foo.ebnf
</pre>
<h2>License</h2>
GF is open-source software licensed under
<a href="LICENSE">GNU General Public License (GPL)</a>.
<p>
The <a href="lib">GF Grammar Libraries</a> are licensed under
<a href="lib/resource/LICENSE">GNU Lesser General Public License (LGPL)</a>.
<h2>Examples and demos</h2>
<a href="http://www.cs.chalmers.se/~bringert/gf/translate/">Numeral
translator</a>: recognizes and generates
numbers from 1 to 999,999 in 80 languages.
(The link goes to a live applet, which requires
<a href="http://java.sun.com/j2se/1.5.0/download.jsp">Java 1.5 plugin</a>.
Here is an <a href="doc/2341.html">example</a>, which does
not require the plugin.)
<p>
<a href="http://www.cs.chalmers.se/%7Ekrijo/gramlets/letter-applet.html">Letter
editor</a>:
write simple letters in English, Finnish,
French, Swedish, and Russian with a few mouse clicks.
<p>
<a
href="http://www.cs.chalmers.se/~bringert/misc/tramdemo.avi">Demo film</a>
of a multimodal dialogue system built with embedded grammars.
<p>
<a href="examples/tutorial/">Example grammars</a> used in the
<a href="doc/gf-tutorial.html">GF tutorial</a>.
<p>
<a href="lib/resource/doc/index.html">Resource grammar library</a>:
basic structures of ten languages
(Danish, English, Finnish, French, German,
Italian, Norwegian, Russian, Spanish, Swedish).
Resource grammars can be used as libraries for writing GF
applications,
but they can also be useful for language training.
<h2>Executable programs</h2>
GF is available for
several platforms: Linux, Mac OS X, Microsoft Windows, and Sun OS.
To get GF, go to the
<a href="download">Download Page</a>.
<h2>Quick start</h2>
When you have downloaded and installed GF, you can try one of the
<a href="doc/gf-quickstart.html">quick start examples</a>.
<h2>Source code</h2>
The main part of GF is written in
<a href="http://www.haskell.org/">Haskell</a>.
<p>
The platform-independent graphical user interface is written in
<a href="http://java.sun.com/">Java</a>.
</p><p>
The <a href="download/">Download Page</a>
gives links to source and binary packages, as well as
information on compiler requirements.
<p>
The publicly accessible
<a href="http://www.cs.chalmers.se/Cs/Research/Language-technology/darcs/GF/doc/darcs.html">
Darcs repository</a>
has the latest sources and documents.
<p>
For Java programmers: GF grammars can be embedded in Java programs by using the
<a href="http://www.cs.chalmers.se/~bringert/gf/gf-java.html">
Embedded GF Interpreter</a>.
</p><h2>Documents</h2>
See the <a href="doc/index.html">Documentation page</a>.
<h2>Projects and events</h2>
<li> <a href="http://webalt.math.helsinki.fi/content/index_eng.html">WebALT</a>,
Web Advanced Learning Technologies. GF is used as for generating multilingual
teaching material in mathematics.
<li> <a href="http://www.talk-project.org">TALK</a> = Tools for Ambient Linguistic
Knowledge</a>. GF was used in implementing multimodal and multilingual dialogue systems.
<li> <a href="http://www.key-project.org/">KeY</a> project on Integrated Deductive
Software Design. GF was used for
authoring informal and formal specifications. More details on the GF
application
<a href="http://www.cs.chalmers.se/%7Ekrijo/gfspec">
here</a>.
<li>
Project <a href="http://efficient.citi.tudor.lu/index_noframe.html">Efficient</a>
at Tudor Institute, Luxembourg, "atelier de prototypage de transactions d'e-commerce".
GF is used as an authoring tool for business models.
<h2>Miscellaneous</h2>
</li><li>
<a href="doc/gfcc.pdf">
GFCC</a>:
report on a compiler from a fragment of C to JVM, written in GF.
The compiler source code can be found in the directory
<tt>examples/gfcc</tt> in the GF grammar library
(see <a href="http://sourceforge.net/project/showfiles.php?group_id=132285">GF download page</a>).
</li><li>
The original <a href="http://www.xrce.xerox.com/">
GF Xerox Home Page</a>
with the oldest releases of and documents on GF, up to Version 0.54, 1999,
does not seem to exist any more.
</li><li>
Earlier application:
<a href="http://www.cs.chalmers.se/%7Ehallgren/Alfa/Tutorial/GFplugin.html">
Natural-Language Interface to the proof editor Alfa</a>.
</li><li>
<a href="http://www.cs.chalmers.se/%7Emarkus/BNFC">The BNF Converter</a>.
A GF spin-off customized for the description of programming
languages.
</li><li>
<a href="http://www.cs.chalmers.se/%7Emarkus/FM">The Functional
Morphology project</a>. Creating infrastructure for GF and other
linguistic applications.
</li></ul>
<h2>Authors</h2>
The <a href="http://www.cs.chalmers.se/Cs/Research/Language-technology/">
Languge Technology Group</a>.
More details on the
<a href="http://www.cs.chalmers.se/%7Eaarne/GF/doc/gf-people.html">
Authors and Acknowledgements</a> page.
<h2>Implementation project</h2>
Want to become a GF developer? Contact
<a href="http://www.cs.chalmers.se/%7Eaarne/">Aarne Ranta</a>.
Or just get the sources and start hacking.
<p>
And register to the
<a href="https://lists.sourceforge.net/lists/listinfo/gf-tools-users">GF User's Mailing List</a>!
<hr>
Last modified by
<a href="http://www.cs.chalmers.se/%7Eaarne">
Aarne Ranta</a>,
December 21, 2007.
</body></html>

211
deprecated/index.txt Normal file
View File

@@ -0,0 +1,211 @@
%!postproc(html): "#BECE" "<center>"
%!postproc(html): "#ENCE" "</center>"
%!postproc(html): "#BESMALL" "<font size=-1>"
%!postproc(html): "#ENSMALL" "</font>"
%!postproc(html): "#BELARGE" "<font size=+2>"
%!postproc(html): "#ENLARGE" "</font>"
#BECE
[doc/gf-logo.png]
=Grammatical Framework=
Version 3.0
June 2008
#BELARGE
``[`` [Demos demos/index.html]
``|`` [Download download/index.html]
``|`` [Libraries lib/resource/doc/synopsis.html]
``|`` [Reference doc/gf-refman.html]
``|`` [Tutorial doc/gf-tutorial.html]
``]``
#ENLARGE
``[`` [Demos demos/index.html]
``|`` [Download download/index.html]
``|`` [Developers doc/gf-developers.html]
% ``|`` [Events doc/events.html]
``|`` [Libraries lib/resource/doc/synopsis.html]
``|`` [People doc/gf-people.html]
% ``|`` [Projects doc/projects.html]
``|`` [Publications doc/gf-bibliography.html]
``|`` [QuickRefCard doc/gf-reference.html]
``|`` [Reference doc/gf-refman.html]
``|`` [Tutorial doc/gf-tutorial.html]
``]``
#ENCE
#BESMALL
==News==
20 April 2009:
On-line course "GF for Resource Grammar Writers" starting today at 15.30. See the
[Summer School Google Group http://groups.google.com/group/gf-resource-school-2009]
for instructions how to start.
3 April 2009:
Two demos and one talk on GF at [EACL http://www.eacl2009.gr/conference/] in Athens.
20 February 2009:
[GF Resource Grammar Summer School doc/gf-summerschool.html]
in Gothenburg, 17-28 August 2009.
4 November 2008:
GHC 6.10 released, but it doesn't work with GF sources yet.
If compiling GF from source, use e.g.
[GHC 6.8.3 http://haskell.org/ghc/download_ghc_683.html].
15 August 2008:
[Numeral translator for the iPhone demos/index-numbers.html]
27 June 2008:
[release of GF 3.0 doc/gf3-release.html] and this new web page; the old web page is
[here ../GF2/index.html].
#ENSMALL
==What is GF==
GF, Grammatical Framework, is a programming language for
**multilingual grammar applications**. It is
- a **special-purpose language for grammars**, like YACC, Bison, Happy, BNFC,
but not restricted to programming languages
- a **functional language**, like Haskell, Lisp, OCaml, Scheme, SML,
but specialized to grammar writing
- a **natural language processing framework**, like LKB, XLE, Regulus,
but based on functional programming and type theory
- a **categorial grammar formalism**, like ACG, CCG,
but different and equipped with different tools
- a **logical framework**, like Agda, Coq, Isabelle,
but equipped with concrete syntax in addition to logic
Don't worry if you don't know most of the references above - but if you do know at
least one, it may help you to get a first idea of what GF is.
==Applications==
GF can be used for building
- [text translators lib/resource/doc/resdemo.html]
- [speech translators http://www.cs.chalmers.se/~bringert/gf/translatespeech.html]
- [natural-language interfaces http://www.cs.chalmers.se/~hallgren/Alfa/Tutorial/GFplugin.html]
- [multilingual web pages http://www.restauranggajden.se/tomas/]
- [multilingual authoring systems http://www.cs.chalmers.se/~markus/gramlets/letter-applet.html]
- [dialogue systems http://www.cs.chalmers.se/~bringert/xv/pizza/]
- [language training systems http://csmisc14.cs.chalmers.se/~bjorn/langtrain.cgi]
- [natural language resources lib/resource/doc/synopsis.html]
==Availability==
GF is **open-source**, licensed under [GPL LICENSE] (the program) and
[LGPL lib/LICENSE] (the libraries). It
is available for
- Linux
- Mac OS X
- Windows
- via compilation to JavaScript, almost any platform that has a web browser
==Projects==
GF was first created in 1998 at
[Xerox Research Centre Europe http://www.xrce.xerox.com/],
Grenoble, in the project
Multilingual Document Authoring. At Xerox, it was used for prototypes including
a restaurant phrase book,
a database query system,
a formalization of an alarm system instructions with translations to 5 languages, and
an authoring system for medical drug descriptions.
Later projects using GF and involving third parties include, in chronological order,
- [GF-Alfa http://www.cs.chalmers.se/~hallgren/Alfa/Tutorial/GFplugin.html]:
natural language interface to formal proofs
- [Efficient http://efficient.citi.tudor.lu/index_noframe.html]:
authoring tool for business models.
- [GF-KeY http://www.key-project.org/]:
authoring and translation of software specifications
- [TALK http://www.talk-project.org]:
multilingual and multimodal spoken dialogue systems
- [WebALT http://webalt.math.helsinki.fi/]:
multilingual generation of mathematical exercises (commercial project)
- [SALDO http://spraakbanken.gu.se/sal/]:
Swedish morphological dictionary based on rules developed for GF and
[Functional Morphology http://www.cs.chalmers.se/~markus/FM/]
Academically, GF has been used in four PhD theses and resulted in around
fifty scientific publications (see [GF publication list doc/gf-bibliography.html]).
==Programming in GF==
GF is easy to learn by following the [tutorial doc/gf-tutorial.html].
You can write your first translator in 15 minutes.
GF has an interactive command interpreter, as well as a batch compiler.
Grammars can be compiled to parser and translator code in many different
formats. These components can then be embedded in applications written
in other programming languages. The formats currently supported are:
- Haskell
- Java
- JavaScript
- Prolog
- Speech recognition: HTK/ATK, Nuance, JSGF
The GF programming language is high-level and advanced, featuring
- static type checking
- higher-order functions
- dependent types
- pattern matching with data constructors and regular expressions
- module system with multiple inheritance and parametrized modules
==Libraries==
Libraries are at the heart of modern software engineering. In natural language
applications, libraries are a way to cope with thousands of details involved in
syntax, lexicon, and inflection. The
[GF resource grammar library lib/resource/doc/synopsis.html] has
support for an increasing number of languages, currently including
+ Arabic (partial)
+ Bulgarian
+ Catalan (partial)
+ Danish
+ English
+ Finnish
+ French
+ German
+ Hindi/Urdu (fragments)
+ [Interlingua http://www.interlingua.com/]
+ Italian
+ Norwegian bokm<6B>l
+ Russian
+ Spanish
+ Swedish
+ Thai (fragments)
Adding a language to the resource library takes 3 to 9
months - contributions
are welcome!
% [doc/10lang-small.png]

165
deprecated/old-lib/LICENSE Normal file
View File

@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@@ -0,0 +1,19 @@
CC = gcc
CFLAGS += -O2 -W -Wall
.PHONY: all clean
all: libgfcc.a
libgfcc.a: gfcc-tree.o gfcc-term.o
ar r $@ $^
gfcc-tree.o: gfcc-tree.c gfcc-tree.h
$(CC) $(CFLAGS) -c -o $@ $<
gfcc-term.o: gfcc-term.c gfcc-term.h
$(CC) $(CFLAGS) -c -o $@ $<
clean:
-rm -f libgfcc.a
-rm -f *.o

View File

@@ -0,0 +1,203 @@
#include "gfcc-term.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
static void *buffer = NULL;
static size_t current;
extern void term_alloc_pool(size_t size) {
if (buffer == NULL)
buffer = malloc(size);
current = 0;
}
extern void term_free_pool() {
if (buffer != NULL)
free(buffer);
buffer = NULL;
}
extern void *term_alloc(size_t size) {
void *off = buffer + current;
current += size;
return off;
}
static inline Term *create_term(TermType type, int n) {
Term *t = (Term*)term_alloc(sizeof(Term) + n * sizeof(Term *));
t->type = type;
t->value.size = n; /* FIXME: hack! */
return t;
}
extern Term *term_array(int n, ...) {
Term *t = create_term(TERM_ARRAY, n);
va_list ap;
int i;
va_start(ap, n);
for (i = 0; i < n; i++) {
term_set_child(t, i, va_arg(ap, Term *));
}
va_end(ap);
return t;
}
extern Term *term_seq(int n, ...) {
Term *t = create_term(TERM_SEQUENCE, n);
va_list ap;
int i;
va_start(ap, n);
for (i = 0; i < n; i++) {
term_set_child(t, i, va_arg(ap, Term *));
}
va_end(ap);
return t;
}
extern Term *term_variants(int n, ...) {
Term *t = create_term(TERM_VARIANTS, n);
va_list ap;
int i;
va_start(ap, n);
for (i = 0; i < n; i++) {
term_set_child(t, i, va_arg(ap, Term *));
}
va_end(ap);
return t;
}
extern Term *term_glue(int n, ...) {
Term *t = create_term(TERM_GLUE, n);
va_list ap;
int i;
va_start(ap, n);
for (i = 0; i < n; i++) {
term_set_child(t, i, va_arg(ap, Term *));
}
va_end(ap);
return t;
}
extern Term *term_rp(Term *t1, Term *t2) {
Term *t = create_term(TERM_RECORD_PARAM, 2);
term_set_child(t, 0, t1);
term_set_child(t, 1, t2);
return t;
}
extern Term *term_suffix(const char *pref, Term *suf) {
Term *t = create_term(TERM_SUFFIX_TABLE, 2);
term_set_child(t,0,term_str(pref));
term_set_child(t,1,suf);
return t;
}
extern Term *term_str(const char *s) {
Term *t = create_term(TERM_STRING, 0);
t->value.string_value = s;
return t;
}
extern Term *term_int(int i) {
Term *t = create_term(TERM_INTEGER,0);
t->value.integer_value = i;
return t;
}
extern Term *term_meta() {
return create_term(TERM_META, 0);
}
extern Term *term_sel_int(Term *t, int i) {
switch (t->type) {
case TERM_ARRAY:
return term_get_child(t,i);
case TERM_SUFFIX_TABLE:
return term_glue(2,
term_get_child(t,0),
term_sel_int(term_get_child(t,1),i));
case TERM_META:
return t;
default:
fprintf(stderr,"Error: term_sel_int %d %d\n", t->type, i);
exit(1);
return NULL;
}
}
extern Term *term_sel(Term *t1, Term *t2) {
switch (t2->type) {
case TERM_INTEGER:
return term_sel_int(t1, t2->value.integer_value);
case TERM_RECORD_PARAM:
return term_sel(t1,term_get_child(t2,0));
case TERM_META:
return term_sel_int(t1,0);
default:
fprintf(stderr,"Error: term_sel %d %d\n", t1->type, t2->type);
exit(1);
return 0;
}
}
static void term_print_sep(FILE *stream, Term *t, const char *sep) {
int n = t->value.size;
int i;
for (i = 0; i < n; i++) {
term_print(stream, term_get_child(t,i));
if (i < n-1) {
fputs(sep, stream);
}
}
}
extern void term_print(FILE *stream, Term *t) {
switch (t->type) {
case TERM_ARRAY:
term_print(stream, term_get_child(t,0));
break;
case TERM_SEQUENCE:
term_print_sep(stream, t, " ");
break;
case TERM_VARIANTS:
term_print_sep(stream, t, "/");
break;
case TERM_GLUE:
term_print_sep(stream, t, "");
break;
case TERM_RECORD_PARAM:
term_print(stream, term_get_child(t,0));
break;
case TERM_SUFFIX_TABLE:
term_print(stream, term_get_child(t,0));
term_print(stream, term_get_child(t,1));
break;
case TERM_META:
fputs("?", stream);
break;
case TERM_STRING:
fputs(t->value.string_value, stream);
break;
case TERM_INTEGER:
fprintf(stream, "%d", t->value.integer_value);
break;
default:
fprintf(stderr,"Error: term_print %d\n", t->type);
exit(1);
}
}

View File

@@ -0,0 +1,65 @@
#ifndef GFCC_TERM_H
#define GFCC_TERM_H
#include <stdio.h>
typedef enum {
/* size = variable */
TERM_ARRAY,
TERM_SEQUENCE,
TERM_VARIANTS,
TERM_GLUE,
/* size = 2 */
TERM_RECORD_PARAM,
TERM_SUFFIX_TABLE,
/* size = 0 */
TERM_META,
TERM_STRING,
TERM_INTEGER
} TermType;
struct Term_ {
TermType type;
union {
const char *string_value;
int integer_value;
int size;
} value;
struct Term_ *args[0];
};
typedef struct Term_ Term;
static inline Term *term_get_child(Term *t, int n) {
return t->args[n];
}
static inline void term_set_child(Term *t, int n, Term *c) {
t->args[n] = c;
}
extern void term_alloc_pool(size_t size);
extern void term_free_pool();
extern void *term_alloc(size_t size);
extern Term *term_array(int n, ...);
extern Term *term_seq(int n, ...);
extern Term *term_variants(int n, ...);
extern Term *term_glue(int n, ...);
extern Term *term_rp(Term *t1, Term *t2);
extern Term *term_suffix(const char *pref, Term *suf);
extern Term *term_str(const char *s);
extern Term *term_int(int i);
extern Term *term_meta();
extern Term *term_sel_int(Term *t, int i);
extern Term *term_sel(Term *t1, Term *t2);
extern void term_print(FILE *stream, Term *t);
#endif

View File

@@ -0,0 +1,61 @@
#include "gfcc-tree.h"
#include <stdlib.h>
extern int arity(Tree *t) {
switch (t->type) {
case ATOM_STRING:
case ATOM_INTEGER:
case ATOM_DOUBLE:
case ATOM_META:
return 0;
default:
return t->value.size;
}
}
static Tree *create_tree(atom_type c, int n) {
Tree *t = (Tree *)malloc(sizeof(Tree) + n * sizeof(Tree *));
t->type = c;
return t;
}
extern Tree *tree_string(const char *s) {
Tree *t = create_tree(ATOM_STRING, 0);
t->value.string_value = s;
return t;
}
extern Tree *tree_integer(int i) {
Tree *t = create_tree(ATOM_INTEGER, 0);
t->value.integer_value = i;
return t;
}
extern Tree *tree_double(double d) {
Tree *t = create_tree(ATOM_DOUBLE, 0);
t->value.double_value = d;
return t;
}
extern Tree *tree_meta() {
return create_tree(ATOM_META, 0);
}
extern Tree *tree_fun(atom_type f, int n) {
Tree *t = create_tree(f, n);
t->value.size = n;
return t;
}
extern void tree_free(Tree *t) {
int n = arity(t);
int i;
for (i = 0; i < n; i++) {
tree_free(tree_get_child(t,i));
}
free(t);
}

View File

@@ -0,0 +1,49 @@
#ifndef GFCC_TREE_H
#define GFCC_TREE_H
typedef enum {
ATOM_STRING,
ATOM_INTEGER,
ATOM_DOUBLE,
ATOM_META,
ATOM_FIRST_FUN
} atom_type;
struct Tree_{
atom_type type;
union {
const char *string_value;
int integer_value;
double double_value;
int size;
} value;
struct Tree_ *args[0];
};
typedef struct Tree_ Tree;
static inline Tree *tree_get_child(Tree *t, int n) {
return t->args[n];
}
static inline void tree_set_child(Tree *t, int n, Tree *a) {
t->args[n] = a;
}
extern int arity(Tree *t);
extern Tree *tree_string(const char *s);
extern Tree *tree_integer(int i);
extern Tree *tree_double(double d);
extern Tree *tree_meta();
extern Tree *tree_fun(atom_type f, int n);
extern void tree_free(Tree *t);
#endif

View File

@@ -0,0 +1,60 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META NAME="generator" CONTENT="http://txt2tags.sf.net">
<TITLE>GF Grammar Libraries</TITLE>
</HEAD><BODY BGCOLOR="white" TEXT="black">
<P ALIGN="center"><CENTER><H1>GF Grammar Libraries</H1>
<FONT SIZE="4">
<I>Author: Aarne Ranta &lt;aarne (at) cs.chalmers.se&gt;</I><BR>
Last update: Fri Dec 22 15:19:46 2006
</FONT></CENTER>
<P>
One of the main ideas of
<A HREF="..">GF</A>
is the use of libraries in grammar writing, in a way familiar
from software engineering. In this way, large grammars can
be built in cooperation, and old grammars or parts of them
can be reused in new grammars. The slides
<A HREF="resource-1.0/doc/gslt-sem-2006.html">Grammars as Software Libraries</A>
give some introduction to this idea.
</P>
<H2>The resource grammar library</H2>
<P>
This library covers basic linguistic structures of
different languages.
</P>
<P>
<A HREF="resource-1.0/doc">Version 1.1</A> released 22 December 2006
(enhanced version of 1.0).
Covers Danish, English, Finnish, French, German, Italian, Norwegian,
Russian, Spanish, and Swedish.
</P>
<P>
Two older versions are also available:
<A HREF="resource/">Version 0.9</A>
and
<A HREF="resource-0.6/">Version 0.6</A>.
</P>
<H2>The prelude library</H2>
<P>
The <A HREF="prelude/">prelude</A>
library gives utility functions for different GF applications:
</P>
<P>
<A HREF="resource-1.0/doc/gfdoc/Precedence.html">Precedence</A>. Utilities for
formal languages: precedence levels, associatives, infixes.
</P>
<P>
<A HREF="resource-1.0/doc/gfdoc/Predef.html">Predef</A>. Type signatures
of predefined (hard-coded) functions.
</P>
<P>
<A HREF="resource-1.0/doc/gfdoc/Prelude.html">Prelude</A>. Generic utilities
for strings, tables, records, booleans.
</P>
<!-- html code generated by txt2tags 2.3 (http://txt2tags.sf.net) -->
<!-- cmdline: txt2tags index.txt -->
</BODY></HTML>

View File

@@ -0,0 +1,58 @@
GF Grammar Libraries
Author: Aarne Ranta <aarne (at) cs.chalmers.se>
Last update: %%date(%c)
% NOTE: this is a txt2tags file.
% Create an html file from this file using:
% txt2tags --toc -thtml index.txt
%!target:html
One of the main ideas of
[GF ..]
is the use of libraries in grammar writing, in a way familiar
from software engineering. In this way, large grammars can
be built in cooperation, and old grammars or parts of them
can be reused in new grammars. The slides
[Grammars as Software Libraries resource-1.0/doc/gslt-sem-2006.html]
give some introduction to this idea.
==The resource grammar library==
This library covers basic linguistic structures of
different languages.
[Version 1.2 resource-1.0/doc] released 22 December 2006
(enhanced version of 1.0).
Covers Danish, English, Finnish, French, German, Italian, Norwegian,
Russian, Spanish, and Swedish, and to a smaller extent Arabic and Catalan.
Two older versions are also available:
[Version 0.9 resource/]
and
[Version 0.6 resource-0.6/].
==The prelude library==
The [prelude prelude/]
library gives utility functions for different GF applications:
[Precedence resource-1.0/doc/gfdoc/Precedence.html]. Utilities for
formal languages: precedence levels, associatives, infixes.
[Predef resource-1.0/doc/gfdoc/Predef.html]. Type signatures
of predefined (hard-coded) functions.
[Prelude resource-1.0/doc/gfdoc/Prelude.html]. Generic utilities
for strings, tables, records, booleans.
==License==
All libraries in this directory and its subdirectories are
releaced under GNU Lesser General Public License (LGPL). See the file
[LICENSE ./LICENSE] for more details.

View File

@@ -0,0 +1,17 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="gflib.js"></script>
<script type="text/javascript" src="editorGrammar.js"></script>
<script type="text/javascript" src="grammar.js"></script>
<script type="text/javascript" src="gfjseditor.js"></script>
<title>Web-based Syntax Editor</title>
</head>
<body onload="mkEditor('editor', Food)" onkeydown="hotKeys(event)">
<div id="editor">
</div>
</body>
</html>

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 B

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,54 @@
/* Output */
function sayText(text) {
document.voice_output_text = text;
activateForm("voice_output");
}
/* XHTML+Voice Utilities */
function activateForm(formid) {
var form = document.getElementById(formid);
var e = document.createEvent("UIEvents");
e.initEvent("DOMActivate","true","true");
form.dispatchEvent(e);
}
/* DOM utilities */
/* Gets the head element of the document. */
function getHeadElement() {
var hs = document.getElementsByTagName("head");
if (hs.length == 0) {
var head = document.createElement("head");
document.documentElement.insertBefore(head, document.documentElement.firstChild);
return head;
} else {
return hs[0];
}
}
/* Gets the body element of the document. */
function getBodyElement() {
var bs = document.getElementsByTagName("body");
if (bs.length == 0) {
var body = document.createElement("body");
document.documentElement.appendChild(body);
return body;
} else {
return bs[0];
}
}
/* Removes all the children of a node */
function removeChildren(node) {
while (node.hasChildNodes()) {
node.removeChild(node.firstChild);
}
}
function setText(node, text) {
removeChildren(node);
node.appendChild(document.createTextNode(text));
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

View File

@@ -0,0 +1,241 @@
body {
font-family:arial,helvetica,sans-serif;
font-size:12px;
background-color: white;
}
#wrapper {
width:740px;
height:520px;
margin:auto 50px;
border:1px solid gray;
padding:10px;
}
#absFrame {
width:250px;
height:250px;
padding:10px;
border:1px solid gray;
float:left;
white-space: nowrap;
}
#conFrame {
width:436px;
height:250px;
margin-left:10px;
padding:10px;
border:1px solid gray;
float:left;
white-space: normal;
overflow:auto;
}
#actFrame {
width:250px;
height:170px;
margin-top:10px;
padding:10px;
border:1px solid gray;
float:left;
overflow:auto;
}
#refFrame {
width:436px;
height:170px;
margin-left:10px;
margin-top:10px;
padding:10px;
border:1px solid gray;
float:left;
overflow:auto;
}
#messageFrame {
width:506px;
height:15px;
margin-top:10px;
margin-right:10px;
padding:10px;
border:1px solid gray;
float:left;
overflow:hidden;
}
#clipboardFrame {
width:180px;
height:15px;
margin-top:10px;
padding:10px;
border:1px solid gray;
float:left;
overflow:auto;
}
#tree {
left: -10px;
top: -10px;
width: 250px;
height: 250px;
margin: 0px;
padding: 10px;
overflow: auto;
}
ul {
position: relative;
list-style: none;
margin-left: 20px;
padding: 0px;
}
li {
position: relative;
}
img.tree-menu {
margin-right: 5px;
}
a.tree:link, a.tree:visited, a.tree:active {
color: black;
background-color: white;
text-decoration: none;
margin-right:10px;
}
a.tree:hover {
color: blue;
background-color: white;
text-decoration: underline;
margin-right:10px;
}
a.treeSelected:link, a.treeSelected:visited, a.treeSelected:active {
color: white;
background-color: #3366CC;
text-decoration: none;
margin-right:10px;
}
a.treeSelected:hover {
color: white;
background-color: #3366CC;
text-decoration: underline;
margin-right:10px;
}
a.treeGray:link, a.treeGray:visited, a.treeGray:active {
color: silver;
background-color: white;
text-decoration: none;
margin-right:10px;
}
a.treeGray:hover {
color: silver;
background-color: white;
text-decoration: none;
margin-right:10px;
}
table.action, table.refinement, table.wrapper, table.tree, table.language {
margin: 0px;
padding: 0px;
border-style: none;
border-collapse: collapse;
border-spacing: 0px;
}
tr.selected {
color: white;
background-color: #3366CC;
}
tr.unavailable, tr.closed {
color: silver;
background-color: white;
}
tr.unavailable:hover {
color: silver;
background-color: #3366CC;
}
tr.action, tr.refinement, tr.wrapper, tr.tree {
color: black;
background-color: white;
}
tr.action:hover, tr.refinement:hover, tr.wrapper:hover, tr.tree:hover {
color: white;
background-color: #3366CC;
}
td.action {
width: 220px;
margin: 0px;
padding: 0px;
}
td.refinement, td.wrapper, td.tree {
width: 515px;
margin: 0px;
padding: 0px;
}
td.hotKey {
width: 30px;
margin: 0px;
padding: 0px;
text-align: right;
}
td.language {
color: black;
background-color: white;
margin: 1px;
padding: 1px;
}
td.language:hover {
color: blue;
background-color: white;
text-decoration: underline;
margin: 1px;
padding: 1px;
}
td.selected {
color: white;
background-color: #3366CC;
margin: 1px;
padding: 1px;
}
td.selected:hover {
color: white;
background-color: #3366CC;
text-decoration: underline;
margin: 1px;
padding: 1px;
}
p {
margin-bottom: 40px;
}
span.normal {
color: black;
background-color: white;
text-decoration: none;
}
span.selected {
color: white;
background-color: #3366CC;
text-decoration: none;
}

View File

@@ -0,0 +1,54 @@
body {
color: black;
background-color: white;
}
dl {
}
dt {
margin: 0;
padding: 0;
}
dl dd {
margin: 0;
padding: 0;
}
dl.fromLang dt {
display: none;
}
dl.toLang {
border-width: 1px 0 0 0;
border-style: solid;
border-color: #c0c0c0;
}
dl.toLang dt {
color: #c0c0c0;
display: block;
float: left;
width: 5em;
}
dl.toLang dd {
border-width: 0 0 1px 0;
border-style: solid;
border-color: #c0c0c0;
}
ul {
margin: 0;
padding: 0;
}
li {
list-style-type: none;
margin: 0;
padding: 0;
}

View File

@@ -0,0 +1,48 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="translator.css" />
<script type="text/javascript" src="gflib.js"></script>
<script type="text/javascript" src="grammar.js"></script>
<script type="text/javascript" src="translator.js"></script>
<script type="text/javascript">
/* CHANGE ME */
var grammar = Food;
function updateTranslation () {
var input = document.getElementById('inputText').value;
var fromLang = document.getElementById('fromLang').value;
var toLang = document.getElementById('toLang').value;
var output = document.getElementById('output');
var translation = grammar.translate(input, fromLang, toLang);
removeChildren(output);
output.appendChild(formatTranslation(translation));
}
function populateLangs () {
var f = document.getElementById('fromLang');
var t = document.getElementById('toLang');
for (var c in grammar.concretes) {
addOption(f, c, c);
addOption(t, c, c);
}
}
</script>
<title>Web-based GF Translator</title>
</head>
<body onload="populateLangs(Food, 'fromLang', 'toLang')">
<form id="translate">
<p>
<input type="text" name="inputText" id="inputText" value="this cheese is warm" size="50" />
</p>
<p>
From: <select name="fromLang" id="fromLang" onchange=""><option value="">Any language</option></select>
To: <select name="toLang" id="toLang"><option value="">All languages</option></select>
<input type="button" value="Translate" onclick="updateTranslation()" />
</p>
</form>
<div id="output"></div>
</body>
</html>

View File

@@ -0,0 +1,51 @@
function formatTranslation (outputs) {
var dl1 = document.createElement("dl");
dl1.className = "fromLang";
for (var fromLang in outputs) {
var ul = document.createElement("ul");
addDefinition(dl1, document.createTextNode(fromLang), ul);
for (var i in outputs[fromLang]) {
var dl2 = document.createElement("dl");
dl2.className = "toLang";
for (var toLang in outputs[fromLang][i]) {
addDefinition(dl2, document.createTextNode(toLang), document.createTextNode(outputs[fromLang][i][toLang]));
}
addItem(ul, dl2);
}
}
return dl1;
}
/* DOM utilities for specific tags */
function addDefinition (dl, t, d) {
var dt = document.createElement("dt");
dt.appendChild(t);
dl.appendChild(dt);
var dd = document.createElement("dd");
dd.appendChild(d);
dl.appendChild(dd);
}
function addItem (ul, i) {
var li = document.createElement("li");
li.appendChild(i);
ul.appendChild(li);
}
function addOption (select, value, content) {
var option = document.createElement("option");
option.value = value;
option.appendChild(document.createTextNode(content));
select.appendChild(option);
}
/* General DOM utilities */
/* Removes all the children of a node */
function removeChildren(node) {
while (node.hasChildNodes()) {
node.removeChild(node.firstChild);
}
}

View File

@@ -0,0 +1,129 @@
resource Coordination = open Prelude in {
param
ListSize = TwoElem | ManyElem ;
oper
ListX = {s1,s2 : Str} ;
twoStr : (x,y : Str) -> ListX = \x,y ->
{s1 = x ; s2 = y} ;
consStr : Str -> ListX -> Str -> ListX = \comma,xs,x ->
{s1 = xs.s1 ++ comma ++ xs.s2 ; s2 = x } ;
twoSS : (_,_ : SS) -> ListX = \x,y ->
twoStr x.s y.s ;
consSS : Str -> ListX -> SS -> ListX = \comma,xs,x ->
consStr comma xs x.s ;
Conjunction : Type = SS ;
ConjunctionDistr : Type = {s1 : Str ; s2 : Str} ;
conjunctX : Conjunction -> ListX -> Str = \or,xs ->
xs.s1 ++ or.s ++ xs.s2 ;
conjunctDistrX : ConjunctionDistr -> ListX -> Str = \or,xs ->
or.s1 ++ xs.s1 ++ or.s2 ++ xs.s2 ;
conjunctSS : Conjunction -> ListX -> SS = \or,xs ->
ss (xs.s1 ++ or.s ++ xs.s2) ;
conjunctDistrSS : ConjunctionDistr -> ListX -> SS = \or,xs ->
ss (or.s1 ++ xs.s1 ++ or.s2 ++ xs.s2) ;
-- all this lifted to tables
ListTable : Type -> Type = \P -> {s1,s2 : P => Str} ;
twoTable : (P : Type) -> (_,_ : {s : P => Str}) -> ListTable P = \_,x,y ->
{s1 = x.s ; s2 = y.s} ;
consTable : (P : Type) -> Str -> ListTable P -> {s : P => Str} -> ListTable P =
\P,c,xs,x ->
{s1 = table P {o => xs.s1 ! o ++ c ++ xs.s2 ! o} ; s2 = x.s} ;
conjunctTable : (P : Type) -> Conjunction -> ListTable P -> {s : P => Str} =
\P,or,xs ->
{s = table P {p => xs.s1 ! p ++ or.s ++ xs.s2 ! p}} ;
conjunctDistrTable :
(P : Type) -> ConjunctionDistr -> ListTable P -> {s : P => Str} = \P,or,xs ->
{s = table P {p => or.s1++ xs.s1 ! p ++ or.s2 ++ xs.s2 ! p}} ;
-- ... and to two- and three-argument tables: how clumsy! ---
ListTable2 : Type -> Type -> Type = \P,Q ->
{s1,s2 : P => Q => Str} ;
twoTable2 : (P,Q : Type) -> (_,_ : {s : P => Q => Str}) -> ListTable2 P Q =
\_,_,x,y ->
{s1 = x.s ; s2 = y.s} ;
consTable2 :
(P,Q : Type) -> Str -> ListTable2 P Q -> {s : P => Q => Str} -> ListTable2 P Q =
\P,Q,c,xs,x ->
{s1 = table P {p => table Q {q => xs.s1 ! p ! q ++ c ++ xs.s2 ! p! q}} ;
s2 = x.s
} ;
conjunctTable2 :
(P,Q : Type) -> Conjunction -> ListTable2 P Q -> {s : P => Q => Str} =
\P,Q,or,xs ->
{s = table P {p => table Q {q => xs.s1 ! p ! q ++ or.s ++ xs.s2 ! p ! q}}} ;
conjunctDistrTable2 :
(P,Q : Type) -> ConjunctionDistr -> ListTable2 P Q -> {s : P => Q => Str} =
\P,Q,or,xs ->
{s =
table P {p => table Q {q => or.s1++ xs.s1 ! p ! q ++ or.s2 ++ xs.s2 ! p ! q}}} ;
ListTable3 : Type -> Type -> Type -> Type = \P,Q,R ->
{s1,s2 : P => Q => R => Str} ;
twoTable3 : (P,Q,R : Type) -> (_,_ : {s : P => Q => R => Str}) ->
ListTable3 P Q R =
\_,_,_,x,y ->
{s1 = x.s ; s2 = y.s} ;
consTable3 :
(P,Q,R : Type) -> Str -> ListTable3 P Q R -> {s : P => Q => R => Str} ->
ListTable3 P Q R =
\P,Q,R,c,xs,x ->
{s1 = \\p,q,r => xs.s1 ! p ! q ! r ++ c ++ xs.s2 ! p ! q ! r ;
s2 = x.s
} ;
conjunctTable3 :
(P,Q,R : Type) -> Conjunction -> ListTable3 P Q R -> {s : P => Q => R => Str} =
\P,Q,R,or,xs ->
{s = \\p,q,r => xs.s1 ! p ! q ! r ++ or.s ++ xs.s2 ! p ! q ! r} ;
conjunctDistrTable3 :
(P,Q,R : Type) -> ConjunctionDistr -> ListTable3 P Q R ->
{s : P => Q => R => Str} =
\P,Q,R,or,xs ->
{s = \\p,q,r => or.s1++ xs.s1 ! p ! q ! r ++ or.s2 ++ xs.s2 ! p ! q ! r} ;
comma = "," ;
-- you can also do this to right-associative lists:
consrStr : Str -> Str -> ListX -> ListX = \comma,x,xs ->
{s1 = x ++ comma ++ xs.s1 ; s2 = xs.s2 } ;
consrSS : Str -> SS -> ListX -> ListX = \comma,x,xs ->
consrStr comma x.s xs ;
consrTable : (P : Type) -> Str -> {s : P => Str} -> ListTable P -> ListTable P =
\P,c,x,xs ->
{s1 = table P {o => x.s ! o ++ c ++ xs.s1 ! o} ; s2 = xs.s2} ;
consrTable2 : (P,Q : Type) -> Str -> {s : P => Q => Str} ->
ListTable2 P Q -> ListTable2 P Q =
\P,Q,c,x,xs ->
{s1 = table P {p => table Q {q => x.s ! p ! q ++ c ++ xs.s1 ! p ! q}} ;
s2 = xs.s2
} ;
} ;

View File

@@ -0,0 +1,54 @@
resource Formal = open Prelude in {
-- to replace the old library Precedence
oper
Prec : PType ;
TermPrec : Type = {s : Str ; p : Prec} ;
mkPrec : Prec -> Str -> TermPrec = \p,s ->
{s = s ; p = p} ;
top : TermPrec -> Str = usePrec 0 ;
constant : Str -> TermPrec = mkPrec highest ;
infixl : Prec -> Str -> (_,_ : TermPrec) -> TermPrec = \p,f,x,y ->
mkPrec p (usePrec p x ++ f ++ usePrec (nextPrec p) y) ;
infixr : Prec -> Str -> (_,_ : TermPrec) -> TermPrec = \p,f,x,y ->
mkPrec p (usePrec (nextPrec p) x ++ f ++ usePrec p y) ;
infixn : Prec -> Str -> (_,_ : TermPrec) -> TermPrec = \p,f,x,y ->
mkPrec p (usePrec (nextPrec p) x ++ f ++ usePrec (nextPrec p) y) ;
-- auxiliaries, should not be needed so much
usePrec : Prec -> TermPrec -> Str = \p,x ->
case lessPrec x.p p of {
True => parenth x.s ;
False => parenthOpt x.s
} ;
parenth : Str -> Str = \s -> "(" ++ s ++ ")" ;
parenthOpt : Str -> Str = \s -> variants {s ; "(" ++ s ++ ")"} ;
--.
-- low-level things: don't use
Prec : PType = Predef.Ints 4 ;
highest = 4 ;
lessPrec : Prec -> Prec -> Bool = \p,q ->
case <<p,q> : Prec * Prec> of {
<3,4> | <2,3> | <2,4> => True ;
<1,1> | <1,0> | <0,0> => False ;
<1,_> | <0,_> => True ;
_ => False
} ;
nextPrec : Prec -> Prec = \p -> case <p : Prec> of {
4 => 4 ;
n => Predef.plus n 1
} ;
}

View File

@@ -0,0 +1,8 @@
resource HTML = open Prelude in {
oper
tag : Str -> Str = \t -> "<" + t + ">" ;
endtag : Str -> Str = \t -> tag ("/" + t) ;
intag : Str -> Str -> Str = \t,s -> tag t ++ s ++ endtag t ;
intagAttr : Str -> Str -> Str -> Str =
\t,a,s -> ("<" + t) ++ (a + ">") ++ s ++ endtag t ;
}

View File

@@ -0,0 +1,12 @@
resource Latex = open Prelude in {
oper
command : Str -> Str = \c -> "\\" + c ;
fun1 : Str -> Str -> Str = \f,x -> "\\" + f + "{" ++ x ++ "}" ;
fun2 : Str -> Str -> Str -> Str =
\f,x,y -> "\\" + f + "{" ++ x ++ "}{" ++ y ++ "}" ;
begin : Str -> Str = \e -> "\\begin{" + e + "}" ;
end : Str -> Str = \e -> "\\end{" + e + "}" ;
inEnv : Str -> Str -> Str = \e,s -> begin e ++ s ++ end e ;
}

View File

@@ -0,0 +1,117 @@
-- operations for precedence-dependent strings.
-- five levels:
-- p4 (constants), p3 (applications), p2 (products), p1 (sums), p0 (arrows)
resource Precedence = open Prelude in {
param
Prec = p4 | p3 | p2 | p1 | p0 ;
oper
PrecTerm = Prec => Str ;
oper
pss : PrecTerm -> {s : PrecTerm} = \s -> {s = s} ;
-- change this if you want some other type of parentheses
mkParenth : Str -> Str = \str -> "(" ++ str ++ ")" ;
-- define ordering of precedences
nextPrec : Prec => Prec =
table {p0 => p1 ; p1 => p2 ; p2 => p3 ; _ => p4} ;
prevPrec : Prec => Prec =
table {p4 => p3 ; p3 => p2 ; p2 => p1 ; _ => p0} ;
mkPrec : Str -> Prec => Prec => Str = \str ->
table {
p4 => table { -- use the term of precedence p4...
_ => str} ; -- ...always without parentheses
p3 => table { -- use the term of precedence p3...
p4 => mkParenth str ; -- ...in parentheses if p4 is required...
_ => str} ; -- ...otherwise without parentheses
p2 => table {
p4 => mkParenth str ;
p3 => mkParenth str ;
_ => str} ;
p1 => table {
p1 => str ;
p0 => str ;
_ => mkParenth str} ;
p0 => table {
p0 => str ;
_ => mkParenth str}
} ;
-- make a string into a constant, of precedence p4
mkConst : Str -> PrecTerm =
\f ->
mkPrec f ! p4 ;
-- make a string into a 1/2/3 -place prefix operator, of precedence p3
mkFun1 : Str -> PrecTerm -> PrecTerm =
\f -> \x ->
table {k => mkPrec (f ++ x ! p4) ! p3 ! k} ;
mkFun2 : Str -> PrecTerm -> PrecTerm -> PrecTerm =
\f -> \x -> \y ->
table {k => mkPrec (f ++ x ! p4 ++ y ! p4) ! p3 ! k} ;
mkFun3 : Str -> PrecTerm -> PrecTerm -> PrecTerm -> PrecTerm =
\f -> \x -> \y -> \z ->
table {k => mkPrec (f ++ x ! p4 ++ y ! p4 ++ z ! p4) ! p3 ! k} ;
-- make a string into a non/left/right -associative infix operator, of precedence p
mkInfix : Str -> Prec -> PrecTerm -> PrecTerm -> PrecTerm =
\f -> \p -> \x -> \y ->
table {k => mkPrec (x ! (nextPrec ! p) ++ f ++ y ! (nextPrec ! p)) ! p ! k} ;
mkInfixL : Str -> Prec -> PrecTerm -> PrecTerm -> PrecTerm =
\f -> \p -> \x -> \y ->
table {k => mkPrec (x ! p ++ f ++ y ! (nextPrec ! p)) ! p ! k} ;
mkInfixR : Str -> Prec -> PrecTerm -> PrecTerm -> PrecTerm =
\f -> \p -> \x -> \y ->
table {k => mkPrec (x ! (nextPrec ! p) ++ f ++ y ! p) ! p ! k} ;
-----------------------------------------------------------
-- alternative:
-- precedence as inherent feature
oper TermWithPrec = {s : Str ; p : Prec} ;
oper
mkpPrec : Str -> Prec -> TermWithPrec =
\f -> \p ->
{s = f ; p = p} ;
usePrec : TermWithPrec -> Prec -> Str =
\x -> \p ->
mkPrec x.s ! x.p ! p ;
-- make a string into a constant, of precedence p4
mkpConst : Str -> TermWithPrec =
\f ->
mkpPrec f p4 ;
-- make a string into a 1/2/3 -place prefix operator, of precedence p3
mkpFun1 : Str -> TermWithPrec -> TermWithPrec =
\f -> \x ->
mkpPrec (f ++ usePrec x p4) p3 ;
mkpFun2 : Str -> TermWithPrec -> TermWithPrec -> TermWithPrec =
\f -> \x -> \y ->
mkpPrec (f ++ usePrec x p4 ++ usePrec y p4) p3 ;
mkpFun3 : Str -> TermWithPrec -> TermWithPrec -> TermWithPrec -> TermWithPrec =
\f -> \x -> \y -> \z ->
mkpPrec (f ++ usePrec x p4 ++ usePrec y p4 ++ usePrec z p4) p3 ;
-- make a string a into non/left/right -associative infix operator, of precedence p
mkpInfix : Str -> Prec -> TermWithPrec -> TermWithPrec -> TermWithPrec =
\f -> \p -> \x -> \y ->
mkpPrec (usePrec x (nextPrec ! p) ++ f ++ usePrec y (nextPrec ! p)) p ;
mkpInfixL : Str -> Prec -> TermWithPrec -> TermWithPrec -> TermWithPrec =
\f -> \p -> \x -> \y ->
mkpPrec (usePrec x p ++ f ++ usePrec y (nextPrec ! p)) p ;
mkpInfixR : Str -> Prec -> TermWithPrec -> TermWithPrec -> TermWithPrec =
\f -> \p -> \x -> \y ->
mkpPrec (usePrec x (nextPrec ! p) ++ f ++ usePrec y p) p ;
} ;

View File

@@ -0,0 +1,37 @@
--1 Predefined functions for concrete syntax
-- The definitions of these constants are hard-coded in GF, and defined
-- in [AppPredefined.hs ../src/GF/Grammar/AppPredefined.hs]. Applying
-- them to run-time variables leads to compiler errors that are often
-- only detected at the code generation time.
resource Predef = {
-- This type of booleans is for internal use only.
param PBool = PTrue | PFalse ;
oper Error : Type = variants {} ; -- the empty type
oper Int : Type = variants {} ; -- the type of integers
oper Ints : Int -> Type = variants {} ; -- the type of integers from 0 to n
oper error : Str -> Error = variants {} ; -- forms error message
oper length : Tok -> Int = variants {} ; -- length of string
oper drop : Int -> Tok -> Tok = variants {} ; -- drop prefix of length
oper take : Int -> Tok -> Tok = variants {} ; -- take prefix of length
oper tk : Int -> Tok -> Tok = variants {} ; -- drop suffix of length
oper dp : Int -> Tok -> Tok = variants {} ; -- take suffix of length
oper eqInt : Int -> Int -> PBool = variants {} ; -- test if equal integers
oper lessInt: Int -> Int -> PBool = variants {} ; -- test order of integers
oper plus : Int -> Int -> Int = variants {} ; -- add integers
oper eqStr : Tok -> Tok -> PBool = variants {} ; -- test if equal strings
oper occur : Tok -> Tok -> PBool = variants {} ; -- test if occurs as substring
oper occurs : Tok -> Tok -> PBool = variants {} ; -- test if any char occurs
oper show : (P : Type) -> P -> Tok = variants {} ; -- convert param to string
oper read : (P : Type) -> Tok -> P = variants {} ; -- convert string to param
oper toStr : (L : Type) -> L -> Str = variants {} ; -- find the "first" string
oper mapStr : (L : Type) -> (Str -> Str) -> L -> L = variants {} ;
-- map all strings in a data structure; experimental ---
} ;

View File

@@ -0,0 +1,4 @@
abstract PredefAbs = {
cat Int ; String ; Float ;
} ;

View File

@@ -0,0 +1,4 @@
concrete PredefCnc of PredefAbs = {
lincat
Int, Float, String = {s : Str} ;
} ;

View File

@@ -0,0 +1,142 @@
--1 The GF Prelude
-- This file defines some prelude facilities usable in all grammars.
resource Prelude = open (Predef=Predef) in {
oper
--2 Strings, records, and tables
SS : Type = {s : Str} ;
ss : Str -> SS = \s -> {s = s} ;
ss2 : (_,_ : Str) -> SS = \x,y -> ss (x ++ y) ;
ss3 : (_,_ ,_: Str) -> SS = \x,y,z -> ss (x ++ y ++ z) ;
cc2 : (_,_ : SS) -> SS = \x,y -> ss (x.s ++ y.s) ;
cc3 : (_,_,_ : SS) -> SS = \x,y,z -> ss (x.s ++ y.s ++ z.s) ;
SS1 : Type -> Type = \P -> {s : P => Str} ;
ss1 : (A : Type) -> Str -> SS1 A = \A,s -> {s = table {_ => s}} ;
SP1 : Type -> Type = \P -> {s : Str ; p : P} ;
sp1 : (A : Type) -> Str -> A -> SP1 A = \_,s,a -> {s = s ; p = a} ;
constTable : (A,B : Type) -> B -> A => B = \_,_,b -> \\_ => b ;
constStr : (A : Type) -> Str -> A => Str = \A -> constTable A Str ;
-- Discontinuous constituents.
SD2 : Type = {s1,s2 : Str} ;
sd2 : (_,_ : Str) -> SD2 = \x,y -> {s1 = x ; s2 = y} ;
--2 Optional elements
-- Missing form.
nonExist : Str = variants {} ;
-- Optional string with preference on the string vs. empty.
optStr : Str -> Str = \s -> variants {s ; []} ;
strOpt : Str -> Str = \s -> variants {[] ; s} ;
-- Free order between two strings.
bothWays : Str -> Str -> Str = \x,y -> variants {x ++ y ; y ++ x} ;
-- Parametric order between two strings.
preOrPost : Bool -> Str -> Str -> Str = \pr,x,y ->
if_then_Str pr (x ++ y) (y ++ x) ;
--2 Infixes. prefixes, and postfixes
-- Fixes with precedences are defined in [Precedence Precedence.html].
infixSS : Str -> SS -> SS -> SS = \f,x,y -> ss (x.s ++ f ++ y.s) ;
prefixSS : Str -> SS -> SS = \f,x -> ss (f ++ x.s) ;
postfixSS : Str -> SS -> SS = \f,x -> ss (x.s ++ f) ;
embedSS : Str -> Str -> SS -> SS = \f,g,x -> ss (f ++ x.s ++ g) ;
--2 Booleans
param Bool = True | False ;
oper
if_then_else : (A : Type) -> Bool -> A -> A -> A = \_,c,d,e ->
case c of {
True => d ; ---- should not need to qualify
False => e
} ;
andB : (_,_ : Bool) -> Bool = \a,b -> if_then_else Bool a b False ;
orB : (_,_ : Bool) -> Bool = \a,b -> if_then_else Bool a True b ;
notB : Bool -> Bool = \a -> if_then_else Bool a False True ;
if_then_Str : Bool -> Str -> Str -> Str = if_then_else Str ;
onlyIf : Bool -> Str -> Str = \b,s -> case b of {
True => s ;
_ => nonExist
} ;
-- Interface to internal booleans
pbool2bool : Predef.PBool -> Bool = \b -> case b of {
Predef.PFalse => False ; Predef.PTrue => True
} ;
init : Tok -> Tok = Predef.tk 1 ;
last : Tok -> Tok = Predef.dp 1 ;
--2 High-level acces to Predef operations
isNil : Tok -> Bool = \b -> pbool2bool (Predef.eqStr [] b) ;
ifTok : (A : Type) -> Tok -> Tok -> A -> A -> A = \A,t,u,a,b ->
case Predef.eqStr t u of {Predef.PTrue => a ; Predef.PFalse => b} ;
--2 Lexer-related operations
-- Bind together two tokens in some lexers, either obligatorily or optionally
oper
glue : Str -> Str -> Str = \x,y -> x ++ BIND ++ y ;
glueOpt : Str -> Str -> Str = \x,y -> variants {glue x y ; x ++ y} ;
noglueOpt : Str -> Str -> Str = \x,y -> variants {x ++ y ; glue x y} ;
-- Force capitalization of next word in some unlexers
capitalize : Str -> Str = \s -> CAPIT ++ s ;
-- These should be hidden, and never changed since they are hardcoded in (un)lexers
BIND : Str = "&+" ;
PARA : Str = "&-" ;
CAPIT : Str = "&|" ;
--2 Miscellaneous
-- Identity function
id : (A : Type) -> A -> A = \_,a -> a ;
-- Parentheses
paren : Str -> Str = \s -> "(" ++ s ++ ")" ;
parenss : SS -> SS = \s -> ss (paren s.s) ;
-- Zero, one, two, or more (elements in a list etc)
param
ENumber = E0 | E1 | E2 | Emore ;
oper
eNext : ENumber -> ENumber = \e -> case e of {
E0 => E1 ; E1 => E2 ; _ => Emore} ;
}

View File

@@ -0,0 +1,193 @@
module Main where
import Control.Monad
import Data.Maybe
import System.Cmd
import System.Directory
import System.Environment
import System.Exit
-- Make commands for compiling and testing resource grammars.
-- usage: runghc Make ((present? OPT?) | (clone FILE))? LANGS?
-- where
-- - OPT = (lang | api | math | pgf | test | demo | clean)
-- - LANGS has the form e.g. langs=Eng,Fin,Rus
-- - clone with a flag file=FILENAME clones the file to the specified languages,
-- by replacing the 3-letter language name of the original in both
-- the filename and the body
-- with each name in the list (default: all languages)
-- With no argument, lang and api are done, in this order.
-- See 'make' below for what is done by which command.
default_gf = "../../dist/build/gf/gf"
presApiPath = "-path=api:present"
-- the languages have long directory names and short ISO codes (3 letters)
-- we also give the decodings for postprocessing linearizations, as long as grammars
-- don't support all flags needed; they are used in tests
langsCoding = [
(("arabic", "Ara"),""),
(("bulgarian","Bul"),""),
(("catalan", "Cat"),""),
(("danish", "Dan"),""),
(("english", "Eng"),""),
(("finnish", "Fin"),""),
(("french", "Fre"),""),
(("hindi", "Hin"),"to_devanagari"),
(("german", "Ger"),""),
(("interlingua","Ina"),""),
(("italian", "Ita"),""),
(("norwegian","Nor"),""),
(("russian", "Rus"),""),
(("spanish", "Spa"),""),
(("swedish", "Swe"),""),
(("thai", "Tha"),"to_thai")
]
langs = map fst langsCoding
-- languagues for which to compile Lang
langsLang = langs `except` ["Ara"]
-- languages for which to compile Try
langsAPI = langsLang `except` ["Ara","Bul","Hin","Ina","Rus","Tha"]
-- languages for which to compile Mathematical
langsMath = langsAPI
-- languages for which to run treebank test
langsTest = langsLang `except` ["Ara","Bul","Cat","Hin","Rus","Spa","Tha"]
-- languages for which to run demo test
langsDemo = langsLang `except` ["Ara","Hin","Ina","Tha"]
-- languages for which langs.pgf is built
langsPGF = langsTest `only` ["Eng","Fre","Swe"]
-- languages for which Compatibility exists (to be extended)
langsCompat = langsLang `only` ["Cat","Eng","Fin","Fre","Ita","Spa","Swe"]
treebankExx = "exx-resource.gft"
treebankResults = "exx-resource.gftb"
main = do
xx <- getArgs
make xx
make :: [String] -> IO ()
make xx = do
let ifx opt act = if null xx || elem opt xx then act >> return () else return ()
let ifxx opt act = if elem opt xx then act >> return () else return ()
let pres = elem "present" xx
let dir = if pres then "../present" else "../alltenses"
let optl ls = maybe ls id $ getOptLangs xx
ifx "lang" $ do
mapM_ (gfc pres [] . lang) (optl langsLang)
copy "*/*.gfo" dir
ifx "compat" $ do
mapM_ (gfc pres [] . compat) (optl langsCompat)
copy "*/Compatibility*.gfo" dir
ifx "api" $ do
mapM_ (gfc pres presApiPath . try) (optl langsAPI)
copy "*/*.gfo" dir
ifx "math" $ do
mapM_ (gfc False [] . math) (optl langsMath)
copy "mathematical/*.gfo" "../mathematical"
mapM_ (gfc False [] . symbolic) (optl langsMath)
copy "mathematical/Symbolic*.gfo" "../mathematical"
ifxx "pgf" $ do
run_gfc $ ["-s","--make","--name=langs","--parser=off",
"--output-dir=" ++ dir]
++ [dir ++ "/Lang" ++ la ++ ".gfo" | (_,la) <- optl langsPGF]
ifxx "test" $ do
let ls = optl langsTest
gf (treeb "Lang" ls) $ unwords [dir ++ "/Lang" ++ la ++ ".gfo" | (_,la) <- ls]
ifxx "demo" $ do
let ls = optl langsDemo
gf (demos "Demo" ls) $ unwords ["demo/Demo" ++ la ++ ".gf" | (_,la) <- ls]
ifxx "clean" $ do
system "rm -f */*.gfo ../alltenses/*.gfo ../present/*.gfo"
ifxx "clone" $ do
let (pref,lang) = case getLangName xx of
Just pl -> pl
_ -> error "expected flag option file=ppppppLLL.gf"
s <- readFile (pref ++ lang ++ ".gf")
mapM_ (\la -> writeFile (pref ++ la ++ ".gf") (replaceLang lang la s)) (map snd (optl langs))
return ()
gfc pres ppath file = do
let preproc = if pres then "-preproc=./mkPresent" else ""
let path = if pres then ppath else ""
putStrLn $ "Compiling " ++ file
run_gfc ["-s","-src", preproc, path, file]
gf comm file = do
putStrLn $ "Reading " ++ file
let cmd = "echo \"" ++ comm ++ "\" | gf -s " ++ file
putStrLn cmd
system cmd
treeb abstr ls = "rf -lines -tree -file=" ++ treebankExx ++
" | l -treebank " ++ unlexer abstr ls ++ " | wf -file=" ++ treebankResults
demos abstr ls = "gr -number=100 | l -treebank " ++ unlexer abstr ls ++
" | ps -to_html | wf -file=resdemo.html"
lang (lla,la) = lla ++ "/All" ++ la ++ ".gf"
compat (lla,la) = lla ++ "/Compatibility" ++ la ++ ".gf"
try (lla,la) = "api/Try" ++ la ++ ".gf"
math (lla,la) = "mathematical/Mathematical" ++ la ++ ".gf"
symbolic (lla,la) = "mathematical/Symbolic" ++ la ++ ".gf"
except ls es = filter (flip notElem es . snd) ls
only ls es = filter (flip elem es . snd) ls
-- list of languages overriding the definitions above
getOptLangs args = case [ls | a <- args, let (f,ls) = splitAt 6 a, f=="langs="] of
ls:_ -> return $ findLangs $ seps ls
_ -> Nothing
where
seps = words . map (\c -> if c==',' then ' ' else c)
findLangs ls = [lang | lang@(_,la) <- langs, elem la ls]
-- the file name has the form p....pLLL.gf, i.e. 3-letter lang name, suffix .gf
getLangName args = case [ls | a <- args, let (f,ls) = splitAt 5 a, f=="file="] of
fi:_ -> let (nal,ferp) = splitAt 3 (drop 3 (reverse fi)) in return (reverse ferp,reverse nal)
_ -> Nothing
replaceLang s1 s2 = repl where
repl s = case s of
c:cs -> case splitAt lgs s of
(pre,rest) | pre == s1 -> s2 ++ repl rest
_ -> c : repl cs
_ -> s
lgs = 3 -- length s1
unlexer abstr ls =
"-unlexer=\\\"" ++ unwords
[abstr ++ la ++ "=" ++ unl |
lla@(_,la) <- ls, let unl = unlex lla, not (null unl)] ++
"\\\""
where
unlex lla = maybe "" id $ lookup lla langsCoding
-- | Runs the gf executable in compile mode with the given arguments.
run_gfc :: [String] -> IO ()
run_gfc args =
do let args' = ["-batch","-gf-lib-path=../"] ++ filter (not . null) args ++ ["+RTS"] ++ rts_flags ++ ["-RTS"]
putStrLn $ "Running: " ++ default_gf ++ " " ++ unwords (map showArg args')
e <- rawSystem default_gf args'
case e of
ExitSuccess -> return ()
ExitFailure i -> putStrLn $ "gf exited with exit code: " ++ show i
where rts_flags = ["-K100M"]
showArg arg = "'" ++ arg ++ "'"
copy :: String -> String -> IO ()
copy from to =
do system $ "cp " ++ from ++ " " ++ to
return ()

View File

@@ -0,0 +1,49 @@
RUNGHC=runghc
RUNMAKE=$(RUNGHC) Make.hs
.PHONY: all present alltenses lang api math test demo synopsis link compiled clean
all: link present alltenses math
present:
$(RUNMAKE) present lang
$(RUNMAKE) present api
alltenses:
$(RUNMAKE) lang
$(RUNMAKE) api
lang:
$(RUNMAKE) lang
api:
$(RUNMAKE) api
math:
$(RUNMAKE) math
compat:
gf -batch */Compatibility*.gf
cp -p */Compatibility*.gfo ../alltenses/
cp -p */Compatibility*.gfo ../present/
# $(RUNMAKE) present compat
# $(RUNMAKE) compat
test:
$(RUNMAKE) test
demo:
$(RUNMAKE) demo
synopsis:
cd doc ; $(RUNGHC) MkSynopsis ; cd ..
link:
chmod a+x mkPresent
compiled:
(cd .. && tar -zcf resource-compiled.tar.gz prelude alltenses present mathematical)
clean:
$(RUNMAKE) clean

View File

@@ -0,0 +1,30 @@
--1 Adjective: Adjectives and Adjectival Phrases
abstract Adjective = Cat ** {
fun
-- The principal ways of forming an adjectival phrase are
-- positive, comparative, relational, reflexive-relational, and
-- elliptic-relational.
-- (The superlative use is covered in [Noun Noun.html].$SuperlA$.)
PositA : A -> AP ; -- warm
ComparA : A -> NP -> AP ; -- warmer than I
ComplA2 : A2 -> NP -> AP ; -- married to her
ReflA2 : A2 -> AP ; -- married to itself
UseA2 : A2 -> A ; -- married
-- Sentence and question complements defined for all adjectival
-- phrases, although the semantics is only clear for some adjectives.
SentAP : AP -> SC -> AP ; -- good that she is here
-- An adjectival phrase can be modified by an *adadjective*, such as "very".
AdAP : AdA -> AP -> AP ; -- very warm
-- The formation of adverbs from adjective (e.g. "quickly") is covered
-- in [Adverb Adverb.html].
}

View File

@@ -0,0 +1,32 @@
--1 Adverb: Adverbs and Adverbial Phrases
abstract Adverb = Cat ** {
fun
-- The two main ways of forming adverbs are from adjectives and by
-- prepositions from noun phrases.
PositAdvAdj : A -> Adv ; -- warmly
PrepNP : Prep -> NP -> Adv ; -- in the house
-- Comparative adverbs have a noun phrase or a sentence as object of
-- comparison.
ComparAdvAdj : CAdv -> A -> NP -> Adv ; -- more warmly than John
ComparAdvAdjS : CAdv -> A -> S -> Adv ; -- more warmly than he runs
-- Adverbs can be modified by 'adadjectives', just like adjectives.
AdAdv : AdA -> Adv -> Adv ; -- very quickly
-- Subordinate clauses can function as adverbs.
SubjS : Subj -> S -> Adv ; -- when she sleeps
-- Comparison adverbs also work as numeral adverbs.
AdnCAdv : CAdv -> AdN ; -- less (than five)
}

View File

@@ -0,0 +1,63 @@
--1 Obsolete constructs included for backward-compatibility
abstract Backward = Cat ** {
-- from Cat
cat
Slash ;
fun
-- from Verb 19/4/2008
ComplV2 : V2 -> NP -> VP ; -- use it
ComplV3 : V3 -> NP -> NP -> VP ; -- send a message to her
ComplV2V : V2V -> NP -> VP -> VP ; -- cause it to burn
ComplV2S : V2S -> NP -> S -> VP ; -- tell me that it rains
ComplV2Q : V2Q -> NP -> QS -> VP ; -- ask me who came
ComplV2A : V2A -> NP -> AP -> VP ; -- paint it red
ReflV2 : V2 -> VP ; -- use itself
UseVQ : VQ -> V2 ; -- ask (a question)
UseVS : VS -> V2 ; -- know (a secret)
-- from Sentence 19/4/2008
SlashV2 : NP -> V2 -> Slash ; -- (whom) he sees
SlashVVV2 : NP -> VV -> V2 -> Slash; -- (whom) he wants to see
-- from Noun 19/4/2008
NumInt : Int -> Num ; -- 51
OrdInt : Int -> Ord ; -- 51st (DEPRECATED)
NoOrd : Ord ;
-- 20/4
DetSg : Quant -> Ord -> Det ; -- the best man
DetPl : Quant -> Num -> Ord -> Det ; -- the five best men
NoNum : Num ;
-- 22/4
DefArt : Quant ; -- the (house), the (houses)
IndefArt : Quant ; -- a (house), (houses)
MassDet : Quant ; -- (beer)
-- from Structural 19/4/2008
that_NP : NP ;
these_NP : NP ;
this_NP : NP ;
those_NP : NP ;
whichPl_IDet : IDet ;
whichSg_IDet : IDet ;
-- from Adverb
AdvSC : SC -> Adv ; -- that he arrives ---- REMOVE?
}

View File

@@ -0,0 +1,134 @@
--1 Cat: the Category System
-- The category system is central to the library in the sense
-- that the other modules ($Adjective$, $Adverb$, $Noun$, $Verb$ etc)
-- communicate through it. This means that a e.g. a function using
-- $NP$s in $Verb$ need not know how $NP$s are constructed in $Noun$:
-- it is enough that both $Verb$ and $Noun$ use the same type $NP$,
-- which is given here in $Cat$.
--
-- Some categories are inherited from [``Common`` Common.html].
-- The reason they are defined there is that they have the same
-- implementation in all languages in the resource (typically,
-- just a string). These categories are
-- $AdA, AdN, AdV, Adv, Ant, CAdv, IAdv, PConj, Phr$,
-- $Pol, SC, Tense, Text, Utt, Voc$.
--
-- Moreover, the list categories $ListAdv, ListAP, ListNP, ListS$
-- are defined on $Conjunction$ and only used locally there.
abstract Cat = Common ** {
cat
--2 Sentences and clauses
-- Constructed in [Sentence Sentence.html], and also in
-- [Idiom Idiom.html].
S ; -- declarative sentence e.g. "she lived here"
QS ; -- question e.g. "where did she live"
RS ; -- relative e.g. "in which she lived"
Cl ; -- declarative clause, with all tenses e.g. "she looks at this"
ClSlash;-- clause missing NP (S/NP in GPSG) e.g. "she looks at"
SSlash ;-- sentence missing NP e.g. "she has looked at"
Imp ; -- imperative e.g. "look at this"
--2 Questions and interrogatives
-- Constructed in [Question Question.html].
QCl ; -- question clause, with all tenses e.g. "why does she walk"
IP ; -- interrogative pronoun e.g. "who"
IComp ; -- interrogative complement of copula e.g. "where"
IDet ; -- interrogative determiner e.g. "how many"
IQuant; -- interrogative quantifier e.g. "which"
--2 Relative clauses and pronouns
-- Constructed in [Relative Relative.html].
RCl ; -- relative clause, with all tenses e.g. "in which she lives"
RP ; -- relative pronoun e.g. "in which"
--2 Verb phrases
-- Constructed in [Verb Verb.html].
VP ; -- verb phrase e.g. "is very warm"
Comp ; -- complement of copula, such as AP e.g. "very warm"
VPSlash ; -- verb phrase missing complement e.g. "give to John"
--2 Adjectival phrases
-- Constructed in [Adjective Adjective.html].
AP ; -- adjectival phrase e.g. "very warm"
--2 Nouns and noun phrases
-- Constructed in [Noun Noun.html].
-- Many atomic noun phrases e.g. "everybody"
-- are constructed in [Structural Structural.html].
-- The determiner structure is
-- ``` Predet (QuantSg | QuantPl Num) Ord
-- as defined in [Noun Noun.html].
CN ; -- common noun (without determiner) e.g. "red house"
NP ; -- noun phrase (subject or object) e.g. "the red house"
Pron ; -- personal pronoun e.g. "she"
Det ; -- determiner phrase e.g. "those seven"
Predet ; -- predeterminer (prefixed Quant) e.g. "all"
Quant ; -- quantifier ('nucleus' of Det) e.g. "this/these"
Art ; -- article e.g. "the"
Num ; -- number determining element e.g. "seven"
Card ; -- cardinal number e.g. "seven"
Ord ; -- ordinal number (used in Det) e.g. "seventh"
--2 Numerals
-- Constructed in [Numeral Numeral.html].
Numeral ; -- cardinal or ordinal in words e.g. "five/fifth"
Digits ; -- cardinal or ordinal in digits e.g. "1,000/1,000th"
--2 Structural words
-- Constructed in [Structural Structural.html].
Conj ; -- conjunction e.g. "and"
---b DConj ; -- distributed conjunction e.g. "both - and"
Subj ; -- subjunction e.g. "if"
Prep ; -- preposition, or just case e.g. "in"
--2 Words of open classes
-- These are constructed in [Lexicon Lexicon.html] and in
-- additional lexicon modules.
V ; -- one-place verb e.g. "sleep"
V2 ; -- two-place verb e.g. "love"
V3 ; -- three-place verb e.g. "show"
VV ; -- verb-phrase-complement verb e.g. "want"
VS ; -- sentence-complement verb e.g. "claim"
VQ ; -- question-complement verb e.g. "wonder"
VA ; -- adjective-complement verb e.g. "look"
V2V ; -- verb with NP and V complement e.g. "cause"
V2S ; -- verb with NP and S complement e.g. "tell"
V2Q ; -- verb with NP and Q complement e.g. "ask"
V2A ; -- verb with NP and AP complement e.g. "paint"
A ; -- one-place adjective e.g. "warm"
A2 ; -- two-place adjective e.g. "divisible"
N ; -- common noun e.g. "house"
N2 ; -- relational noun e.g. "son"
N3 ; -- three-place relational noun e.g. "connection"
PN ; -- proper name e.g. "Paris"
-- DEPRECATED: QuantSg, QuantPl
--- QuantSg ;-- quantifier ('nucleus' of sing. Det) e.g. "every"
--- QuantPl ;-- quantifier ('nucleus' of plur. Det) e.g. "many"
}

View File

@@ -0,0 +1,61 @@
--1 Common: Structures with Common Implementations.
-- This module defines the categories that uniformly have the linearization
-- ${s : Str}$ in all languages.
-- Moreover, this module defines the abstract parameters of tense, polarity, and
-- anteriority, which are used in [``Phrase`` Phrase.html] to generate different
-- forms of sentences. Together they give 4 x 2 x 2 = 16 sentence forms.
-- These tenses are defined for all languages in the library. More tenses
-- can be defined in the language extensions, e.g. the "passé simple" of
-- Romance languages in [``ExtraRomance`` ../romance/ExtraRomance.gf].
abstract Common = {
cat
--2 Top-level units
-- Constructed in [``Text`` Text.html]: $Text$.
Text ; -- text consisting of several phrases e.g. "He is here. Why?"
-- Constructed in [``Phrase`` Phrase.html]:
Phr ; -- phrase in a text e.g. "but be quiet please"
Utt ; -- sentence, question, word... e.g. "be quiet"
Voc ; -- vocative or "please" e.g. "my darling"
PConj ; -- phrase-beginning conjunction e.g. "therefore"
-- Constructed in [``Sentence`` Sentence.html]:
SC ; -- embedded sentence or question e.g. "that it rains"
--2 Adverbs
-- Constructed in [``Adverb`` Adverb.html].
-- Many adverbs are constructed in [``Structural`` Structural.html].
Adv ; -- verb-phrase-modifying adverb e.g. "in the house"
AdV ; -- adverb directly attached to verb e.g. "always"
AdA ; -- adjective-modifying adverb e.g. "very"
AdN ; -- numeral-modifying adverb e.g. "more than"
IAdv ; -- interrogative adverb e.g. "why"
CAdv ; -- comparative adverb e.g. "more"
--2 Tense, polarity, and anteriority
Tense ; -- tense e.g. present, past, future
Pol ; -- polarity e.g. positive, negative
Ant ; -- anteriority e.g. simultaneous, anterior
fun
PPos, PNeg : Pol ; -- I sleep/don't sleep
TPres : Tense ;
ASimul : Ant ;
TPast, TFut, TCond : Tense ; -- I slept/will sleep/would sleep --# notpresent
AAnter : Ant ; -- I have slept --# notpresent
}

View File

@@ -0,0 +1,9 @@
abstract Compatibility = Cat ** {
-- from Noun 19/4/2008
fun
NumInt : Int -> Num ; -- 57
OrdInt : Int -> Ord ; -- 57
}

View File

@@ -0,0 +1,52 @@
--1 Conjunction: Coordination
-- Coordination is defined for many different categories; here is
-- a sample. The rules apply to *lists* of two or more elements,
-- and define two general patterns:
-- - ordinary conjunction: X,...X and X
-- - distributed conjunction: both X,...,X and X
--
--
-- $VP$ conjunctions are not covered here, because their applicability
-- depends on language. Some special cases are defined in
-- [``Extra`` ../abstract/Extra.gf].
abstract Conjunction = Cat ** {
--2 Rules
fun
ConjS : Conj -> [S] -> S ; -- "he walks and she runs"
ConjAP : Conj -> [AP] -> AP ; -- "cold and warm"
ConjNP : Conj -> [NP] -> NP ; -- "she or we"
ConjAdv : Conj -> [Adv] -> Adv ; -- "here or there"
---b DConjS : DConj -> [S] -> S ; -- "either he walks or she runs"
---b DConjAP : DConj -> [AP] -> AP ; -- "both warm and cold"
---b DConjNP : DConj -> [NP] -> NP ; -- "either he or she"
---b DConjAdv : DConj -> [Adv] -> Adv; -- "both here and there"
--2 Categories
-- These categories are only used in this module.
cat
[S]{2} ;
[Adv]{2} ;
[NP]{2} ;
[AP]{2} ;
--2 List constructors
-- The list constructors are derived from the list notation and therefore
-- not given explicitly. But here are their type signatures:
-- BaseC : C -> C -> [C] ; -- for C = S, AP, NP, Adv
-- ConsC : C -> [C] -> [C] ;
}
--.
-- *Note*. This module uses right-recursive lists. If backward
-- compatibility with API 0.9 is needed, use
-- [SeqConjunction SeqConjunction.html].

View File

@@ -0,0 +1,30 @@
--1 More syntax rules
-- This module defines syntax rules that are not implemented in all
-- languages, but in more than one, so that it makes sense to offer a
-- common API.
abstract Extra = Cat ** {
fun
GenNP : NP -> Quant ; -- this man's
ComplBareVS : VS -> S -> VP ; -- know you go
StrandRelSlash : RP -> ClSlash -> RCl ; -- that he lives in
EmptyRelSlash : RP -> ClSlash -> RCl ; -- he lives in
StrandQuestSlash : IP -> ClSlash -> QCl ; -- whom does John live with
-- $VP$ conjunction, which has different fragments implemented in
-- different languages - never a full $VP$, though.
cat
VPI ;
[VPI] {2} ;
fun
MkVPI : VP -> VPI ;
ConjVPI : Conj -> [VPI] -> VPI ;
ComplVPIVV : VV -> VPI -> VP ;
}

View File

@@ -0,0 +1,22 @@
--1 Grammar: the Main Module of the Resource Grammar
-- This grammar is a collection of the different grammar modules,
-- To test the resource, import [``Lang`` Lang.html], which also contains
-- a lexicon.
abstract Grammar =
Noun,
Verb,
Adjective,
Adverb,
Numeral,
Sentence,
Question,
Relative,
Conjunction,
Phrase,
Text,
Structural,
Idiom ;

View File

@@ -0,0 +1,22 @@
--1 Idiom: Idiomatic Expressions
abstract Idiom = Cat ** {
-- This module defines constructions that are formed in fixed ways,
-- often different even in closely related languages.
fun
ImpersCl : VP -> Cl ; -- it is hot
GenericCl : VP -> Cl ; -- one sleeps
CleftNP : NP -> RS -> Cl ; -- it is I who did it
CleftAdv : Adv -> S -> Cl ; -- it is here she slept
ExistNP : NP -> Cl ; -- there is a house
ExistIP : IP -> QCl ; -- which houses are there
ProgrVP : VP -> VP ; -- be sleeping
ImpPl1 : VP -> Utt ; -- let's go
}

View File

@@ -0,0 +1,13 @@
--1 Lang: a Test Module for the Resource Grammar
-- This grammar is for testing the resource as included in the
-- language-independent API, consisting of a grammar and a lexicon.
-- The grammar without a lexicon is [``Grammar`` Grammar.html],
-- which may be more suitable to open in applications.
abstract Lang =
Grammar,
Lexicon
** {
flags startcat=Phr ;
} ;

View File

@@ -0,0 +1,356 @@
abstract Lexicon = Cat ** {
fun
add_V3 : V3 ;
airplane_N : N ;
already_Adv : Adv ;
animal_N : N ;
answer_V2S : V2S ;
apartment_N : N ;
apple_N : N ;
art_N : N ;
ashes_N : N ;
ask_V2Q : V2Q ;
baby_N : N ;
back_N : N ;
bad_A : A ;
bank_N : N ;
bark_N : N ;
beautiful_A : A ;
become_VA : VA ;
beer_N : N ;
beg_V2V : V2V ;
belly_N : N ;
big_A : A ;
bike_N : N ;
bird_N : N ;
bite_V2 : V2 ;
black_A : A ;
blood_N : N ;
blow_V : V ;
blue_A : A ;
boat_N : N ;
bone_N : N ;
book_N : N ;
boot_N : N ;
boss_N : N ;
boy_N : N ;
bread_N : N ;
break_V2 : V2 ;
breast_N : N ;
breathe_V : V ;
broad_A : A ;
brother_N2 : N2 ;
brown_A : A ;
burn_V : V ;
butter_N : N ;
buy_V2 : V2 ;
camera_N : N ;
cap_N : N ;
car_N : N ;
carpet_N : N ;
cat_N : N ;
ceiling_N : N ;
chair_N : N ;
cheese_N : N ;
child_N : N ;
church_N : N ;
city_N : N ;
clean_A : A ;
clever_A : A ;
close_V2 : V2 ;
cloud_N : N ;
coat_N : N ;
cold_A : A ;
come_V : V ;
computer_N : N ;
correct_A : A ;
country_N : N ;
count_V2 : V2 ;
cousin_N : N ;
cow_N : N ;
cut_V2 : V2 ;
day_N : N ;
die_V : V ;
dig_V : V ;
dirty_A : A ;
distance_N3 : N3 ;
doctor_N : N ;
dog_N : N ;
door_N : N ;
do_V2 : V2 ;
drink_V2 : V2 ;
drink_V2 : V2 ;
dry_A : A ;
dull_A : A ;
dust_N : N ;
ear_N : N ;
earth_N : N ;
easy_A2V : A2 ;
eat_V2 : V2 ;
eat_V2 : V2 ;
egg_N : N ;
empty_A : A ;
enemy_N : N ;
eye_N : N ;
factory_N : N ;
fall_V : V ;
far_Adv : Adv ;
father_N2 : N2 ;
fat_N : N ;
fear_VS : VS ;
fear_V2 : V2 ;
feather_N : N ;
fight_V2 : V2 ;
find_V2 : V2 ;
fingernail_N : N ;
fire_N : N ;
fish_N : N ;
float_V : V ;
floor_N : N ;
flower_N : N ;
flow_V : V ;
fly_V : V ;
fog_N : N ;
foot_N : N ;
forest_N : N ;
forget_V2 : V2 ;
freeze_V : V ;
fridge_N : N ;
friend_N : N ;
fruit_N : N ;
full_A : A ;
fun
fun_AV : A ;
garden_N : N ;
girl_N : N ;
give_V3 : V3 ;
glove_N : N ;
gold_N : N ;
good_A : A ;
go_V : V ;
grammar_N : N ;
grass_N : N ;
green_A : A ;
guts_N : N ;
hair_N : N ;
hand_N : N ;
harbour_N : N ;
hate_V2 : V2 ;
hat_N : N ;
have_V2 : V2 ;
head_N : N ;
heart_N : N ;
hear_V2 : V2 ;
hear_V2 : V2 ;
heavy_A : A ;
hill_N : N ;
hit_V2 : V2 ;
hold_V2 : V2 ;
hope_VS : VS ;
horn_N : N ;
horse_N : N ;
hot_A : A ;
house_N : N ;
hunt_V2 : V2 ;
husband_N : N ;
ice_N : N ;
important_A : A ;
industry_N : N ;
iron_N : N ;
john_PN : PN ;
jump_V : V ;
kill_V2 : V2 ;
king_N : N ;
knee_N : N ;
know_V2 : V2 ;
know_V2 : V2 ;
lake_N : N ;
lamp_N : N ;
language_N : N ;
laugh_V : V ;
leaf_N : N ;
learn_V2 : V2 ;
leather_N : N ;
leave_V2 : V2 ;
left_Ord : Ord ;
leg_N : N ;
lie_V : V ;
like_V2 : V2 ;
listen_V2 : V2 ;
liver_N : N ;
live_V : V ;
long_A : A ;
lose_V2 : V2 ;
louse_N : N ;
love_N : N ;
love_V2 : V2 ;
man_N : N ;
married_A2 : A2 ;
meat_N : N ;
milk_N : N ;
moon_N : N ;
mother_N2 : N2 ;
mountain_N : N ;
mouth_N : N ;
music_N : N ;
name_N : N ;
narrow_A : A ;
near_A : A ;
neck_N : N ;
new_A : A ;
newspaper_N : N ;
night_N : N ;
nose_N : N ;
now_Adv : Adv ;
number_N : N ;
oil_N : N ;
old_A : A ;
open_V2 : V2 ;
paint_V2A : V2A ;
paper_N : N ;
paris_PN : PN ;
peace_N : N ;
pen_N : N ;
person_N : N ;
planet_N : N ;
plastic_N : N ;
play_V2 : V2 ;
play_V : V ;
policeman_N : N ;
priest_N : N ;
probable_AS : A ;
pull_V2 : V2 ;
push_V2 : V2 ;
put_V2 : V2 ;
queen_N : N ;
question_N : N ;
radio_N : N ;
rain_N : N ;
rain_V0 : V ;
read_V2 : V2 ;
ready_A : A ;
reason_N : N ;
red_A : A ;
religion_N : N ;
restaurant_N : N ;
right_Ord : Ord ;
river_N : N ;
road_N : N ;
rock_N : N ;
roof_N : N ;
root_N : N ;
rope_N : N ;
rotten_A : A ;
round_A : A ;
rubber_N : N ;
rub_V2 : V2 ;
rule_N : N ;
run_V : V ;
salt_N : N ;
sand_N : N ;
say_VS : VS ;
school_N : N ;
science_N : N ;
scratch_V2 : V2 ;
sea_N : N ;
seed_N : N ;
seek_V2 : V2 ;
see_V2 : V2 ;
see_V2 : V2 ;
sell_V3 : V3 ;
send_V3 : V3 ;
sew_V : V ;
sharp_A : A ;
sheep_N : N ;
ship_N : N ;
shirt_N : N ;
shoe_N : N ;
shop_N : N ;
short_A : A ;
silver_N : N ;
sing_V : V ;
sister_N : N ;
sit_V : V ;
skin_N : N ;
sky_N : N ;
sleep_V : V ;
small_A : A ;
smell_V : V ;
smoke_N : N ;
smooth_A : A ;
snake_N : N ;
snow_N : N ;
sock_N : N ;
song_N : N ;
speak_V2 : V2 ;
spit_V : V ;
split_V2 : V2 ;
squeeze_V2 : V2 ;
stab_V2 : V2 ;
stand_V : V ;
star_N : N ;
steel_N : N ;
stick_N : N ;
stone_N : N ;
stop_V : V ;
stove_N : N ;
straight_A : A ;
student_N : N ;
stupid_A : A ;
suck_V2 : V2 ;
sun_N : N ;
swell_V : V ;
swim_V : V ;
switch8off_V2 : V2 ;
switch8on_V2 : V2 ;
table_N : N ;
tail_N : N ;
talk_V3 : V3 ;
teacher_N : N ;
teach_V2 : V2 ;
television_N : N ;
thick_A : A ;
thin_A : A ;
think_V : V ;
throw_V2 : V2 ;
tie_V2 : V2 ;
today_Adv : Adv ;
tongue_N : N ;
tooth_N : N ;
train_N : N ;
travel_V : V ;
tree_N : N ;
turn_V : V ;
ugly_A : A ;
uncertain_A : A ;
understand_V2 : V2 ;
university_N : N ;
village_N : N ;
vomit_V : V ;
wait_V2 : V2 ;
walk_V : V ;
warm_A : A ;
war_N : N ;
wash_V2 : V2 ;
watch_V2 : V2 ;
water_N : N ;
wet_A : A ;
white_A : A ;
wide_A : A ;
wife_N : N ;
wind_N : N ;
window_N : N ;
wine_N : N ;
wing_N : N ;
win_V2 : V2 ;
wipe_V2 : V2 ;
woman_N : N ;
wonder_VQ : VQ ;
wood_N : N ;
worm_N : N ;
write_V2 : V2 ;
year_N : N ;
yellow_A : A ;
young_A : A ;
}

View File

@@ -0,0 +1,144 @@
--1 Noun: Nouns, noun phrases, and determiners
abstract Noun = Cat ** {
--2 Noun phrases
-- The three main types of noun phrases are
-- - common nouns with determiners
-- - proper names
-- - pronouns
--
--
fun
DetCN : Det -> CN -> NP ; -- the man
UsePN : PN -> NP ; -- John
UsePron : Pron -> NP ; -- he
-- Pronouns are defined in the module [``Structural`` Structural.html].
-- A noun phrase already formed can be modified by a $Predet$erminer.
PredetNP : Predet -> NP -> NP; -- only the man
-- A noun phrase can also be postmodified by the past participle of a
-- verb, by an adverb, or by a relative clause
PPartNP : NP -> V2 -> NP ; -- the man seen
AdvNP : NP -> Adv -> NP ; -- Paris today
RelNP : NP -> RS -> NP ; -- Paris, which is here
-- Determiners can form noun phrases directly.
DetNP : Det -> NP ; -- these five
--2 Determiners
-- The determiner has a fine-grained structure, in which a 'nucleus'
-- quantifier and two optional parts can be discerned: a cardinal and
-- an ordinal numeral.
DetQuantOrd : Quant -> Num -> Ord -> Det ; -- these five best
DetQuant : Quant -> Num -> Det ; -- these five
-- Whether the resulting determiner is singular or plural depends on the
-- cardinal.
-- All parts of the determiner can be empty, except $Quant$, which is
-- the "kernel" of a determiner. It is, however, the $Num$ that determines
-- the inherent number.
NumSg : Num ;
NumPl : Num ;
NumCard : Card -> Num ;
-- $Card$ consists of either digits or numeral words.
NumDigits : Digits -> Card ; -- 51
NumNumeral : Numeral -> Card ; -- fifty-one
-- The construction of numerals is defined in [Numeral Numeral.html].
-- A $Card$ can be modified by certain adverbs.
AdNum : AdN -> Card -> Card ; -- almost 51
-- An $Ord$ consists of either digits or numeral words.
-- Also superlative forms of adjectives behave syntactically like ordinals.
OrdDigits : Digits -> Ord ; -- 51st
OrdNumeral : Numeral -> Ord ; -- fifty-first
OrdSuperl : A -> Ord ; -- warmest
-- Definite and indefinite noun phrases are sometimes realized as
-- neatly distinct words (Spanish "un, unos ; el, los") but also without
-- any particular word (Finnish; Swedish definites).
DetArtOrd : Art -> Num -> Ord -> Det ; -- the (five) best
DetArtCard : Art -> Card -> Det ; -- the five
IndefArt : Art ;
DefArt : Art ;
-- Articles cannot alone form noun phrases, but need a noun.
DetArtSg : Art -> CN -> NP ; -- the man
DetArtPl : Art -> CN -> NP ; -- the men
-- Nouns can be used without an article as mass nouns. The resource does
-- not distinguish mass nouns from other common nouns, which can result
-- in semantically odd expressions.
MassNP : CN -> NP ; -- (beer)
-- Pronouns have possessive forms. Genitives of other kinds
-- of noun phrases are not given here, since they are not possible
-- in e.g. Romance languages. They can be found in $Extra$ modules.
PossPron : Pron -> Quant ; -- my (house)
-- Other determiners are defined in [Structural Structural.html].
--2 Common nouns
-- Simple nouns can be used as nouns outright.
UseN : N -> CN ; -- house
-- Relational nouns take one or two arguments.
ComplN2 : N2 -> NP -> CN ; -- mother of the king
ComplN3 : N3 -> NP -> N2 ; -- distance from this city (to Paris)
-- Relational nouns can also be used without their arguments.
-- The semantics is typically derivative of the relational meaning.
UseN2 : N2 -> CN ; -- mother
Use2N3 : N3 -> N2 ; -- distance (from this city)
Use3N3 : N3 -> N2 ; -- distance (to Paris)
-- Nouns can be modified by adjectives, relative clauses, and adverbs
-- (the last rule will give rise to many 'PP attachment' ambiguities
-- when used in connection with verb phrases).
AdjCN : AP -> CN -> CN ; -- big house
RelCN : CN -> RS -> CN ; -- house that John bought
AdvCN : CN -> Adv -> CN ; -- house on the hill
-- Nouns can also be modified by embedded sentences and questions.
-- For some nouns this makes little sense, but we leave this for applications
-- to decide. Sentential complements are defined in [Verb Verb.html].
SentCN : CN -> SC -> CN ; -- question where she sleeps
--2 Apposition
-- This is certainly overgenerating.
ApposCN : CN -> NP -> CN ; -- city Paris (, numbers x and y)
} ;

View File

@@ -0,0 +1,60 @@
--1 Numerals
-- This grammar defines numerals from 1 to 999999.
-- The implementations are adapted from the
-- [numerals library http://www.cs.chalmers.se/~aarne/GF/examples/numerals/]
-- which defines numerals for 88 languages.
-- The resource grammar implementations add to this inflection (if needed)
-- and ordinal numbers.
--
-- *Note* 1. Number 1 as defined
-- in the category $Numeral$ here should not be used in the formation of
-- noun phrases, and should therefore be removed. Instead, one should use
-- [Structural Structural.html]$.one_Quant$. This makes the grammar simpler
-- because we can assume that numbers form plural noun phrases.
--
-- *Note* 2. The implementations introduce spaces between
-- parts of a numeral, which is often incorrect - more work on
-- (un)lexing is needed to solve this problem.
abstract Numeral = Cat ** {
cat
Digit ; -- 2..9
Sub10 ; -- 1..9
Sub100 ; -- 1..99
Sub1000 ; -- 1..999
Sub1000000 ; -- 1..999999
fun
num : Sub1000000 -> Numeral ;
n2, n3, n4, n5, n6, n7, n8, n9 : Digit ;
pot01 : Sub10 ; -- 1
pot0 : Digit -> Sub10 ; -- d * 1
pot110 : Sub100 ; -- 10
pot111 : Sub100 ; -- 11
pot1to19 : Digit -> Sub100 ; -- 10 + d
pot0as1 : Sub10 -> Sub100 ; -- coercion of 1..9
pot1 : Digit -> Sub100 ; -- d * 10
pot1plus : Digit -> Sub10 -> Sub100 ; -- d * 10 + n
pot1as2 : Sub100 -> Sub1000 ; -- coercion of 1..99
pot2 : Sub10 -> Sub1000 ; -- m * 100
pot2plus : Sub10 -> Sub100 -> Sub1000 ; -- m * 100 + n
pot2as3 : Sub1000 -> Sub1000000 ; -- coercion of 1..999
pot3 : Sub1000 -> Sub1000000 ; -- m * 1000
pot3plus : Sub1000 -> Sub1000 -> Sub1000000 ; -- m * 1000 + n
-- Numerals as sequences of digits have a separate, simpler grammar
cat
Dig ; -- single digit 0..9
fun
IDig : Dig -> Digits ; -- 8
IIDig : Dig -> Digits -> Digits ; -- 876
D_0, D_1, D_2, D_3, D_4, D_5, D_6, D_7, D_8, D_9 : Dig ;
}

View File

@@ -0,0 +1,44 @@
--1 Phrase: Phrases and Utterances
abstract Phrase = Cat ** {
-- When a phrase is built from an utterance it can be prefixed
-- with a phrasal conjunction (such as "but", "therefore")
-- and suffixing with a vocative (typically a noun phrase).
fun
PhrUtt : PConj -> Utt -> Voc -> Phr ; -- but come here, my friend
-- Utterances are formed from sentences, questions, and imperatives.
UttS : S -> Utt ; -- John walks
UttQS : QS -> Utt ; -- is it good
UttImpSg : Pol -> Imp -> Utt; -- (don't) love yourself
UttImpPl : Pol -> Imp -> Utt; -- (don't) love yourselves
UttImpPol : Pol -> Imp -> Utt ; -- (don't) sleep (polite)
-- There are also 'one-word utterances'. A typical use of them is
-- as answers to questions.
-- *Note*. This list is incomplete. More categories could be covered.
-- Moreover, in many languages e.g. noun phrases in different cases
-- can be used.
UttIP : IP -> Utt ; -- who
UttIAdv : IAdv -> Utt ; -- why
UttNP : NP -> Utt ; -- this man
UttAdv : Adv -> Utt ; -- here
UttVP : VP -> Utt ; -- to sleep
-- The phrasal conjunction is optional. A sentence conjunction
-- can also used to prefix an utterance.
NoPConj : PConj ;
PConjConj : Conj -> PConj ; -- and
-- The vocative is optional. Any noun phrase can be made into vocative,
-- which may be overgenerating (e.g. "I").
NoVoc : Voc ;
VocNP : NP -> Voc ; -- my friend
}

View File

@@ -0,0 +1,41 @@
--1 Question: Questions and Interrogative Pronouns
abstract Question = Cat ** {
-- A question can be formed from a clause ('yes-no question') or
-- with an interrogative.
fun
QuestCl : Cl -> QCl ; -- does John walk
QuestVP : IP -> VP -> QCl ; -- who walks
QuestSlash : IP -> ClSlash -> QCl ; -- whom does John love
QuestIAdv : IAdv -> Cl -> QCl ; -- why does John walk
QuestIComp : IComp -> NP -> QCl ; -- where is John
-- Interrogative pronouns can be formed with interrogative
-- determiners, with or without a noun.
IdetCN : IDet -> CN -> IP ; -- which five songs
IdetIP : IDet -> IP ; -- which five
-- They can be modified with adverbs.
AdvIP : IP -> Adv -> IP ; -- who in Paris
-- Interrogative quantifiers have number forms and can take number modifiers.
IdetQuant : IQuant -> Num -> IDet ; -- which (five)
-- Interrogative adverbs can be formed prepositionally.
PrepIP : Prep -> IP -> IAdv ; -- with whom
-- Interrogative complements to copulas can be both adverbs and
-- pronouns.
CompIAdv : IAdv -> IComp ; -- where (is it)
CompIP : IP -> IComp ; -- who (is it)
-- More $IP$, $IDet$, and $IAdv$ are defined in $Structural$.
}

View File

@@ -0,0 +1,26 @@
--1 Relative clauses and pronouns
abstract Relative = Cat ** {
fun
-- The simplest way to form a relative clause is from a clause by
-- a pronoun similar to "such that".
RelCl : Cl -> RCl ; -- such that John loves her
-- The more proper ways are from a verb phrase
-- (formed in [``Verb`` Verb.html]) or a sentence
-- with a missing noun phrase (formed in [``Sentence`` Sentence.html]).
RelVP : RP -> VP -> RCl ; -- who loves John
RelSlash : RP -> ClSlash -> RCl ; -- whom John loves
-- Relative pronouns are formed from an 'identity element' by prefixing
-- or suffixing (depending on language) prepositional phrases.
IdRP : RP ; -- which
FunRP : Prep -> NP -> RP -> RP ; -- the mother of whom
}

View File

@@ -0,0 +1,95 @@
--1 Sentence: Sentences, Clauses, and Imperatives
abstract Sentence = Cat ** {
--2 Clauses
-- The $NP VP$ predication rule form a clause whose linearization
-- gives a table of all tense variants, positive and negative.
-- Clauses are converted to $S$ (with fixed tense) with the
-- $UseCl$ function below.
fun
PredVP : NP -> VP -> Cl ; -- John walks
-- Using an embedded sentence as a subject is treated separately.
-- This can be overgenerating. E.g. "whether you go" as subject
-- is only meaningful for some verb phrases.
PredSCVP : SC -> VP -> Cl ; -- that she goes is good
--2 Clauses missing object noun phrases
-- This category is a variant of the 'slash category' $S/NP$ of
-- GPSG and categorial grammars, which in turn replaces
-- movement transformations in the formation of questions
-- and relative clauses. Except $SlashV2$, the construction
-- rules can be seen as special cases of function composition, in
-- the style of CCG.
-- *Note* the set is not complete and lacks e.g. verbs with more than 2 places.
SlashVP : NP -> VPSlash -> ClSlash ; -- (whom) he sees
AdvSlash : ClSlash -> Adv -> ClSlash ; -- (whom) he sees today
SlashPrep : Cl -> Prep -> ClSlash ; -- (with whom) he walks
SlashVS : NP -> VS -> SSlash -> ClSlash ; -- (whom) she says that he loves
--2 Imperatives
-- An imperative is straightforwardly formed from a verb phrase.
-- It has variation over positive and negative, singular and plural.
-- To fix these parameters, see [Phrase Phrase.html].
ImpVP : VP -> Imp ; -- love yourselves
--2 Embedded sentences
-- Sentences, questions, and infinitival phrases can be used as
-- subjects and (adverbial) complements.
EmbedS : S -> SC ; -- that she goes
EmbedQS : QS -> SC ; -- who goes
EmbedVP : VP -> SC ; -- to go
--2 Sentences
-- These are the 2 x 4 x 4 = 16 forms generated by different
-- combinations of tense, polarity, and
-- anteriority, which are defined in [``Common`` Common.html].
fun
UseCl : Tense -> Ant -> Pol -> Cl -> S ;
UseQCl : Tense -> Ant -> Pol -> QCl -> QS ;
UseRCl : Tense -> Ant -> Pol -> RCl -> RS ;
UseSlash : Tense -> Ant -> Pol -> ClSlash -> SSlash ;
-- An adverb can be added to the beginning of a sentence.
AdvS : Adv -> S -> S ; -- today, I will go home
-- A sentence can be modified by a relative clause referring to its contents.
RelS : S -> RS -> S ; -- she sleeps, which is good
}
--.
-- Examples for English $S$/$Cl$:
{-
Pres Simul Pos ODir : he sleeps
Pres Simul Neg ODir : he doesn't sleep
Pres Anter Pos ODir : he has slept
Pres Anter Neg ODir : he hasn't slept
Past Simul Pos ODir : he slept
Past Simul Neg ODir : he didn't sleep
Past Anter Pos ODir : he had slept
Past Anter Neg ODir : he hadn't slept
Fut Simul Pos ODir : he will sleep
Fut Simul Neg ODir : he won't sleep
Fut Anter Pos ODir : he will have slept
Fut Anter Neg ODir : he won't have slept
Cond Simul Pos ODir : he would sleep
Cond Simul Neg ODir : he wouldn't sleep
Cond Anter Pos ODir : he would have slept
Cond Anter Neg ODir : he wouldn't have slept
-}

View File

@@ -0,0 +1,111 @@
--1 Structural: Structural Words
--
-- Here we have some words belonging to closed classes and appearing
-- in all languages we have considered.
-- Sometimes more distinctions are needed, e.g. $we_Pron$ in Spanish
-- should be replaced by masculine and feminine variants, found in
-- [``ExtraSpa`` ../spanish/ExtraSpa.gf].
abstract Structural = Cat ** {
fun
-- This is an alphabetical list of structural words
above_Prep : Prep ;
after_Prep : Prep ;
all_Predet : Predet ;
almost_AdA : AdA ;
almost_AdN : AdN ;
although_Subj : Subj ;
always_AdV : AdV ;
and_Conj : Conj ;
because_Subj : Subj ;
before_Prep : Prep ;
behind_Prep : Prep ;
between_Prep : Prep ;
both7and_DConj : Conj ; -- both...and
---b both7and_DConj : DConj ;
but_PConj : PConj ;
by8agent_Prep : Prep ; -- by (agent)
by8means_Prep : Prep ; -- by (means of)
can8know_VV : VV ; -- can (capacity)
can_VV : VV ; -- can (possibility)
during_Prep : Prep ;
either7or_DConj : Conj ; -- either...or
---b either7or_DConj : DConj ;
every_Det : Det ;
everybody_NP : NP ; -- everybody
everything_NP : NP ;
everywhere_Adv : Adv ;
--- first_Ord : Ord ; DEPRECATED
few_Det : Det ;
for_Prep : Prep ;
from_Prep : Prep ;
he_Pron : Pron ;
here_Adv : Adv ;
here7to_Adv : Adv ; -- to here
here7from_Adv : Adv ; -- from here
how_IAdv : IAdv ;
how8many_IDet : IDet ;
i_Pron : Pron ;
if_Subj : Subj ;
in8front_Prep : Prep ; -- in front of
in_Prep : Prep ;
it_Pron : Pron ;
less_CAdv : CAdv ;
many_Det : Det ;
more_CAdv : CAdv ;
most_Predet : Predet ;
much_Det : Det ;
must_VV : VV ;
---b no_Phr : Phr ;
no_Utt : Utt ;
on_Prep : Prep ;
--- one_Quant : QuantSg ; DEPRECATED
only_Predet : Predet ;
or_Conj : Conj ;
otherwise_PConj : PConj ;
part_Prep : Prep ;
please_Voc : Voc ;
possess_Prep : Prep ; -- of (possessive)
quite_Adv : AdA ;
she_Pron : Pron ;
so_AdA : AdA ;
someSg_Det : Det ;
somePl_Det : Det ;
somebody_NP : NP ;
something_NP : NP ;
somewhere_Adv : Adv ;
that_Quant : Quant ;
there_Adv : Adv ;
there7to_Adv : Adv ; -- to there
there7from_Adv : Adv ; -- from there
therefore_PConj : PConj ;
they_Pron : Pron ;
this_Quant : Quant ;
through_Prep : Prep ;
to_Prep : Prep ;
too_AdA : AdA ;
under_Prep : Prep ;
very_AdA : AdA ;
want_VV : VV ;
we_Pron : Pron ;
whatPl_IP : IP ; -- what (plural)
whatSg_IP : IP ; -- what (singular)
when_IAdv : IAdv ;
when_Subj : Subj ;
where_IAdv : IAdv ;
which_IQuant : IQuant ;
whoPl_IP : IP ; -- who (plural)
whoSg_IP : IP ; -- who (singular)
why_IAdv : IAdv ;
with_Prep : Prep ;
without_Prep : Prep ;
---b yes_Phr : Phr ;
yes_Utt : Utt ;
youSg_Pron : Pron ; -- you (singular)
youPl_Pron : Pron ; -- you (plural)
youPol_Pron : Pron ; -- you (polite)
}

View File

@@ -0,0 +1,15 @@
--1 Text: Texts
-- Texts are built from an empty text by adding $Phr$ases,
-- using as constructors the punctuation marks ".", "?", and "!".
-- Any punctuation mark can be attached to any kind of phrase.
abstract Text = Common ** {
fun
TEmpty : Text ; --
TFullStop : Phr -> Text -> Text ; -- John walks. ...
TQuestMark : Phr -> Text -> Text ; -- Are they here? ...
TExclMark : Phr -> Text -> Text ; -- Let's go! ...
}

View File

@@ -0,0 +1,71 @@
--1 The construction of verb phrases
abstract Verb = Cat ** {
--2 Complementization rules
-- Verb phrases are constructed from verbs by providing their
-- complements. There is one rule for each verb category.
fun
UseV : V -> VP ; -- sleep
ComplVV : VV -> VP -> VP ; -- want to run
ComplVS : VS -> S -> VP ; -- say that she runs
ComplVQ : VQ -> QS -> VP ; -- wonder who runs
ComplVA : VA -> AP -> VP ; -- they become red
SlashV2a : V2 -> VPSlash ; -- love (it)
Slash2V3 : V3 -> NP -> VPSlash ; -- give it (to her)
Slash3V3 : V3 -> NP -> VPSlash ; -- give (it) to her
SlashV2V : V2V -> VP -> VPSlash ; -- beg (her) to go
SlashV2S : V2S -> S -> VPSlash ; -- answer (to him) that it is good
SlashV2Q : V2Q -> QS -> VPSlash ; -- ask (him) who came
SlashV2A : V2A -> AP -> VPSlash ; -- paint (it) red
ComplSlash : VPSlash -> NP -> VP ; -- love it
SlashVV : VV -> VPSlash -> VPSlash ; -- want to buy
SlashV2VNP : V2V -> NP -> VPSlash -> VPSlash ; -- beg me to buy
--2 Other ways of forming verb phrases
-- Verb phrases can also be constructed reflexively and from
-- copula-preceded complements.
ReflVP : VPSlash -> VP ; -- love himself
UseComp : Comp -> VP ; -- be warm
-- Passivization of two-place verbs is another way to use
-- them. In many languages, the result is a participle that
-- is used as complement to a copula ("is used"), but other
-- auxiliary verbs are possible (Ger. "wird angewendet", It.
-- "viene usato"), as well as special verb forms (Fin. "käytetään",
-- Swe. "används").
--
-- *Note*. the rule can be overgenerating, since the $V2$ need not
-- take a direct object.
PassV2 : V2 -> VP ; -- be loved
-- Adverbs can be added to verb phrases. Many languages make
-- a distinction between adverbs that are attached in the end
-- vs. next to (or before) the verb.
AdvVP : VP -> Adv -> VP ; -- sleep here
AdVVP : AdV -> VP -> VP ; -- always sleep
-- *Agents of passives* are constructed as adverbs with the
-- preposition [Structural Structural.html]$.8agent_Prep$.
--2 Complements to copula
-- Adjectival phrases, noun phrases, and adverbs can be used.
CompAP : AP -> Comp ; -- (be) small
CompNP : NP -> Comp ; -- (be) a man
CompAdv : Adv -> Comp ; -- (be) here
}

View File

@@ -0,0 +1,199 @@
--1 Combinators: a High-Level Syntax API
-- This module defines some "grammatical functions" that give shortcuts to
-- typical constructions. [``Constructors`` Constructors.html] and the
-- language-specific ``Paradigms`` modules are usually needed
-- to construct arguments of these functions.
incomplete resource Combinators = open Grammar in {
oper
--2 Predication
pred : overload {
pred : V -> NP -> Cl ; -- x converges
pred : V2 -> NP -> NP -> Cl ; -- x intersects y
pred : V3 -> NP -> NP -> NP -> Cl ; -- x intersects y at z
pred : V -> NP -> NP -> Cl ; -- x and y intersect
pred : A -> NP -> Cl ; -- x is even
pred : A2 -> NP -> NP -> Cl ; -- x is divisible by y
pred : A -> NP -> NP -> Cl ; -- x and y are equal
pred : N -> NP -> Cl ; -- x is a maximum
pred : CN -> NP -> Cl ; -- x is a local maximum
pred : NP -> NP -> Cl ; -- x is the neutral element
pred : N -> NP -> NP -> Cl ; -- x and y are inverses
pred : Adv -> NP -> Cl ; -- x is in scope
pred : Prep -> NP -> NP -> Cl -- x is outside y
} ;
--2 Function application
app : overload {
app : N -> NP ;
app : N2 -> NP -> NP ;
app : N3 -> NP -> NP -> NP ;
app : N2 -> NP -> NP -> NP ;
app : N2 -> N -> CN ;
app : N2 -> NP -> CN ; -- divisor of x
app : N3 -> NP -> NP -> CN ; -- path from x to y
app : N2 -> NP -> NP -> CN ; -- path between x and y
} ;
--2 Coordination
coord : overload {
coord : Conj -> Adv -> Adv -> Adv ;
coord : Conj -> AP -> AP -> AP ;
coord : Conj -> NP -> NP -> NP ;
coord : Conj -> S -> S -> S ;
coord : Conj -> ListAdv -> Adv ;
coord : Conj -> ListAP -> AP ;
coord : Conj -> ListNP -> NP ;
coord : Conj -> ListS -> S ;
} ;
--2 Modification
mod : overload {
mod : A -> N -> CN ;
mod : AP -> CN -> CN ;
mod : AdA -> A -> AP ;
mod : Det -> N -> NP ;
mod : Det -> CN -> NP ;
mod : Quant -> N -> NP ;
mod : Quant -> CN -> NP ;
mod : Predet -> N -> NP ;
mod : Numeral -> N -> NP
} ;
--2 Negation
neg : overload {
neg : Imp -> Utt ;
neg : Cl -> S ;
neg : QCl -> QS ;
neg : RCl -> RS
};
--2 Text append
-- This is not in ground API, because it would destroy parsing.
appendText : Text -> Text -> Text ;
--.
pred = overload {
pred : V -> NP -> Cl
= \v,np -> PredVP np (UseV v) ;
pred : V2 -> NP -> NP -> Cl
= \v,np,ob -> PredVP np (ComplSlash (SlashV2a v) ob) ;
pred : V3 -> NP -> NP -> NP -> Cl
= \v,np,ob,ob2 ->
PredVP np (ComplSlash (Slash2V3 v ob) ob2) ;
pred : V -> NP -> NP -> Cl
= \v,x,y -> PredVP (ConjNP and_Conj (BaseNP x y)) (UseV v) ;
pred : A -> NP -> Cl
= \a,np -> PredVP np (UseComp (CompAP (PositA a))) ;
pred : A2 -> NP -> NP -> Cl
= \a,x,y -> PredVP x (UseComp (CompAP (ComplA2 a y))) ;
pred : A -> NP -> NP -> Cl
= \a,x,y -> PredVP (ConjNP and_Conj (BaseNP x y)) (UseComp (CompAP (PositA a))) ;
pred : N -> NP -> Cl
= \n,x -> PredVP x (UseComp (CompNP (DetArtSg (IndefArt) (UseN n)))) ;
pred : CN -> NP -> Cl
= \n,x -> PredVP x (UseComp (CompNP (DetArtSg (IndefArt) n))) ;
pred : NP -> NP -> Cl
= \n,x -> PredVP x (UseComp (CompNP n)) ; pred : N2 -> NP -> NP -> Cl
= \n,x,y -> PredVP x (UseComp (CompNP (DetArtSg (IndefArt) (ComplN2 n y)))) ;
pred : N -> NP -> NP -> Cl
= \n,x,y -> PredVP (ConjNP and_Conj (BaseNP x y)) (UseComp (CompNP (DetArtPl (IndefArt) (UseN n)))) ;
pred : Adv -> NP -> Cl
= \a,x -> PredVP x (UseComp (CompAdv a)) ;
pred : Prep -> NP -> NP -> Cl
= \p,x,y -> PredVP x (UseComp (CompAdv (PrepNP p y)))
} ;
app = overload {
app : N -> NP
= \n -> (DetArtSg (DefArt) (UseN n)) ;
app : N2 -> NP -> NP
= \n,x -> (DetArtSg (DefArt) (ComplN2 n x)) ;
app : N3 -> NP -> NP -> NP
= \n,x,y -> (DetArtSg (DefArt) (ComplN2 (ComplN3 n x) y)) ;
app : N2 -> NP -> NP -> NP
= \n,x,y -> (DetArtSg DefArt (ComplN2 n (ConjNP and_Conj (BaseNP x y)))) ;
app : N2 -> N -> CN
= \f,n -> ComplN2 f (DetArtPl (IndefArt) (UseN n)) ;
app : N2 -> NP -> CN = ComplN2 ;
app : N3 -> NP -> NP -> CN = \n,x,y -> ComplN2 (ComplN3 n x) y ;
app : N2 -> NP -> NP -> CN = \n,x,y ->
ComplN2 n (ConjNP and_Conj (BaseNP x y)) ;
} ;
coord = overload {
coord : Conj -> Adv -> Adv -> Adv
= \c,x,y -> ConjAdv c (BaseAdv x y) ;
coord : Conj -> AP -> AP -> AP
= \c,x,y -> ConjAP c (BaseAP x y) ;
coord : Conj -> NP -> NP -> NP
= \c,x,y -> ConjNP c (BaseNP x y) ;
coord : Conj -> S -> S -> S
= \c,x,y -> ConjS c (BaseS x y) ;
coord : Conj -> ListAdv -> Adv
= \c,xy -> ConjAdv c xy ;
coord : Conj -> ListAP -> AP
= \c,xy -> ConjAP c xy ;
coord : Conj -> ListNP -> NP
= \c,xy -> ConjNP c xy ;
coord : Conj -> ListS -> S
= \c,xy -> ConjS c xy
} ;
mod = overload {
mod : A -> N -> CN
= \a,n -> AdjCN (PositA a) (UseN n) ;
mod : AP -> CN -> CN
= \a,n -> AdjCN a n ;
mod : AdA -> A -> AP
= \m,a -> AdAP m (PositA a) ;
mod : Det -> N -> NP
= \d,n -> DetCN d (UseN n) ;
mod : Det -> CN -> NP
= \d,n -> DetCN d n ;
mod : Quant -> N -> NP
= \q,n -> DetCN (DetQuant (q) NumSg) (UseN n) ;
mod : Quant -> CN -> NP
= \q,n -> DetCN (DetQuant (q) NumSg) n ;
mod : Predet -> N -> NP
= \q,n -> PredetNP q (DetArtPl (IndefArt) (UseN n)) ;
mod : Numeral -> N -> NP
= \nu,n -> DetCN (DetArtCard (IndefArt) (NumNumeral nu)) (UseN n)
} ;
neg = overload {
neg : Imp -> Utt
= UttImpSg PNeg ;
neg : Cl -> S
= UseCl TPres ASimul PNeg;
neg : QCl -> QS
= UseQCl TPres ASimul PNeg;
neg : RCl -> RS
= UseRCl TPres ASimul PNeg
};
-- This is not in ground API, because it would destroy parsing.
appendText : Text -> Text -> Text
= \x,y -> {s = x.s ++ y.s ; lock_Text = <>} ;
}

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource CombinatorsAra = Combinators with (Grammar = GrammarAra) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource CombinatorsBul = Combinators with (Grammar = GrammarBul) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource CombinatorsCat = Combinators with (Grammar = GrammarCat) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource CombinatorsDan = Combinators with (Grammar = GrammarDan) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource CombinatorsEng = Combinators with (Grammar = GrammarEng) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource CombinatorsFin = Combinators with (Grammar = GrammarFin) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource CombinatorsFre = Combinators with (Grammar = GrammarFre) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource CombinatorsGer = Combinators with (Grammar = GrammarGer) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource CombinatorsHin = Combinators with (Grammar = GrammarHin) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource CombinatorsIna = Combinators with (Grammar = GrammarIna) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource CombinatorsIta = Combinators with (Grammar = GrammarIta) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource CombinatorsNor = Combinators with (Grammar = GrammarNor) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource CombinatorsRus = Combinators with (Grammar = GrammarRus) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource CombinatorsSpa = Combinators with (Grammar = GrammarSpa) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource CombinatorsSwe = Combinators with (Grammar = GrammarSwe) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource CombinatorsTha = Combinators with (Grammar = GrammarTha) ;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsBul = Constructors with (Grammar = GrammarBul) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsCat = Constructors with (Grammar = GrammarCat) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsDan = Constructors with (Grammar = GrammarDan) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsEng = Constructors with (Grammar = GrammarEng) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsFin = Constructors with (Grammar = GrammarFin) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsFre = Constructors with (Grammar = GrammarFre) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsGer = Constructors with (Grammar = GrammarGer) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsIta = Constructors with (Grammar = GrammarIta) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsNor = Constructors with (Grammar = GrammarNor) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsRus = Constructors with (Grammar = GrammarRus) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsSpa = Constructors with (Grammar = GrammarSpa) ;

View File

@@ -0,0 +1,3 @@
--# -path=.:alltenses:prelude
resource ConstructorsSwe = Constructors with (Grammar = GrammarSwe) ;

View File

@@ -0,0 +1,4 @@
--# -path=.:alltenses:prelude
interface Syntax = Constructors, Cat, Structural, Combinators ;

View File

@@ -0,0 +1,4 @@
--# -path=.:alltenses:prelude
instance SyntaxBul of Syntax = ConstructorsBul, CatBul, StructuralBul, CombinatorsBul ;

View File

@@ -0,0 +1,4 @@
--# -path=.:alltenses:prelude
instance SyntaxCat of Syntax = ConstructorsCat, CatCat, StructuralCat, CombinatorsCat ;

View File

@@ -0,0 +1,4 @@
--# -path=.:alltenses:prelude
instance SyntaxDan of Syntax = ConstructorsDan, CatDan, StructuralDan, CombinatorsDan ;

View File

@@ -0,0 +1,5 @@
--# -path=.:alltenses:prelude
instance SyntaxEng of Syntax =
ConstructorsEng, CatEng, StructuralEng, CombinatorsEng ;

View File

@@ -0,0 +1,4 @@
--# -path=.:alltenses:prelude
instance SyntaxFin of Syntax = ConstructorsFin, CatFin, StructuralFin, CombinatorsFin ;

View File

@@ -0,0 +1,4 @@
--# -path=.:alltenses:prelude
instance SyntaxFre of Syntax = ConstructorsFre, CatFre, StructuralFre, CombinatorsFre ;

View File

@@ -0,0 +1,4 @@
--# -path=.:alltenses:prelude
instance SyntaxGer of Syntax = ConstructorsGer, CatGer, StructuralGer, CombinatorsGer ;

View File

@@ -0,0 +1,4 @@
--# -path=.:alltenses:prelude
instance SyntaxIta of Syntax = ConstructorsIta, CatIta, StructuralIta, CombinatorsIta ;

View File

@@ -0,0 +1,5 @@
--# -path=.:alltenses:prelude
instance SyntaxNor of Syntax = ConstructorsNor, CatNor, StructuralNor, CombinatorsNor
;

View File

@@ -0,0 +1,4 @@
--# -path=.:alltenses:prelude
instance SyntaxRus of Syntax = ConstructorsRus, CatRus, StructuralRus, CombinatorsRus ;

View File

@@ -0,0 +1,5 @@
--# -path=.:alltenses:prelude
instance SyntaxSpa of Syntax =
ConstructorsSpa, CatSpa, StructuralSpa, CombinatorsSpa ;

View File

@@ -0,0 +1,5 @@
--# -path=.:alltenses:prelude
instance SyntaxSwe of Syntax =
ConstructorsSwe, CatSwe, StructuralSwe, CombinatorsSwe ;

View File

@@ -0,0 +1,13 @@
--# -path=.:alltenses:prelude
resource TryBul = SyntaxBul, LexiconBul, ParadigmsBul - [mkAdv] **
open (P = ParadigmsBul) in {
oper
mkAdv = overload SyntaxBul {
mkAdv : Str -> Adv = P.mkAdv ;
} ;
}

View File

@@ -0,0 +1,13 @@
--# -path=.:alltenses:prelude
resource TryCat = SyntaxCat, LexiconCat, ParadigmsCat - [mkAdv] **
open (P = ParadigmsCat) in {
oper
mkAdv = overload SyntaxCat {
mkAdv : Str -> Adv = P.mkAdv ;
} ;
}

Some files were not shown because too many files have changed in this diff Show More