treelang.texi
来自「理解和实践操作系统的一本好书」· TEXI 代码 · 共 1,311 行 · 第 1/3 页
TEXI
1,311 行
\input texinfo @c -*-texinfo-*-@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@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@set email-patches gcc-patches@@gcc.gnu.org @set path-treelang gcc/gcc/treelang@ifset VERSION_PACKAGE@set which-treelang @value{version-GCC} @value{VERSION_PACKAGE}@end ifset@ifclear VERSION_PACKAGE@set which-treelang @value{version-GCC}@end ifclear@set which-GCC GCC@set email-josling tej@@melbpc.org.au@set www-josling http://www.geocities.com/timjosling@c This tells @include'd files that they're part of the overall TREELANG doc@c set. (They might be part of a higher-level doc set too.)@set DOC-TREELANG@c @setfilename usetreelang.info@c @setfilename maintaintreelang.info@c To produce the full manual, use the "treelang.info" setfilename, and@c make sure the following do NOT begin with '@c' (and the @clear lines DO)@set INTERNALS@set USING@c To produce a user-only manual, use the "usetreelang.info" setfilename, and@c make sure the following does NOT begin with '@c':@c @clear INTERNALS@c To produce a maintainer-only manual, use the "maintaintreelang.info" setfilename,@c and make sure the following does NOT begin with '@c':@c @clear USING@ifset INTERNALS@ifset USING@settitle Using and Maintaining GNU Treelang@end ifset@end ifset@c seems reasonable to assume at least one of INTERNALS or USING is set...@ifclear INTERNALS@settitle Using GNU Treelang@end ifclear@ifclear USING@settitle Maintaining GNU Treelang@end ifclear@c then again, have some fun@ifclear INTERNALS@ifclear USING@settitle Doing Very Little at all with GNU Treelang@end ifclear@end ifclear@syncodeindex fn cp@syncodeindex vr cp@c %**end of header@c Cause even numbered pages to be printed on the left hand side of@c the page and odd numbered pages to be printed on the right hand@c side of the page. Using this, you can print on both sides of a@c sheet of paper and have the text on the same part of the sheet.@c The text on right hand pages is pushed towards the right hand@c margin and the text on left hand pages is pushed toward the left@c hand margin.@c (To provide the reverse effect, set bindingoffset to -0.75in.)@c @tex@c \global\bindingoffset=0.75in@c \global\normaloffset =0.75in@c @end tex@copyingCopyright @copyright{} @value{copyrights-treelang} Free Software Foundation, Inc.Permission is granted to copy, distribute and/or modify this documentunder the terms of the GNU Free Documentation License, Version 1.2 orany later version published by the Free Software Foundation; with theInvariant Sections being ``GNU General Public License'', the Front-Covertexts 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 Software development@direntry* treelang: (treelang). The GNU Treelang compiler.@end direntry@ifset INTERNALS@ifset USINGThis file documents the use and the internals of the GNU Treelang(@code{treelang}) compiler. At the moment this manual is notincorporated into the main GCC manual as it is incomplete. Itcorresponds to the @value{which-treelang} version of @code{treelang}.@end ifset@end ifset@ifclear USINGThis file documents the internals of the GNU Treelang (@code{treelang}) compiler.It corresponds to the @value{which-treelang} version of @code{treelang}.@end ifclear@ifclear INTERNALSThis file documents the use of the GNU Treelang (@code{treelang}) compiler.It corresponds to the @value{which-treelang} version of @code{treelang}.@end ifclearPublished by the Free Software Foundation51 Franklin Street, Fifth FloorBoston, MA 02110-1301 USA@insertcopying@end ifnottex@setchapternewpage odd@c @finalout@titlepage@ifset INTERNALS@ifset USING@title Using and Maintaining GNU Treelang@end ifset@end ifset@ifclear INTERNALS@title Using GNU Treelang@end ifclear@ifclear USING@title Maintaining GNU Treelang@end ifclear@versionsubtitle@author Tim Josling@page@vskip 0pt plus 1filllPublished by the Free Software Foundation @*51 Franklin Street, Fifth Floor@*Boston, MA 02110-1301, USA@*@c Last printed ??ber, 19??.@*@c Printed copies are available for $? each.@*@c ISBN ???@sp 1@insertcopying@end titlepage@page@ifnottex@node Top, Copying,, (dir)@top Introduction@cindex Introduction@ifset INTERNALS@ifset USINGThis manual documents how to run, install and maintain @code{treelang}.It also documents the features and incompatibilities in the @value{which-treelang}version of @code{treelang}.@end ifset@end ifset@ifclear INTERNALSThis manual documents how to run and install @code{treelang}.It also documents the features and incompatibilities in the @value{which-treelang}version of @code{treelang}.@end ifclear@ifclear USINGThis manual documents how to maintain @code{treelang}.It also documents the features and incompatibilities in the @value{which-treelang}version of @code{treelang}.@end ifclear@end ifnottex@menu* Copying:: * Contributors:: * GNU Free Documentation License:: * Funding:: * Getting Started:: * What is GNU Treelang?:: * Lexical Syntax:: * Parsing Syntax:: * Compiler Overview:: * TREELANG and GCC:: * Compiler:: * Other Languages:: * treelang internals:: * Open Questions:: * Bugs:: * Service:: * Projects:: * Index:: @detailmenu --- The Detailed Node Listing ---Other Languages* Interoperating with C and C++:: treelang internals* treelang files:: * treelang compiler interfaces:: * Hints and tips:: treelang compiler interfaces* treelang driver:: * treelang main compiler:: treelang main compiler* Interfacing to toplev.c:: * Interfacing to the garbage collection:: * Interfacing to the code generation code. :: Reporting Bugs* Sending Patches:: @end detailmenu@end menu@include gpl.texi@include fdl.texi@node Contributors@unnumbered Contributors to GNU Treelang@cindex contributors@cindex creditsTreelang was based on 'toy' by Richard Kenner, and also uses code fromthe GCC core code tree. Tim Josling first created the language anddocumentation, based on the GCC Fortran compiler's documentationframework. Treelang was updated to use the TreeSSA infrastructure byJames A. Morrison.@itemize @bullet@itemThe packaging and compiler portions of GNU Treelang are based largelyon the GCC compiler.@xref{Contributors,,Contributors to GCC,GCC,Using and Maintaining GCC},for more information.@itemThere is no specific run-time library for treelang, other than thestandard C runtime.@itemIt would have been difficult to build treelang without access to JoachimNadler's guide to writing a front end to GCC (written in German). Atranslation of this document into English is available via theCobolForGCC project or via the documentation links from the GCC homepage @uref{http://gcc.gnu.org}.@end itemize@include funding.texi@node Getting Started@chapter Getting Started@cindex getting started@cindex new users@cindex newbies@cindex beginnersTreelang is a sample language, useful only to help people understand howto implement a new language front end to GCC. It is not a usefullanguage in itself other than as an example or basis for building a newlanguage. Therefore only language developers are likely to have aninterest in it.This manual assumes familiarity with GCC, which you can obtain by usingit 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 by addingtreelang to the list of languages specified by @option{--enable-languages}, e.g.@: @samp{--enable-languages=all,treelang}.If you're generally curious about the future of@code{treelang}, see @ref{Projects}.If you're curious about its past,see @ref{Contributors}.To see a few of the questions maintainers of @code{treelang} have,and that you might be able to answer,see @ref{Open Questions}.@ifset USING@node What is GNU Treelang?, Lexical Syntax, Getting Started, Top@chapter What is GNU Treelang?@cindex concepts, basic@cindex basic conceptsGNU Treelang, or @code{treelang}, is designed initially as a freereplacement for, or alternative to, the 'toy' language, but which isamenable to inclusion within the GCC source tree. @code{treelang} is largely a cut down version of C, designed to showcasethe features of the GCC code generation back end. Only those featuresthat are directly supported by the GCC code generation back end areimplemented. Features are implemented in a manner which is easiest andclearest to implement. Not all or even most code generation back endfeatures are implemented. The intention is to add features incrementallyuntil most features of the GCC back end are implemented in treelang.The main features missing are structures, arrays and pointers.A sample program follows:@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);// @r{function definition}add @{ // @r{return the sum of arg1 and arg2} return arg1 + arg2;@} subtract @{ return arg3 - arg4;@}double_plus_one@{ // @r{aaa is a variable, of type integer and allocated at the start of} // @r{the function} automatic int aaa; // @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; return aaa;@}first_nonzero@{ // @r{C-like if statement} if (arg5) @{ return arg5; @} else @{ @} return arg6;@}@end smallexample@node Lexical Syntax, Parsing Syntax, What is GNU Treelang?, Top@chapter Lexical Syntax@cindex Lexical SyntaxTreelang programs consist of whitespace, comments, keywords and names.@itemize @bullet@itemWhitespace consists of the space character, a tab, and the end of linecharacter. Line terminations are as defined by thestandard C library. Whitespace is ignored except within comments,and where it separates parts of the program. In the example below, A andB are two separate names separated by whitespace. @smallexampleA B@end smallexample@itemComments consist of @samp{//} followed by any characters up to the endof the line. C style comments (/* */) are not supported. For example,the assignment below is followed by a not very helpful comment.@smallexamplex = 1; // @r{Set X to 1}@end smallexample@itemKeywords consist of any of the following reserved words or symbols:@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 inan 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, or unary plus for signed literals@item - subtraction, or unary minus for signed literals@item = assignment@item ==equality test@item ifbegin IF statement@item elsebegin 'else' portion of IF statement@item static
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?