OSDN Git Service

2005-02-13 James A. Morrison <phython@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / treelang / treelang.texi
index 8f9ea8f..665310e 100644 (file)
@@ -2,21 +2,14 @@
 
 @c NOTE THIS IS NOT A GOOD EXAMPLE OF HOW TO DO A MANUAL. FIXME!!!
 @c NOTE THIS IS NOT A GOOD EXAMPLE OF HOW TO DO A MANUAL. FIXME!!!
-@c NOTE THIS IS NOT A GOOD EXAMPLE OF HOW TO DO A MANUAL. FIXME!!!
 
 
 @c %**start of header
 @setfilename treelang.info
 
-@set last-update 2001-07-30
-@set copyrights-treelang 1995,1996,1997,1998,1999,2000,2001,2002
-@c DEVELOPMENT is set to indicate an in-development version,
-@c as compared to a release version.  When making a release
-@c (e.g. a release branch in the CVS repository for GCC),
-@c clear this and set the version information correctly.
-@clear DEVELOPMENT
-@set version-treelang 1.0
-@set version-GCC 3.0
+@include gcc-common.texi
+
+@set copyrights-treelang 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005
 
 @set email-general gcc@@gcc.gnu.org
 @set email-bugs gcc-bugs@@gcc.gnu.org or bug-gcc@@gnu.org
 @c and make sure the following does NOT begin with '@c':
 @c @clear USING
 
-@c 6/27/96 FSF DO wants smallbook fmt for 1st bound edition. (from gcc.texi)
-@c @smallbook
-
-@c i also commented out the finalout command, so if there *are* any
-@c overfulls, you'll (hopefully) see the rectangle in the right hand
-@c margin. -- burley 1999-03-13 (from mew's comment in GCC.texi).
-@c @finalout
-
 @ifset INTERNALS
 @ifset USING
 @settitle Using and Maintaining GNU Treelang
 @c \global\normaloffset =0.75in
 @c @end tex
 
-@ifinfo
+@copying
+Copyright @copyright{} @value{copyrights-treelang} Free Software Foundation, Inc.
+
+Permission is granted to copy, distribute and/or modify this document
+under the terms of the GNU Free Documentation License, Version 1.2 or
+any later version published by the Free Software Foundation; with the
+Invariant Sections being ``GNU General Public License'', the Front-Cover
+texts being (a) (see below), and with the Back-Cover Texts being (b)
+(see below).  A copy of the license is included in the section entitled
+``GNU Free Documentation License''.
+
+(a) The FSF's Front-Cover Text is:
+
+     A GNU Manual
+
+(b) The FSF's Back-Cover Text is:
+
+     You have freedom to copy and modify this GNU Manual, like GNU
+     software.  Copies published by the Free Software Foundation raise
+     funds for GNU development.
+@end copying
+
+@ifnottex
 @dircategory Programming
 @direntry
 * treelang: (treelang).                  The GNU Treelang compiler.
@@ -118,26 +125,8 @@ Published by the Free Software Foundation
 59 Temple Place - Suite 330
 Boston, MA 02111-1307 USA
 
-Copyright (C) @value{copyrights-treelang} Free Software Foundation, Inc.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.1 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below).  A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
-
-(a) The FSF's Front-Cover Text is:
-
-     A GNU Manual
-
-(b) The FSF's Back-Cover Text is:
-
-     You have freedom to copy and modify this GNU Manual, like GNU
-     software.  Copies published by the Free Software Foundation raise
-     funds for GNU development.
-@end ifinfo
+@insertcopying
+@end ifnottex
 
 treelang was Contributed by Tim Josling (@email{@value{email-josling}}).
 Inspired by and based on the 'toy' language, written by Richard Kenner.
@@ -162,14 +151,8 @@ documentation.
 @end ifclear
 @sp 2
 @center Tim Josling
-@sp 3
-@center Last updated @value{last-update}
-@sp 1
-@center for version @value{version-treelang}
 @page
 @vskip 0pt plus 1filll
-Copyright @copyright{} @value{copyrights-treelang} Free Software Foundation, Inc.
-@sp 2
 For the @value{which-treelang} Version*
 @sp 1
 Published by the Free Software Foundation @*
@@ -179,27 +162,11 @@ Boston, MA 02111-1307, USA@*
 @c Printed copies are available for $? each.@*
 @c ISBN ???
 @sp 1
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.1 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below).  A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
-
-(a) The FSF's Front-Cover Text is:
-
-     A GNU Manual
-
-(b) The FSF's Back-Cover Text is:
-
-     You have freedom to copy and modify this GNU Manual, like GNU
-     software.  Copies published by the Free Software Foundation raise
-     funds for GNU development.
+@insertcopying
 @end titlepage
 @page
 
-@ifinfo
+@ifnottex
 
 @node Top, Copying,, (dir)
 @top Introduction
@@ -226,12 +193,7 @@ new features and incompatibilities, and how to report bugs.  It
 corresponds to the @value{which-treelang} version of @code{treelang}.
 @end ifclear
 
-@end ifinfo
-
-@ifset DEVELOPMENT
-@emph{Warning:} This document is still under development, and might not
-accurately reflect the @code{treelang} code base of which it is a part.
-@end ifset
+@end ifnottex
 
 @menu
 * Copying::                     
@@ -297,7 +259,8 @@ Reporting Bugs
 Treelang was based on 'toy' by Richard Kenner, and also uses code from
 the GCC core code tree. Tim Josling first created the language and
 documentation, based on the GCC Fortran compiler's documentation
-framework.
+framework.  Treelang was updated to use the TreeSSA infrastructure by James A.
+Morrison.
 
 @itemize @bullet
 @item
@@ -315,7 +278,7 @@ It would have been difficult to build treelang without access to Joachim
 Nadler's guide to writing a front end to GCC (written in German). A
 translation of this document into English is available via the
 CobolForGCC project or via the documentation links from the GCC home
-page @uref{http://GCC.gnu.org}.
+page @uref{http://gcc.gnu.org}.
 @end itemize
 
 @include funding.texi
@@ -334,10 +297,13 @@ language. Therefore only language developers are likely to have an
 interest in it.
 
 This manual assumes familiarity with GCC, which you can obtain by using
-it and by reading the manual @samp{Using and Porting GCC}.
+it and by reading the manuals @samp{Using the GNU Compiler Collection (GCC)}
+and @samp{GNU Compiler Collection (GCC) Internals}.
 
 To install treelang, follow the GCC installation instructions, 
-taking care to ensure you specify treelang in the configure step.
+taking care to ensure you specify treelang in the configure step by adding
+treelang to the list of languages specified by @option{--enable-langauges}, 
+e.g.@: @samp{--enable-languages=all,treelang}.
 
 If you're generally curious about the future of
 @code{treelang}, see @ref{Projects}.
@@ -370,18 +336,18 @@ The main features missing are structures, arrays and pointers.
 
 A sample program follows:
 
-@example
-// function prototypes
-// function 'add' taking two ints and returning an int
+@smallexample
+// @r{function prototypes}
+// @r{function 'add' taking two ints and returning an int}
 external_definition int add(int arg1, int arg2);
 external_definition int subtract(int arg3, int arg4);
 external_definition int first_nonzero(int arg5, int arg6);
 external_definition int double_plus_one(int arg7);
 
-// function definition
+// @r{function definition}
 add 
 @{
-// return the sum of arg1 and arg2
+  // @r{return the sum of arg1 and arg2}
   return arg1 + arg2;
 @}
 
@@ -393,9 +359,11 @@ subtract
 
 double_plus_one
 @{
-// aaa is a variable, of type integer and allocated at the start of the function
+  // @r{aaa is a variable, of type integer and allocated at the start of}
+  // @r{the function}
   automatic int aaa;
-// set aaa to the value returned from aaa, when passed arg7 and arg7 as the two parameters
+  // @r{set aaa to the value returned from add, when passed arg7 and arg7 as}
+  // @r{the two parameters}
   aaa=add(arg7, arg7);
   aaa=add(aaa, aaa);
   aaa=subtract(subtract(aaa, arg7), arg7) + 1;
@@ -404,7 +372,7 @@ double_plus_one
 
 first_nonzero
 @{
-// C-like if statement
+  // @r{C-like if statement}
   if (arg5)
     @{
       return arg5;
@@ -414,7 +382,7 @@ first_nonzero
     @}
   return arg6;
 @}
-@end example
+@end smallexample
 
 @node Lexical Syntax, Parsing Syntax, What is GNU Treelang?, Top
 @chapter Lexical Syntax
@@ -424,8 +392,8 @@ Treelang programs consist of whitespace, comments, keywords and names.
 @itemize @bullet
 
 @item
-Whitespace consists of the space character and the end of line
-character. Tabs are not allowed. Line terminations are as defined by the
+Whitespace consists of the space character, a tab, and the end of line
+character.  Line terminations are as defined by the
 standard C library. Whitespace is ignored except within comments,
 and where it separates parts of the program. In the example below, A and
 B are two separate names separated by whitespace. 
@@ -440,43 +408,64 @@ of the line. C style comments (/* */) are not supported. For example,
 the assignment below is followed by a not very helpful comment.
 
 @smallexample
-x=1; // Set X to 1
+x = 1; // @r{Set X to 1}
 @end smallexample
 
 @item
-Keywords consist of any reserved words or symbols as described
-later. The list of keywords follows:
+Keywords consist of any of the following reserved words or symbols:
 
-@smallexample
-@{ - used to start the statements in a function
-@} - used to end the statements in a function
-( - start list of function arguments, or to change the precedence of operators in an expression
-) - end list or prioritised operators in expression
-, - used to separate parameters in a function prototype or in a function call 
-; - used to end a statement
-+ - addition
-- - subtraction
-= - assignment
-== - equality test
-if - begin IF statement
-else - begin 'else' portion of IF statement
-static - indicate variable is permanent, or function has file scope only
-automatic - indicate that variable is allocated for the life of the function
-external_reference - indicate that variable or function is defined in another file
-external_definition - indicate that variable or function is to be accessible from other files
-int - variable is an integer (same as C int) 
-char - variable is a character (same as C char)
-unsigned - variable is unsigned. If this is not present, the variable is signed
-return - start function return statement
-void - used as function type to indicate function returns nothing
-@end smallexample
+@itemize @bullet
+@item @{
+used to start the statements in a function
+@item @}
+used to end the statements in a function
+@item (
+start list of function arguments, or to change the precedence of operators in
+an expression
+@item )
+end list or prioritized operators in expression
+@item ,
+used to separate parameters in a function prototype or in a function call 
+@item ;
+used to end a statement
+@item +
+addition
+@item - 
+subtraction
+@item = 
+assignment
+@item ==
+equality test
+@item if
+begin IF statement
+@item else
+begin 'else' portion of IF statement
+@item static
+indicate variable is permanent, or function has file scope only
+@item automatic
+indicate that variable is allocated for the life of the function
+@item external_reference
+indicate that variable or function is defined in another file
+@item external_definition
+indicate that variable or function is to be accessible from other files
+@item int
+variable is an integer (same as C int) 
+@item char
+variable is a character (same as C char)
+@item unsigned
+variable is unsigned. If this is not present, the variable is signed
+@item return
+start function return statement
+@item void
+used as function type to indicate function returns nothing
+@end itemize
 
 
 @item
-Names consist of any letter or "_" followed by any number of letters or
-numbers or "_". "$" is not allowed in a name. All names must be globally
-unique - the same name may not be used twice in any context - and must
-not be a keyword. Names and keywords are case sensitive. For example:
+Names consist of any letter or "_" followed by any number of letters,
+numbers, or "_".  "$" is not allowed in a name. All names must be globally
+unique, i.e. may not be used twice in any context, and must
+not be a keyword.  Names and keywords are case sensitive. For example:
 
 @smallexample
 a A _a a_ IF_X
@@ -499,7 +488,7 @@ file may contain one of more declarations.
 declaration: variable declaration OR function prototype OR function declaration
 
 @item
-Function Prototype: storage type NAME ( parameter_list )
+Function Prototype: storage type NAME ( optional_parameter_list )
 
 @smallexample
 static int add (int a, int b)
@@ -511,10 +500,11 @@ variable_declaration: storage type NAME initial;
 Example:
 
 @smallexample
-int temp1=1;
+int temp1 = 1;
 @end smallexample
 
-A variable declaration can be outside a function, or at the start of a function.
+A variable declaration can be outside a function, or at the start of a
+function.
 
 @item
 storage: automatic OR static OR external_reference OR external_definition
@@ -601,13 +591,13 @@ statement: if_statement OR expression_statement OR return_statement
 if_statement: if (expression) @{ statements @} else @{ statements @}
 
 The first lot of statements is executed if the expression is
-non-zero. Otherwise the second lot of statements is executed. Either
+nonzero. Otherwise the second lot of statements is executed. Either
 list of statements may be empty, but both sets of braces and the else must be present. 
 
 @smallexample
 if (a==b) 
 @{
-// nothing
+// @r{nothing}
 @}
 else
 @{
@@ -628,8 +618,9 @@ be absent, and if the function is not void the expression must be
 present.
 
 @item
-expression: variable OR integer_constant OR expression+expression OR expression-expression
- OR expression==expression OR (expression) OR variable=expression OR function_call
+expression: variable OR integer_constant OR expression+expression
+OR expression-expression OR expression==expression OR (expression)
+OR variable=expression OR function_call
 
 An expression can be a constant or a variable reference or a
 function_call. Expressions can be combined as a sum of two expressions
@@ -890,11 +881,12 @@ files and accepts Treelang-specific command-line options, plus some
 command-line options that are designed to cater to Treelang users
 but apply to other languages as well.
 
-@xref{G++ and GCC,,Compile C; C++; or Objective-C,GCC,Using and Porting GCC},
+@xref{G++ and GCC,,Programming Languages Supported by GCC,GCC,Using
+the GNU Compiler Collection (GCC)},
 for information on the way different languages are handled
 by the GCC compiler (@code{gcc}).
 
-You can use this, combined with the output of the @samp{GCC -v x.tree}
+You can use this, combined with the output of the @samp{gcc -v x.tree}
 command to get the options applicable to treelang. Treelang programs
 must end with the suffix @samp{.tree}.