diff options
| author | aarne <aarne@cs.chalmers.se> | 2005-12-21 09:29:20 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2005-12-21 09:29:20 +0000 |
| commit | c15ee36f742d01c65ef07a723b87ecaeed39c2e0 (patch) | |
| tree | 58ead4f1cda333c24dcf0cd0976faac60a3f061f | |
| parent | e6f46da89b2f04fcd2c264f7383f51814a6e2def (diff) | |
html version generated
| -rw-r--r-- | doc/tutorial/gf-tutorial2.html | 145 |
1 files changed, 99 insertions, 46 deletions
diff --git a/doc/tutorial/gf-tutorial2.html b/doc/tutorial/gf-tutorial2.html index d3d390aa8..6f8ff78f1 100644 --- a/doc/tutorial/gf-tutorial2.html +++ b/doc/tutorial/gf-tutorial2.html @@ -7,7 +7,7 @@ <P ALIGN="center"><CENTER><H1>Grammatical Framework Tutorial</H1> <FONT SIZE="4"> <I>Author: Aarne Ranta <aarne (at) cs.chalmers.se></I><BR> -Last update: Mon Dec 19 18:05:36 2005 +Last update: Wed Dec 21 10:29:13 2005 </FONT></CENTER> <P></P> @@ -91,36 +91,38 @@ Last update: Mon Dec 19 18:05:36 2005 <LI><A HREF="#toc58">Free variation</A> <LI><A HREF="#toc59">Record extension and subtyping</A> <LI><A HREF="#toc60">Tuples and product types</A> - <LI><A HREF="#toc61">Prefix-dependent choices</A> - <LI><A HREF="#toc62">Predefined types and operations</A> + <LI><A HREF="#toc61">Record and tuple patterns</A> + <LI><A HREF="#toc62">Prefix-dependent choices</A> + <LI><A HREF="#toc63">Predefined types and operations</A> </UL> - <LI><A HREF="#toc63">More features of the module system</A> + <LI><A HREF="#toc64">More features of the module system</A> <UL> - <LI><A HREF="#toc64">Interfaces, instances, and functors</A> - <LI><A HREF="#toc65">Resource grammars and their reuse</A> - <LI><A HREF="#toc66">Restricted inheritance and qualified opening</A> + <LI><A HREF="#toc65">Interfaces, instances, and functors</A> + <LI><A HREF="#toc66">Resource grammars and their reuse</A> + <LI><A HREF="#toc67">Restricted inheritance and qualified opening</A> </UL> - <LI><A HREF="#toc67">More concepts of abstract syntax</A> + <LI><A HREF="#toc68">More concepts of abstract syntax</A> <UL> - <LI><A HREF="#toc68">Dependent types</A> - <LI><A HREF="#toc69">Higher-order abstract syntax</A> - <LI><A HREF="#toc70">Semantic definitions</A> + <LI><A HREF="#toc69">Dependent types</A> + <LI><A HREF="#toc70">Higher-order abstract syntax</A> + <LI><A HREF="#toc71">Semantic definitions</A> + <LI><A HREF="#toc72">List categories</A> </UL> - <LI><A HREF="#toc71">Transfer modules</A> - <LI><A HREF="#toc72">Practical issues</A> + <LI><A HREF="#toc73">Transfer modules</A> + <LI><A HREF="#toc74">Practical issues</A> <UL> - <LI><A HREF="#toc73">Lexers and unlexers</A> - <LI><A HREF="#toc74">Efficiency of grammars</A> - <LI><A HREF="#toc75">Speech input and output</A> - <LI><A HREF="#toc76">Multilingual syntax editor</A> - <LI><A HREF="#toc77">Interactive Development Environment (IDE)</A> - <LI><A HREF="#toc78">Communicating with GF</A> - <LI><A HREF="#toc79">Embedded grammars in Haskell, Java, and Prolog</A> - <LI><A HREF="#toc80">Alternative input and output grammar formats</A> + <LI><A HREF="#toc75">Lexers and unlexers</A> + <LI><A HREF="#toc76">Efficiency of grammars</A> + <LI><A HREF="#toc77">Speech input and output</A> + <LI><A HREF="#toc78">Multilingual syntax editor</A> + <LI><A HREF="#toc79">Interactive Development Environment (IDE)</A> + <LI><A HREF="#toc80">Communicating with GF</A> + <LI><A HREF="#toc81">Embedded grammars in Haskell, Java, and Prolog</A> + <LI><A HREF="#toc82">Alternative input and output grammar formats</A> </UL> - <LI><A HREF="#toc81">Case studies</A> + <LI><A HREF="#toc83">Case studies</A> <UL> - <LI><A HREF="#toc82">Interfacing formal and natural languages</A> + <LI><A HREF="#toc84">Interfacing formal and natural languages</A> </UL> </UL> @@ -1996,6 +1998,44 @@ Product types and tuples are syntactic sugar for record types and records: Thus the labels <CODE>p1, p2,...`</CODE> are hard-coded. </P> <A NAME="toc61"></A> +<H3>Record and tuple patterns</H3> +<P> +Record types of parameter types are also parameter types. +A typical example is a record of agreement features, e.g. French +</P> +<PRE> + oper Agr : PType = {g : Gender ; n : Number ; p : Person} ; +</PRE> +<P> +Notice the term <CODE>PType</CODE> rather than just <CODE>Type</CODE> referring to +parameter types. Every <CODE>PType</CODE> is also a <CODE>Type</CODE>. +</P> +<P> +Pattern matching is done in the expected way, but it can moreover +utilize partial records: the branch +</P> +<PRE> + {g = Fem} => t +</PRE> +<P> +in a table of type <CODE>Agr => T</CODE> means the same as +</P> +<PRE> + {g = Fem ; n = _ ; p = _} => t +</PRE> +<P> +Tuple patterns are translated to record patterns in the +same way as tuples to records; partial patterns make it +possible to write, slightly surprisingly, +</P> +<PRE> + case <g,n,p> of { + <Fem> => t + ... + } +</PRE> +<P></P> +<A NAME="toc62"></A> <H3>Prefix-dependent choices</H3> <P> The construct exemplified in @@ -2024,7 +2064,7 @@ This very example does not work in all situations: the prefix } ; </PRE> <P></P> -<A NAME="toc62"></A> +<A NAME="toc63"></A> <H3>Predefined types and operations</H3> <P> GF has the following predefined categories in abstract syntax: @@ -2047,11 +2087,11 @@ they can be used as arguments. For example: -- e.g. (StreetAddress 10 "Downing Street") : Address </PRE> <P></P> -<A NAME="toc63"></A> -<H2>More features of the module system</H2> <A NAME="toc64"></A> -<H3>Interfaces, instances, and functors</H3> +<H2>More features of the module system</H2> <A NAME="toc65"></A> +<H3>Interfaces, instances, and functors</H3> +<A NAME="toc66"></A> <H3>Resource grammars and their reuse</H3> <P> A resource grammar is a grammar built on linguistic grounds, @@ -2104,17 +2144,19 @@ The rest of the modules (black) come from the resource. <P> <IMG ALIGN="middle" SRC="Multi.png" BORDER="0" ALT=""> </P> -<A NAME="toc66"></A> -<H3>Restricted inheritance and qualified opening</H3> <A NAME="toc67"></A> -<H2>More concepts of abstract syntax</H2> +<H3>Restricted inheritance and qualified opening</H3> <A NAME="toc68"></A> -<H3>Dependent types</H3> +<H2>More concepts of abstract syntax</H2> <A NAME="toc69"></A> -<H3>Higher-order abstract syntax</H3> +<H3>Dependent types</H3> <A NAME="toc70"></A> -<H3>Semantic definitions</H3> +<H3>Higher-order abstract syntax</H3> <A NAME="toc71"></A> +<H3>Semantic definitions</H3> +<A NAME="toc72"></A> +<H3>List categories</H3> +<A NAME="toc73"></A> <H2>Transfer modules</H2> <P> Transfer means noncompositional tree-transforming operations. @@ -2133,9 +2175,9 @@ See the <A HREF="../transfer.html">transfer language documentation</A> for more information. </P> -<A NAME="toc72"></A> +<A NAME="toc74"></A> <H2>Practical issues</H2> -<A NAME="toc73"></A> +<A NAME="toc75"></A> <H3>Lexers and unlexers</H3> <P> Lexers and unlexers can be chosen from @@ -2171,7 +2213,7 @@ Given by <CODE>help -lexer</CODE>, <CODE>help -unlexer</CODE>: </PRE> <P></P> -<A NAME="toc74"></A> +<A NAME="toc76"></A> <H3>Efficiency of grammars</H3> <P> Issues: @@ -2182,7 +2224,7 @@ Issues: <LI>parsing efficiency: <CODE>-mcfg</CODE> vs. others </UL> -<A NAME="toc75"></A> +<A NAME="toc77"></A> <H3>Speech input and output</H3> <P> The<CODE>speak_aloud = sa</CODE> command sends a string to the speech @@ -2212,7 +2254,7 @@ The method words only for grammars of English. Both Flite and ATK are freely available through the links above, but they are not distributed together with GF. </P> -<A NAME="toc76"></A> +<A NAME="toc78"></A> <H3>Multilingual syntax editor</H3> <P> The @@ -2229,18 +2271,29 @@ Here is a snapshot of the editor: The grammars of the snapshot are from the <A HREF="http://www.cs.chalmers.se/~aarne/GF/examples/letter">Letter grammar package</A>. </P> -<A NAME="toc77"></A> +<A NAME="toc79"></A> <H3>Interactive Development Environment (IDE)</H3> <P> Forthcoming. </P> -<A NAME="toc78"></A> +<A NAME="toc80"></A> <H3>Communicating with GF</H3> <P> Other processes can communicate with the GF command interpreter, -and also with the GF syntax editor. +and also with the GF syntax editor. Useful flags when invoking GF are </P> -<A NAME="toc79"></A> +<UL> +<LI><CODE>-batch</CODE> suppresses the promps and structures the communication with XML tags. +<LI><CODE>-s</CODE> suppresses non-output non-error messages and XML tags. +-- <CODE>-nocpu</CODE> suppresses CPU time indication. +<P></P> +Thus the most silent way to invoke GF is +<PRE> + gf -batch -s -nocpu +</PRE> +</UL> + +<A NAME="toc81"></A> <H3>Embedded grammars in Haskell, Java, and Prolog</H3> <P> GF grammars can be used as parts of programs written in the @@ -2252,15 +2305,15 @@ following languages. The links give more documentation. <LI><A HREF="http://www.cs.chalmers.se/~peb/software.html">Prolog</A> </UL> -<A NAME="toc80"></A> +<A NAME="toc82"></A> <H3>Alternative input and output grammar formats</H3> <P> A summary is given in the following chart of GF grammar compiler phases: <IMG ALIGN="middle" SRC="../gf-compiler.png" BORDER="0" ALT=""> </P> -<A NAME="toc81"></A> +<A NAME="toc83"></A> <H2>Case studies</H2> -<A NAME="toc82"></A> +<A NAME="toc84"></A> <H3>Interfacing formal and natural languages</H3> <P> <A HREF="http://www.cs.chalmers.se/~krijo/thesis/thesisA4.pdf">Formal and Informal Software Specifications</A>, @@ -2273,6 +2326,6 @@ English and German. A simpler example will be explained here. </P> -<!-- html code generated by txt2tags 2.0 (http://txt2tags.sf.net) --> +<!-- html code generated by txt2tags 2.3 (http://txt2tags.sf.net) --> <!-- cmdline: txt2tags -\-toc gf-tutorial2.txt --> </BODY></HTML> |
