Commit 7cd4527e by Arnaud Charlet Committed by Arnaud Charlet

re PR ada/14150 (Ada documentation out of date)

	PR ada/14150
	* Make-lang.in: Clean up generation of documentation

	* gnat-style.texi, gnat_rm.texi, ug_words: Resync with AdaCore version

	* xgnatug.adb: Removed, replaced by xgnatugn.adb

	* xgnatugn.adb: Replaces xgnatug.adb

	* gnat_ug.texi: Removed, replaced by gnat_ugn.texi

	* gnat_ugn.texi: Replaces gnat_ug.texi. Resync with AdaCore version

	* gnat_ug_unx.texi, gnat_ug_vms.texi, gnat_ug_vxw.texi,
	gnat_ug_wnt.texi: Removed.

From-SVN: r80308
parent 1c19eacc
2004-04-01 Arnaud Charlet <charlet@act-europe.fr> 2004-04-01 Arnaud Charlet <charlet@act-europe.fr>
PR ada/14150
* Make-lang.in: Clean up generation of documentation
* gnat-style.texi, gnat_rm.texi, ug_words: Resync with AdaCore version
* xgnatug.adb: Removed, replaced by xgnatugn.adb
* xgnatugn.adb: Replaces xgnatug.adb
* gnat_ug.texi: Removed, replaced by gnat_ugn.texi
* gnat_ugn.texi: Replaces gnat_ug.texi. Resync with AdaCore version
* gnat_ug_unx.texi, gnat_ug_vms.texi, gnat_ug_vxw.texi,
gnat_ug_wnt.texi: Removed.
2004-04-01 Arnaud Charlet <charlet@act-europe.fr>
* utils2.c: Update copyright notice. * utils2.c: Update copyright notice.
2004-04-01 Robert Dewar <dewar@gnat.com> 2004-04-01 Robert Dewar <dewar@gnat.com>
......
...@@ -451,47 +451,17 @@ ada.tags: force ...@@ -451,47 +451,17 @@ ada.tags: force
# Generate documentation. # Generate documentation.
#
# The generated Texinfo files for the User Guide are stored in $(srcdir).
#
# ??? There is some ugliness here in that the aforementioned generated
# documentation files depend on executables in the build tree. Since the
# source directory is supposed to be read only it is difficult to ship a source
# tree with the documentation already generated such that "make" will not
# attempt to rebuild them.
#
# As a compromise this only will execute with --enable-maintainer mode.
#
# If gnu make 3.80 is ever made a requirement to build, then this could be
# avoided using an order-only dependency:
#
# $(srcdir)/ada/gnat_ug_unx.texi: \
# ada/gnat_ug.texi ada/ug_words | ada/doctools/xgnatug$(build_exeext)
ifndef MAINT ada/doctools/xgnatugn$(build_exeext): ada/xgnatugn.adb
ada/doctools/xgnatug$(build_exeext): ada/xgnatug.adb
-$(MKDIR) ada/doctools -$(MKDIR) ada/doctools
cp $^ ada/doctools $(CP) $^ ada/doctools
cd ada/doctools && gnatmake -q xgnatug cd ada/doctools && gnatmake -q xgnatugn
$(srcdir)/ada/gnat_ug_unx.texi : ada/doctools/xgnatug$(build_exeext) \ doc/gnat_ugn_unw.texi : ada/doctools/xgnatugn$(build_exeext) \
$(srcdir)/ada/gnat_ug.texi $(srcdir)/ada/ug_words $(srcdir)/ada/gnat_ugn.texi $(srcdir)/ada/ug_words
ada/doctools/xgnatug unx $(srcdir)/ada/gnat_ug.texi $(srcdir)/ada/ug_words $(srcdir)/ada/gnat_ug_unx.texi ada/doctools/xgnatugn unw $(srcdir)/ada/gnat_ugn.texi $(srcdir)/ada/ug_words doc/gnat_ugn_unw.texi
$(srcdir)/ada/gnat_ug_vms.texi : ada/doctools/xgnatug$(build_exeext) \ doc/gnat_ugn_unw.info: doc/gnat_ugn_unw.texi \
$(srcdir)/ada/gnat_ug.texi $(srcdir)/ada/ug_words
ada/doctools/xgnatug vms $(srcdir)/ada/gnat_ug.texi $(srcdir)/ada/ug_words $(srcdir)/ada/gnat_ug_vms.texi
$(srcdir)/ada/gnat_ug_vxw.texi : ada/doctools/xgnatug$(build_exeext) \
$(srcdir)/ada/gnat_ug.texi $(srcdir)/ada/ug_words
ada/doctools/xgnatug vxworks $(srcdir)/ada/gnat_ug.texi $(srcdir)/ada/ug_words $(srcdir)/ada/gnat_ug_vxw.texi
$(srcdir)/ada/gnat_ug_wnt.texi : ada/doctools/xgnatug$(build_exeext) \
$(srcdir)/ada/gnat_ug.texi $(srcdir)/ada/ug_words
ada/doctools/xgnatug wnt $(srcdir)/ada/gnat_ug.texi $(srcdir)/ada/ug_words $(srcdir)/ada/gnat_ug_wnt.texi
endif
doc/gnat_ug_unx.info: $(srcdir)/ada/gnat_ug_unx.texi \
$(docdir)/include/fdl.texi $(docdir)/include/gcc-common.texi $(docdir)/include/fdl.texi $(docdir)/include/gcc-common.texi
if [ x$(BUILD_INFO) = xinfo ]; then \ if [ x$(BUILD_INFO) = xinfo ]; then \
rm -f $(@)*; \ rm -f $(@)*; \
...@@ -499,30 +469,6 @@ doc/gnat_ug_unx.info: $(srcdir)/ada/gnat_ug_unx.texi \ ...@@ -499,30 +469,6 @@ doc/gnat_ug_unx.info: $(srcdir)/ada/gnat_ug_unx.texi \
-I$(srcdir)/ada -o $@ $<; \ -I$(srcdir)/ada -o $@ $<; \
else true; fi else true; fi
doc/gnat_ug_vms.info: $(srcdir)/ada/gnat_ug_vms.texi \
$(docdir)/include/fdl.texi $(docdir)/include/gcc-common.texi
if [ x$(BUILD_INFO) = xinfo ]; then \
rm -f $(@)*; \
$(MAKEINFO) $(MAKEINFOFLAGS) -I$(docdir)/include \
-I$(srcdir)/ada -o $@ $<; \
else true; fi
doc/gnat_ug_vxw.info: $(srcdir)/ada/gnat_ug_vxw.texi \
$(docdir)/include/fdl.texi $(docdir)/include/gcc-common.texi
if [ x$(BUILD_INFO) = xinfo ]; then \
rm -f $(@)*; \
$(MAKEINFO) $(MAKEINFOFLAGS) -I$(docdir)/include \
-I$(srcdir)/ada -o $@ $<; \
else true; fi
doc/gnat_ug_wnt.info: $(srcdir)/ada/gnat_ug_wnt.texi \
$(docdir)/include/fdl.texi $(docdir)/include/gcc-common.texi
if [ x$(BUILD_INFO) = xinfo ]; then \
rm -f $(@)*; \
$(MAKEINFO) $(MAKEINFOFLAGS) -I$(docdir)/include \
-I$(srcdir)/ada -o$@ $<; \
else true; fi
doc/gnat_rm.info: ada/gnat_rm.texi $(docdir)/include/fdl.texi \ doc/gnat_rm.info: ada/gnat_rm.texi $(docdir)/include/fdl.texi \
$(docdir)/include/gcc-common.texi $(docdir)/include/gcc-common.texi
if [ x$(BUILD_INFO) = xinfo ]; then \ if [ x$(BUILD_INFO) = xinfo ]; then \
...@@ -538,38 +484,22 @@ doc/gnat-style.info: ada/gnat-style.texi $(docdir)/include/fdl.texi ...@@ -538,38 +484,22 @@ doc/gnat-style.info: ada/gnat-style.texi $(docdir)/include/fdl.texi
-I$(srcdir)/ada -o $@ $<; \ -I$(srcdir)/ada -o $@ $<; \
else true; fi else true; fi
ADA_INFOFILES = doc/gnat_ug_vms.info doc/gnat_ug_wnt.info \ ADA_INFOFILES = doc/gnat_ugn_unw.info \
doc/gnat_ug_unx.info doc/gnat_ug_vxw.info \
doc/gnat_rm.info doc/gnat-style.info doc/gnat_rm.info doc/gnat-style.info
ada.info: $(ADA_INFOFILES) ada.info: $(ADA_INFOFILES)
ada.srcinfo: $(ADA_INFOFILES) ada.srcinfo: $(ADA_INFOFILES)
-cp -p $^ $(srcdir)/doc -$(CP) $^ $(srcdir)/doc
install-info:: $(DESTDIR)$(infodir)/gnat_ug_vms.info \ install-info:: $(DESTDIR)$(infodir)/gnat_ugn_unw.info \
$(DESTDIR)$(infodir)/gnat_ug_wnt.info \
$(DESTDIR)$(infodir)/gnat_ug_unx.info \
$(DESTDIR)$(infodir)/gnat_ug_vxw.info \
$(DESTDIR)$(infodir)/gnat_rm.info \ $(DESTDIR)$(infodir)/gnat_rm.info \
$(DESTDIR)$(infodir)/gnat-style.info $(DESTDIR)$(infodir)/gnat-style.info
dvi:: doc/gnat_ug_vms.dvi doc/gnat_ug_wnt.dvi doc/gnat_ug_unx.dvi \ dvi:: doc/gnat_ugn_unw.dvi \
doc/gnat_ug_vxw.dvi doc/gnat_rm.dvi doc/gnat-style.dvi doc/gnat_rm.dvi doc/gnat-style.dvi
doc/gnat_ug_unx.dvi: $(srcdir)/ada/gnat_ug_unx.texi \
$(docdir)/include/fdl.texi $(docdir)/include/gcc-common.texi
$(TEXI2DVI) -c -I $(abs_docdir)/include -o $@ $<
doc/gnat_ug_vms.dvi: $(srcdir)/ada/gnat_ug_vms.texi \
$(docdir)/include/fdl.texi $(docdir)/include/gcc-common.texi
$(TEXI2DVI) -c -I $(abs_docdir)/include -o $@ $<
doc/gnat_ug_vxw.dvi: $(srcdir)/ada/gnat_ug_vxw.texi \
$(docdir)/include/fdl.texi $(docdir)/include/gcc-common.texi
$(TEXI2DVI) -c -I $(abs_docdir)/include -o $@ $<
doc/gnat_ug_wnt.dvi: $(srcdir)/ada/gnat_ug_wnt.texi \ doc/gnat_ugn_unw.dvi: doc/gnat_ugn_unw.texi \
$(docdir)/include/fdl.texi $(docdir)/include/gcc-common.texi $(docdir)/include/fdl.texi $(docdir)/include/gcc-common.texi
$(TEXI2DVI) -c -I $(abs_docdir)/include -o $@ $< $(TEXI2DVI) -c -I $(abs_docdir)/include -o $@ $<
......
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
@c o @c o
@c G N A T C O D I N G S T Y L E o @c G N A T C O D I N G S T Y L E o
@c o @c o
@c o @c Copyright (C) 1992-2003 Ada Core Technologies, Inc. o
@c Copyright (C) 1992-2001 Ada Core Technologies, Inc. o
@c o @c o
@c GNAT is free software; you can redistribute it and/or modify it under o @c GNAT is free software; you can redistribute it and/or modify it under o
@c terms of the GNU General Public License as published by the Free Soft- o @c terms of the GNU General Public License as published by the Free Soft- o
...@@ -24,7 +23,11 @@ ...@@ -24,7 +23,11 @@
@c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
@setfilename gnat-style.info @setfilename gnat-style.info
@settitle GNAT Coding Style @settitle GNAT Coding Style
@setchapternewpage odd
@dircategory Programming @dircategory Programming
@direntry @direntry
* gnat-style: (gnat-style). GNAT Coding Style * gnat-style: (gnat-style). GNAT Coding Style
...@@ -35,24 +38,63 @@ ...@@ -35,24 +38,63 @@
@end macro @end macro
@c %**end of header @c %**end of header
@ifinfo
@center GNAT Coding Style
@center A guide for GNAT developers
Copyright (C) 1992-2001 Ada Core Technologies, Inc.
@end ifinfo
@titlepage @titlepage
@sp 10 @sp 10
@title GNAT Coding Style @title GNAT Coding Style
@subtitle A guide for GNAT developers @flushright
@titlefont{A Guide for GNAT Developers}
@end flushright
@sp 2
@subtitle GNAT, The GNU Ada 95 Compiler
@subtitle Document revision level $Revision: 1.8 $
@subtitle Date: $Date: 2003/05/24 21:29:30 $
@author Ada Core Technologies, Inc. @author Ada Core Technologies, Inc.
@page
@vskip 0pt plus 1filll
Copyright @copyright{} 1995-2003, Free Software Foundation
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 Free Documentation License'', with the
Front-Cover Texts being
``GNAT Coding Style'' and ``A Guide for GNAT Developers'',
and with no Back-Cover Texts.
A copy of the license is included in the section entitled
``GNU Free Documentation License''.
@end titlepage @end titlepage
@raisesections @raisesections
@node Top, General, , (dir) @node Top, General, , (dir)
@comment node-name, next, previous, up @comment node-name, next, previous, up
@ifinfo
@noindent
GNAT Coding Style@*
A Guide for GNAT Developers
@sp 2
@noindent
GNAT, The GNU Ada 95 Compiler@*
Document revision level $Revision: 1.8 $@*
Date: $Date: 2003/05/24 21:29:30 $
@noindent
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 Free Documentation License'', with the
Front-Cover Texts being
``GNAT Coding Style'' and ``A Guide for GNAT Developers''
and with no Back-Cover Texts.
A copy of the license is included in the section entitled
``GNU Free Documentation License''.
@end ifinfo
@menu @menu
* General:: * General::
* Lexical Elements:: * Lexical Elements::
...@@ -62,6 +104,8 @@ ...@@ -62,6 +104,8 @@
* Subprograms:: * Subprograms::
* Packages:: * Packages::
* Program Structure:: * Program Structure::
* GNU Free Documentation License::
* Index::
@end menu @end menu
@c ------------------------------------------------------------------------- @c -------------------------------------------------------------------------
...@@ -75,31 +119,40 @@ readability of the code. This document has been written to help ...@@ -75,31 +119,40 @@ readability of the code. This document has been written to help
maintain this consistent style, while having a large group of developers maintain this consistent style, while having a large group of developers
work on the compiler. work on the compiler.
@noindent
For the coding style in the C parts of the compiler and run time, For the coding style in the C parts of the compiler and run time,
see the GNU Coding Guidelines. see the GNU Coding Guidelines.
@noindent This document is structured after the @cite{Ada Reference Manual}.
This document is structured after the Ada Reference manual.
Those familiar with that document should be able to quickly Those familiar with that document should be able to quickly
lookup style rules for particular constructs. lookup style rules for particular constructs.
@c ------------------------------------------------------------------------- @c -------------------------------------------------------------------------
@node Lexical Elements, Declarations and Types, General, Top @node Lexical Elements, Declarations and Types, General, Top
@section Lexical Elements @section Lexical Elements
@c ------------------------------------------------------------------------- @c -------------------------------------------------------------------------
@cindex Lexical elements
@subsection Character Set and Separators @subsection Character Set and Separators
@c ------------------------------------------------------------------------- @c -------------------------------------------------------------------------
@cindex Character set
@cindex ASCII
@cindex Separators
@cindex End-of-line
@cindex Line length
@cindex Indentation
@itemize @bullet @itemize @bullet
@item @item
The character set used should be plain 7-bit ASCII@. The character set used should be plain 7-bit ASCII@.
The only separators allowed are space and the end-of-line sequence. The only separators allowed are space and the end-of-line sequence.
No other control character or format effector (such as HT, VT, FF) No other control character or format effector (such as @code{HT},
@code{VT}, @code{FF})
should be used. should be used.
The normal end-of-line sequence is used, which may be LF, CR/LF or CR, The normal end-of-line sequence is used, which may be
depending on the host system. An optional SUB (16#1A#) may be present as the @code{LF}, @code{CR/LF} or @code{CR},
depending on the host system. An optional @code{SUB}
(@code{16#1A#}) may be present as the
last character in the file on hosts using that character as file terminator. last character in the file on hosts using that character as file terminator.
@item @item
...@@ -113,24 +166,31 @@ separator. ...@@ -113,24 +166,31 @@ separator.
Lines must not have trailing blanks. Lines must not have trailing blanks.
@item @item
Indentation is 3 characters per level for if statements, loops, case Indentation is 3 characters per level for @code{if} statements, loops, and
statements. For exact information on required spacing between lexical @code{case} statements.
For exact information on required spacing between lexical
elements, see file @file{style.adb}. elements, see file @file{style.adb}.
@cindex @file{style.adb} file
@end itemize @end itemize
@subsection Identifiers @subsection Identifiers
@c ------------------------------------------------------------------------- @c -------------------------------------------------------------------------
@itemize @bullet @itemize @bullet
@cindex Identifiers
@item @item
Identifiers will start with an upper case letter, and each letter following Identifiers will start with an upper case letter, and each letter following
an underscore will be upper case. Short acronyms may be all upper case. an underscore will be upper case.
@cindex Casing (for identifiers)
Short acronyms may be all upper case.
All other letters are lower case. All other letters are lower case.
An exception is for identifiers matching a foreign language. In particular, An exception is for identifiers matching a foreign language. In particular,
we use all lower case where appropriate for C@. we use all lower case where appropriate for C@.
@item @item
Use underscores to separate words in an identifier. Use underscores to separate words in an identifier.
@cindex Underscores
@item Try to limit your use of abbreviations in identifiers. @item Try to limit your use of abbreviations in identifiers.
It is ok to make a few abbreviations, explain what they mean, and then It is ok to make a few abbreviations, explain what they mean, and then
...@@ -139,22 +199,25 @@ example is the @code{ALI} word which stands for Ada Library ...@@ -139,22 +199,25 @@ example is the @code{ALI} word which stands for Ada Library
Information and is by convention always written in upper-case when Information and is by convention always written in upper-case when
used in entity names. used in entity names.
@smallexample @smallexample @c adanocomment
procedure Find_ALI_Files; procedure Find_ALI_Files;
@end smallexample @end smallexample
@item @item
Don't use the variable @samp{I}, use @samp{J} instead, @samp{I} is too Don't use the variable name @code{I}, use @code{J} instead; @code{I} is too
easily mixed up with @samp{1} in some fonts. Similarly don't use the easily confused with @code{1} in some fonts. Similarly don't use the
variable @samp{O}, which is too easily mixed up with the number @samp{0}. variable @code{O}, which is too easily mistaken for the number @code{0}.
@end itemize @end itemize
@subsection Numeric Literals @subsection Numeric Literals
@c ------------------------------------------------------------------------- @c -------------------------------------------------------------------------
@cindex Numeric literals
@itemize @bullet @itemize @bullet
@item @item
Numeric literals should include underscores where helpful for Numeric literals should include underscores where helpful for
readability. readability.
@cindex Underscores
@smallexample @smallexample
1_000_000 1_000_000
...@@ -165,77 +228,89 @@ readability. ...@@ -165,77 +228,89 @@ readability.
@subsection Reserved Words @subsection Reserved Words
@c ------------------------------------------------------------------------- @c -------------------------------------------------------------------------
@cindex Reserved words
@itemize @bullet @itemize @bullet
@item @item
Reserved words use all lower case. Reserved words use all lower case.
@cindex Casing (for reserved words)
@smallexample @smallexample @c adanocomment
return else return else
@end smallexample @end smallexample
@item @item
The words @samp{Access}, @samp{Delta} and @samp{Digits} are The words @code{Access}, @code{Delta} and @code{Digits} are
capitalized when used as @syntax{attribute_designator}. capitalized when used as @syntax{attribute_designator}.
@end itemize @end itemize
@subsection Comments @subsection Comments
@c ------------------------------------------------------------------------- @c -------------------------------------------------------------------------
@cindex Comments
@itemize @bullet @itemize @bullet
@item @item
Comment start with @samp{-- } (i.e.@: @samp{--} followed by two spaces). A comment starts with @code{--} followed by two spaces).
The only exception to this rule (i.e.@: one space is tolerated) is when the The only exception to this rule (i.e.@: one space is tolerated) is when the
comment ends with @samp{ --}. comment ends with a single space followed by @code{--}.
It also accepted to have only one space between @samp{--} and the start It is also acceptable to have only one space between @code{--} and the start
of the comment when the comment is at the end of a line, of the comment when the comment is at the end of a line,
after some Ada code. after some Ada code.
@item @item
Every sentence in a comment should start with an upper-case letter (including Every sentence in a comment should start with an upper-case letter (including
the first letter of the comment). the first letter of the comment).
@cindex Casing (in comments)
@item @item
When declarations are commented with ``hanging'' comments, i.e.@: When declarations are commented with ``hanging'' comments, i.e.@:
comments after the declaration, there is no blank line before the comments after the declaration, there is no blank line before the
comment, and if it is absolutely necessary to have blank lines within comment, and if it is absolutely necessary to have blank lines within
the comments these blank lines @emph{do} have a @samp{--} (unlike the the comments these blank lines @emph{do} have a @code{--} (unlike the
normal rule, which is to use entirely blank lines for separating normal rule, which is to use entirely blank lines for separating
comment paragraphs). The comment start at same level of indentation comment paragraphs). The comment starts at same level of indentation
as code they are commenting. as code it is commenting.
@cindex Blank lines (in comments)
@cindex Indentation
@smallexample @smallexample @c adanocomment
z : Integer; z : Integer;
-- @r{Integer value for storing value of} z -- Integer value for storing value of z
-- --
-- @r{The previous line was a blank line.} -- The previous line was a blank line.
@end smallexample @end smallexample
@item @item
Comments that are dubious or incomplete or comment on possibly Comments that are dubious or incomplete, or that comment on possibly
wrong or incomplete code should be preceded or followed by @samp{???}@. wrong or incomplete code, should be preceded or followed by @code{???}@.
@item @item
Comments in a subprogram body must generally be surrounded by blank lines, Comments in a subprogram body must generally be surrounded by blank lines.
except after a @samp{begin}: An exception is a comment that follows a line containing a single keyword
(@code{begin}, @code{else}, @code{loop}):
@smallexample @smallexample @c adanocomment
@group
begin begin
-- @r{Comment for the next statement} -- Comment for the next statement
A := 5; A := 5;
-- @r{Comment for the B statement} -- Comment for the B statement
B := 6; B := 6;
end;
@end group
@end smallexample @end smallexample
@item @item
In sequences of statements, comments at the end of the lines should be In sequences of statements, comments at the end of the lines should be
aligned. aligned.
@cindex Alignment (in comments)
@smallexample @smallexample @c adanocomment
My_Identifier := 5; -- @r{First comment} My_Identifier := 5; -- First comment
Other_Id := 6; -- @r{Second comment} Other_Id := 6; -- Second comment
@end smallexample @end smallexample
@item @item
...@@ -244,7 +319,7 @@ period. Comments taking more than a line are punctuated in the normal ...@@ -244,7 +319,7 @@ period. Comments taking more than a line are punctuated in the normal
manner. manner.
@item @item
Comments should focus on why instead of what. Comments should focus on @emph{why} instead of @emph{what}.
Descriptions of what subprograms do go with the specification. Descriptions of what subprograms do go with the specification.
@item @item
...@@ -254,20 +329,22 @@ depend on the names of things. The names are supplementary, not ...@@ -254,20 +329,22 @@ depend on the names of things. The names are supplementary, not
sufficient, as comments. sufficient, as comments.
@item @item
Do NOT put two spaces after periods in comments. @emph{Do not} put two spaces after periods in comments.
@end itemize @end itemize
@c ------------------------------------------------------------------------- @c -------------------------------------------------------------------------
@node Declarations and Types, Expressions and Names, Lexical Elements,Top @node Declarations and Types, Expressions and Names, Lexical Elements,Top
@section Declarations and Types @section Declarations and Types
@c ------------------------------------------------------------------------- @c -------------------------------------------------------------------------
@cindex Declarationa and Types
@itemize @bullet @itemize @bullet
@item @item
In entity declarations, colons must be surrounded by spaces. Colons In entity declarations, colons must be surrounded by spaces. Colons
should be aligned. should be aligned.
@cindex Alignment (in declarations)
@smallexample @smallexample @c adanocomment
Entity1 : Integer; Entity1 : Integer;
My_Entity : Integer; My_Entity : Integer;
@end smallexample @end smallexample
...@@ -281,10 +358,11 @@ All local subprograms in a subprogram or package body should be declared ...@@ -281,10 +358,11 @@ All local subprograms in a subprogram or package body should be declared
before the first local subprogram body. before the first local subprogram body.
@item @item
Don't declare local entities that hide global entities. Do not declare local entities that hide global entities.
@cindex Hiding of outer entities
@item @item
Don't declare multiple variables in one declaration that spans lines. Do not declare multiple variables in one declaration that spans lines.
Start a new declaration on each line, instead. Start a new declaration on each line, instead.
@item @item
...@@ -303,14 +381,16 @@ one context, where comments explain their purpose. ...@@ -303,14 +381,16 @@ one context, where comments explain their purpose.
@node Expressions and Names, Statements, Declarations and Types, Top @node Expressions and Names, Statements, Declarations and Types, Top
@section Expressions and Names @section Expressions and Names
@c ------------------------------------------------------------------------- @c -------------------------------------------------------------------------
@cindex Expressions and names
@itemize @bullet @itemize @bullet
@item @item
Every operator must be surrounded by spaces, except for the Every operator must be surrounded by spaces, except for the
exponentiation operator. exponentiation operator.
@cindex Operators
@smallexample @smallexample @c adanocomment
E := A * B**2 + 3 * (C - D); E := A * B**2 + 3 * (C - D);
@end smallexample @end smallexample
...@@ -320,7 +400,8 @@ When folding a long line, fold before an operator, not after. ...@@ -320,7 +400,8 @@ When folding a long line, fold before an operator, not after.
@item @item
Use parentheses where they clarify the intended association of operands Use parentheses where they clarify the intended association of operands
with operators: with operators:
@smallexample @cindex Parenthesization of expressions
@smallexample @c adanocomment
(A / B) * C (A / B) * C
@end smallexample @end smallexample
@end itemize @end itemize
...@@ -329,9 +410,12 @@ with operators: ...@@ -329,9 +410,12 @@ with operators:
@node Statements, Subprograms, Expressions and Names, Top @node Statements, Subprograms, Expressions and Names, Top
@section Statements @section Statements
@c ------------------------------------------------------------------------- @c -------------------------------------------------------------------------
@cindex Statements
@subsection Simple and Compound Statements @subsection Simple and Compound Statements
@c ------------------------------------------------------------------------- @c -------------------------------------------------------------------------
@cindex Simple and compound statements
@itemize @bullet @itemize @bullet
@item @item
Use only one statement or label per line. Use only one statement or label per line.
...@@ -342,13 +426,17 @@ groups or separated from surrounding code using a blank line. ...@@ -342,13 +426,17 @@ groups or separated from surrounding code using a blank line.
@subsection If Statements @subsection If Statements
@c ------------------------------------------------------------------------- @c -------------------------------------------------------------------------
@cindex @code{if} statement
@itemize @bullet @itemize @bullet
@item @item
When the @samp{if}, @samp{elsif} or @samp{else} keywords fit on the When the @code{if}, @code{elsif} or @code{else} keywords fit on the
same line with the condition and the @samp{then} keyword, then the same line with the condition and the @code{then} keyword, then the
statement is formatted as follows: statement is formatted as follows:
@cindex Alignment (in an @code{if} statement)
@smallexample @smallexample @c adanocomment
@group
if @var{condition} then if @var{condition} then
... ...
elsif @var{condition} then elsif @var{condition} then
...@@ -356,63 +444,81 @@ statement is formatted as follows: ...@@ -356,63 +444,81 @@ statement is formatted as follows:
else else
... ...
end if; end if;
@end group
@end smallexample @end smallexample
@noindent @noindent
When the above layout is not possible, @samp{then} should be aligned When the above layout is not possible, @code{then} should be aligned
with @samp{if}, and conditions should preferably be split before an with @code{if}, and conditions should preferably be split before an
@samp{and} or @samp{or} keyword a follows: @code{and} or @code{or} keyword a follows:
@smallexample @smallexample @c adanocomment
@group
if @var{long_condition_that_has_to_be_split} if @var{long_condition_that_has_to_be_split}
and then @var{continued_on_the_next_line} and then @var{continued_on_the_next_line}
then then
... ...
end if; end if;
@end group
@end smallexample @end smallexample
@noindent @noindent
The @samp{elsif}, @samp{else} and @samp{end if} always line up with The @code{elsif}, @code{else} and @code{end if} always line up with
the @samp{if} keyword. The preferred location for splitting the line the @code{if} keyword. The preferred location for splitting the line
is before @samp{and} or @samp{or}. The continuation of a condition is is before @code{and} or @code{or}. The continuation of a condition is
indented with two spaces or as many as needed to make nesting clear. indented with two spaces or as many as needed to make nesting clear.
As exception, if conditions are closely related either of the As an exception, if conditions are closely related either of the
following is allowed: following is allowed:
@smallexample @smallexample
@group
if x = lakdsjfhlkashfdlkflkdsalkhfsalkdhflkjdsahf if x = lakdsjfhlkashfdlkflkdsalkhfsalkdhflkjdsahf
or else or else
x = asldkjhalkdsjfhhfd x = asldkjhalkdsjfhhfd
or else or else
x = asdfadsfadsf x = asdfadsfadsf
then then
...
end if;
@end group
@group
if x = lakdsjfhlkashfdlkflkdsalkhfsalkdhflkjdsahf or else if x = lakdsjfhlkashfdlkflkdsalkhfsalkdhflkjdsahf or else
x = asldkjhalkdsjfhhfd or else x = asldkjhalkdsjfhhfd or else
x = asdfadsfadsf x = asdfadsfadsf
then then
...
end if;
@end group
@end smallexample @end smallexample
@item @item
Conditions should use short-circuit forms (@samp{and then}, Conditions should use short-circuit forms (@code{and then},
@samp{or else}). @code{or else}).
@cindex Short-circuit forms
@item @item
Complex conditions in if statements are indented two characters: Complex conditions in @code{if} statements are indented two characters:
@cindex Indentation (in @code{if} statements)
@smallexample @smallexample @c adanocomment
@group
if @var{this_complex_condition} if @var{this_complex_condition}
and then @var{that_other_one} and then @var{that_other_one}
and then @var{one_last_one} and then @var{one_last_one}
then then
... ...
end if;
@end group
@end smallexample @end smallexample
@item @item
Every @samp{if} block is preceded and followed by a blank line, except Every @code{if} block is preceded and followed by a blank line, except
where it begins or ends a @syntax{sequence_of_statements}. where it begins or ends a @syntax{sequence_of_statements}.
@cindex Blank lines (in an @code{if} statement)
@smallexample @smallexample @c adanocomment
@group
A := 5; A := 5;
if A = 5 then if A = 5 then
...@@ -420,77 +526,93 @@ where it begins or ends a @syntax{sequence_of_statements}. ...@@ -420,77 +526,93 @@ where it begins or ends a @syntax{sequence_of_statements}.
end if; end if;
A := 6; A := 6;
@end group
@end smallexample @end smallexample
@end itemize @end itemize
@subsection Case Statements @subsection Case Statements
@itemize @bullet @cindex @code{case} statements
@itemize @bullet
@item @item
Layout is as below. For long case statements, the extra indentation Layout is as below. For long @code{case} statements, the extra indentation
can be saved by aligning the when clauses with the opening case. can be saved by aligning the @code{when} clauses with the opening @code{case}.
@smallexample @smallexample @c adanocomment
@group
case @var{expression} is case @var{expression} is
when @var{condition} => when @var{condition} =>
... ...
when @var{condition} => when @var{condition} =>
... ...
end case; end case;
@end group
@end smallexample @end smallexample
@end itemize @end itemize
@subsection Loop Statements @subsection Loop Statements
@itemize @bullet @cindex Loop statements
@itemize @bullet
@noindent @noindent
When possible, have @samp{for} or @samp{while} on one line with the When possible, have @code{for} or @code{while} on one line with the
condition and the @samp{loop} keyword. condition and the @code{loop} keyword.
@smallexample @smallexample @c adanocomment
@group
for J in S'Range loop for J in S'Range loop
... ...
end loop; end loop;
@end group
@end smallexample @end smallexample
@noindent @noindent
If the condition is too long, split the condition (see ``If If the condition is too long, split the condition (see ``If
statements'' above) and align @samp{loop} with the @samp{for} or statements'' above) and align @code{loop} with the @code{for} or
@samp{while} keyword. @code{while} keyword.
@cindex Alignment (in a loop statement)
@smallexample @smallexample @c adanocomment
@group
while @var{long_condition_that_has_to_be_split} while @var{long_condition_that_has_to_be_split}
and then @var{continued_on_the_next_line} and then @var{continued_on_the_next_line}
loop loop
... ...
end loop; end loop;
@end group
@end smallexample @end smallexample
@noindent @noindent
If the @syntax{loop_statement} has an identifier, it is laid out as follows: If the @syntax{loop_statement} has an identifier, it is laid out as follows:
@smallexample @smallexample @c adanocomment
@group
Outer : while not @var{condition} loop Outer : while not @var{condition} loop
... ...
end Outer; end Outer;
@end group
@end smallexample @end smallexample
@end itemize @end itemize
@subsection Block Statements @subsection Block Statements
@itemize @bullet @cindex Block statement
@itemize @bullet
@item @item
The @samp{declare} (optional), @samp{begin} and @samp{end} statements The @code{declare} (optional), @code{begin} and @code{end} words
are aligned, except when the @syntax{block_statement} is named. There are aligned, except when the @syntax{block_statement} is named. There
is a blank line before the @samp{begin} keyword: is a blank line before the @code{begin} keyword:
@cindex Alignment (in a block statement)
@smallexample @smallexample @c adanocomment
@group
Some_Block : declare Some_Block : declare
... ...
begin begin
... ...
end Some_Block; end Some_Block;
@end group
@end smallexample @end smallexample
@end itemize @end itemize
...@@ -499,61 +621,104 @@ is a blank line before the @samp{begin} keyword: ...@@ -499,61 +621,104 @@ is a blank line before the @samp{begin} keyword:
@node Subprograms, Packages, Statements, Top @node Subprograms, Packages, Statements, Top
@section Subprograms @section Subprograms
@c ------------------------------------------------------------------------- @c -------------------------------------------------------------------------
@cindex Subprograms
@subsection Subprogram Declarations @subsection Subprogram Declarations
@c ------------------------------------------------------------------------- @c -------------------------------------------------------------------------
@itemize @bullet @itemize @bullet
@item @item
Do not write the @samp{in} for parameters, especially in functions: Do not write the @code{in} for parameters, especially in functions:
@smallexample @smallexample @c adanocomment
function Length (S : String) return Integer; function Length (S : String) return Integer;
@end smallexample @end smallexample
@item @item
When the declaration line for a procedure or a function is too long, fold it. When the declaration line for a procedure or a function is too long to fit
In this case, align the colons, and, for functions, the result type. the entire declaration (including the keyword procedure or function) on a
single line, then fold it, putting a single parameter on a line, aligning
the colons, as in:
@smallexample @smallexample @c adanocomment
@group
procedure Set_Heading
(Source : String;
Count : Natural;
Pad : Character := Space;
Fill : Boolean := True);
@end group
@end smallexample
@noindent
In the case of a function, if the entire spec does not fit on one line, then
the return may appear after the last parameter, as in:
@smallexample @c adanocomment
@group
function Head function Head
(Source : String; (Source : String;
Count : Natural; Count : Natural;
Pad : Character := Space) Pad : Character := Space) return String;
return String; @end group
@end smallexample @end smallexample
@item @noindent
The parameter list for a subprogram is preceded by a space: Or it may appear on its own as a separate line. This form is preferred when
putting the return on the same line as the last parameter would result in
an overlong line. The return type may optionally be aligned with the types
of the parameters (usually we do this aligning if it results only in a small
number of extra spaces, and otherwise we don't attempt to align). So two
alternative forms for the above spec are:
@smallexample @c adanocomment
@group
function Head
(Source : String;
Count : Natural;
Pad : Character := Space)
return String;
@smallexample function Head
procedure Func (A : Integer); (Source : String;
Count : Natural;
Pad : Character := Space)
return String;
@end group
@end smallexample @end smallexample
@end itemize @end itemize
@subsection Subprogram Bodies @subsection Subprogram Bodies
@c ------------------------------------------------------------------------- @c -------------------------------------------------------------------------
@itemize @bullet @cindex Subprogram bodies
@itemize @bullet
@item @item
The functions and procedures should always be sorted alphabetically in Function and procedure bodies should usually be sorted alphabetically. Do
a compilation unit. not attempt to sort them in some logical order by functionality. For a
sequence of subrpgroams specs, a general alphabetical sorting is also
usually appropriate, but occasionally it makes sense to group by major
function, with appropriate headers.
@item @item
All subprograms have a header giving the function name, with the following All subprograms have a header giving the function name, with the following
format: format:
@smallexample @smallexample @c adanocomment
@group
----------------- -----------------
-- My_Function -- -- My_Function --
----------------- -----------------
procedure My_Function is procedure My_Function is
begin begin
...
end My_Function;
@end group
@end smallexample @end smallexample
@noindent
Note that the name in the header is preceded by a single space, Note that the name in the header is preceded by a single space,
not two spaces as for other comments. not two spaces as for other comments.
...@@ -561,18 +726,26 @@ not two spaces as for other comments. ...@@ -561,18 +726,26 @@ not two spaces as for other comments.
Every subprogram body must have a preceding @syntax{subprogram_declaration}. Every subprogram body must have a preceding @syntax{subprogram_declaration}.
@item @item
If there any declarations in a subprogram, the @samp{begin} keyword is @cindex Blank lines (in subprogram bodies)
preceded by a blank line. A sequence of declarations may optionally be separated from the following
begin by a blank line. Just as we optionally allow blank lines in general
between declarations, this blank line should be present only if it improves
readability. Generally we avoid this blank line if the declarative part is
small (one or two lines) and we include it if the declarative part is long.
@item @item
If the declarations in a subprogram contain at least one nested If the declarations in a subprogram contain at least one nested
subprogram body, then just before the @samp{begin} of the enclosing subprogram body, then just before the @code{begin} of the enclosing
subprogram, there is a line: subprogram, there is a comment line and a blank line:
@smallexample @smallexample @c adanocomment
-- @r{Start of processing for @var{Enclosing_Subprogram}} @group
-- Start of processing for @var{Enclosing_Subprogram}
begin begin
...
end @var{Enclosing_Subprogram};
@end group
@end smallexample @end smallexample
@end itemize @end itemize
...@@ -581,36 +754,44 @@ subprogram, there is a line: ...@@ -581,36 +754,44 @@ subprogram, there is a line:
@node Packages, Program Structure, Subprograms, Top @node Packages, Program Structure, Subprograms, Top
@section Packages and Visibility Rules @section Packages and Visibility Rules
@c ------------------------------------------------------------------------- @c -------------------------------------------------------------------------
@cindex Packages
@itemize @bullet @itemize @bullet
@item @item
All program units and subprograms have their name at the end: All program units and subprograms have their name at the end:
@smallexample @smallexample @c adanocomment
@group
package P is package P is
... ...
end P; end P;
@end group
@end smallexample @end smallexample
@item @item
We will use the style of @samp{use}-ing @samp{with}-ed packages, with We will use the style of @code{use}-ing @code{with}-ed packages, with
the context clauses looking like: the context clauses looking like:
@cindex @code{use} clauses
@smallexample @smallexample @c adanocomment
@group
with A; use A; with A; use A;
with B; use B; with B; use B;
@end group
@end smallexample @end smallexample
@item @item
Names declared in the visible part of packages should be Names declared in the visible part of packages should be
unique, to prevent name clashes when the packages are @samp{use}d. unique, to prevent name clashes when the packages are @code{use}d.
@cindex Name clash avoidance
@smallexample @smallexample @c adanocomment
@group
package Entity is package Entity is
type Entity_Kind is ...; type Entity_Kind is ...;
... ...
end Entity; end Entity;
@end group
@end smallexample @end smallexample
@item @item
...@@ -619,28 +800,49 @@ should be the first thing in a @syntax{program_unit}. ...@@ -619,28 +800,49 @@ should be the first thing in a @syntax{program_unit}.
@end itemize @end itemize
@c ------------------------------------------------------------------------- @c -------------------------------------------------------------------------
@node Program Structure,, Packages, Top @node Program Structure, GNU Free Documentation License, Packages, Top
@section Program Structure and Compilation Issues @section Program Structure and Compilation Issues
@c ------------------------------------------------------------------------- @c -------------------------------------------------------------------------
@cindex Program structure
@itemize @bullet @itemize @bullet
@item @item
Every GNAT source file must be compiled with the @option{-gnatg} Every GNAT source file must be compiled with the @option{-gnatg}
switch to check the coding style (Note that you should look at switch to check the coding style.
(Note that you should look at
@file{style.adb} to see the lexical rules enforced by @file{style.adb} to see the lexical rules enforced by
@option{-gnatg}). @option{-gnatg}).
@cindex @option{-gnatg} option (to gcc)
@cindex @file{style.adb} file
@item @item
Each source file should contain only one compilation unit. Each source file should contain only one compilation unit.
@item @item
Filenames should be 8 characters or less followed by the @samp{.adb} Filenames should be 8 or fewer characters, followed by the @code{.adb}
extension for a body or @samp{.ads} for a spec. extension for a body or @code{.ads} for a spec.
@cindex File name length
@item @item
Unit names should be distinct when krunched to 8 characters Unit names should be distinct when ``krunch''ed to 8 characters
(see @file{krunch.ads}) and the filenames should match the unit name, (see @file{krunch.ads}) and the filenames should match the unit name,
except that they are all lower case. except that they are all lower case.
@cindex @file{krunch.ads} file
@end itemize @end itemize
@c **********************************
@c * GNU Free Documentation License *
@c **********************************
@include fdl.texi
@c GNU Free Documentation License
@cindex GNU Free Documentation License
@node Index,,GNU Free Documentation License, Top
@unnumberedsec Index
@printindex cp
@contents
@bye @bye
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Ada_Switches ^ Ada_Qualifiers
b_ ^ B_ b_ ^ B_
b~ ^ B$ b~ ^ B$
cc1 ^ CC1 cc1 ^ CC1
Cc1 ^ CC1 Cc1 ^ CC1
Default_Switches ^ Default_Qualifiers
emacs ^ EMACS emacs ^ EMACS
Emacs ^ EMACS Emacs ^ EMACS
gdb ^ GDB gdb ^ GDB
...@@ -14,6 +12,8 @@ gnatbind ^ GNAT BIND ...@@ -14,6 +12,8 @@ gnatbind ^ GNAT BIND
Gnatbind ^ GNAT BIND Gnatbind ^ GNAT BIND
gnatchop ^ GNAT CHOP gnatchop ^ GNAT CHOP
Gnatchop ^ GNAT CHOP Gnatchop ^ GNAT CHOP
gnatclean ^ GNAT CLEAN
Gnatclean ^ GNAT CLEAN
gnatelim ^ GNAT ELIM gnatelim ^ GNAT ELIM
Gnatelim ^ GNAT ELIM Gnatelim ^ GNAT ELIM
gnatf ^ GNAT XREF gnatf ^ GNAT XREF
...@@ -30,37 +30,49 @@ gnatls ^ GNAT LIST ...@@ -30,37 +30,49 @@ gnatls ^ GNAT LIST
Gnatls ^ GNAT LIST Gnatls ^ GNAT LIST
gnatmake ^ GNAT MAKE gnatmake ^ GNAT MAKE
Gnatmake ^ GNAT MAKE Gnatmake ^ GNAT MAKE
gnatname ^ GNAT NAME
Gnatname ^ GNAT NAME
gnatpp ^ GNAT PRETTY
Gnatpp ^ GNAT PRETTY
gnatprep ^ GNAT PREPROCESS gnatprep ^ GNAT PREPROCESS
Gnatprep ^ GNAT PREPROCESS Gnatprep ^ GNAT PREPROCESS
gnatpsta ^ GNAT STANDARD
Gnatpsta ^ GNAT STANDARD
gnatstub ^ GNAT STUB gnatstub ^ GNAT STUB
Gnatstub ^ GNAT STUB Gnatstub ^ GNAT STUB
gnatxref ^ GNAT XREF gnatxref ^ GNAT XREF
Gnatxref ^ GNAT XREF Gnatxref ^ GNAT XREF
gcc ^ GNAT COMPILE gcc ^ GNAT COMPILE
gcc -c ^ GNAT COMPILE gcc -c ^ GNAT COMPILE
-fno-inline ^ /INLINE=SUPPRESS
-fstack-check ^ /CHECKS=STACK
-fno-strict-aliasing ^ /OPTIMIZE=NO_STRICT_ALIASING
-gnata ^ /CHECKS=ASSERTIONS -gnata ^ /CHECKS=ASSERTIONS
-gnatb ^ /WARNINGS=BRIEF -gnatA ^ /NO_GNAT_ADC
-gnatb ^ /REPORT_ERRORS=BRIEF
-gnatc ^ /NOLOAD -gnatc ^ /NOLOAD
-gnatdc ^ /TRACE_UNITS -gnatdc ^ /TRACE_UNITS
-gnatdO ^ /REPORT_ERRORS=IMMEDIATE -gnatdO ^ /REPORT_ERRORS=IMMEDIATE
-gnatC ^ /COMPRESS_NAMES -gnatC ^ /COMPRESS_NAMES
-gnatD ^ /XDEBUG -gnatD ^ /XDEBUG
-gnatec ^ /CONFIGURATION_PRAGMAS_FILE
-gnateD ^ /SYMBOL_PREPROCESSING
-gnatef ^ /FULL_PATH_IN_BRIEF_MESSAGES
-gnatem ^ /MAPPING_FILE
-gnatep ^ /DATA_PREPROCESSING
-gnatE ^ /CHECKS=ELABORATION -gnatE ^ /CHECKS=ELABORATION
-gnatf ^ /REPORT_ERRORS=FULL -gnatf ^ /REPORT_ERRORS=FULL
-gnatF ^ /UPPERCASE_EXTERNALS -gnatF ^ /UPPERCASE_EXTERNALS
-gnatg ^ /STYLE=GNAT -gnatg ^ /STYLE_CHECKS=GNAT
-gnatG ^ /EXPAND_SOURCE -gnatG ^ /EXPAND_SOURCE
-gnatk ^ /FILE_NAME_MAX_LENGTH -gnatk ^ /FILE_NAME_MAX_LENGTH
-gnatl ^ /LIST -gnatl ^ /LIST
-gnatL ^ /LONGJMP_SETJMP
-gnatm ^ /ERROR_LIMIT -gnatm ^ /ERROR_LIMIT
-gnatm2 ^ /ERROR_LIMIT=2 -gnatm2 ^ /ERROR_LIMIT=2
-gnatn ^ /INLINE=PRAGMA -gnatn ^ /INLINE=PRAGMA
-gnatN ^ /INLINE=FULL
-gnato ^ /CHECKS=OVERFLOW -gnato ^ /CHECKS=OVERFLOW
-gnatp ^ /CHECKS=SUPPRESS_ALL -gnatp ^ /CHECKS=SUPPRESS_ALL
-gnatP ^ /POLLING_ENABLE -gnatP ^ /POLLING
-gnatr ^ /STYLE=REFERENCE_MANUAL
-gnatR ^ /REPRESENTATION_INFO -gnatR ^ /REPRESENTATION_INFO
-gnatR0 ^ /REPRESENTATION_INFO=NONE -gnatR0 ^ /REPRESENTATION_INFO=NONE
-gnatR1 ^ /REPRESENTATION_INFO=ARRAYS -gnatR1 ^ /REPRESENTATION_INFO=ARRAYS
...@@ -69,59 +81,85 @@ gcc -c ^ GNAT COMPILE ...@@ -69,59 +81,85 @@ gcc -c ^ GNAT COMPILE
-gnatq ^ /TRY_SEMANTICS -gnatq ^ /TRY_SEMANTICS
-gnatQ ^ /FORCE_ALI -gnatQ ^ /FORCE_ALI
-gnats ^ /SYNTAX_ONLY -gnats ^ /SYNTAX_ONLY
-gnatS ^ /PRINT_STANDARD
-gnatt ^ /TREE_OUTPUT -gnatt ^ /TREE_OUTPUT
-gnatu ^ /UNITS_LIST -gnatu ^ /UNITS_LIST
-gnatU ^ /UNIQUE_ERROR_TAG -gnatU ^ /UNIQUE_ERROR_TAG
-gnatv ^ /REPORT_ERRORS=VERBOSE -gnatv ^ /REPORT_ERRORS=VERBOSE
-gnatV ^ /VALIDITY_CHECKING -gnatV ^ /VALIDITY_CHECKING
-gnatV0 ^ /VALIDITY_CHECKING=NONE -gnatVa ^ /VALIDITY_CHECKING=ALL
-gnatVd ^ /VALIDITY_CHECKING=RM -gnatVc ^ /VALIDITY_CHECKING=COPIES
-gnatVf ^ /VALIDITY_CHECKING=FULL -gnatVd ^ /VALIDITY_CHECKING=DEFAULT
-gnatVD ^ /VALIDITY_CHECKING=NODEFAULT
-gnatVf ^ /VALIDITY_CHECKING=FLOATS
-gnatVi ^ /VALIDITY_CHECKING=IN_PARAMS
-gnatVm ^ /VALIDITY_CHECKING=MOD_PARAMS
-gnatVn ^ /VALIDITY_CHECKING=NONE
-gnatVo ^ /VALIDITY_CHECKING=OPERANDS
-gnatVp ^ /VALIDITY_CHECKING=PARAMETERS
-gnatVr ^ /VALIDITY_CHECKING=RETURNS
-gnatVs ^ /VALIDITY_CHECKING=SUBSCRIPTS
-gnatVt ^ /VALIDITY_CHECKING=TESTS
-gnatw ^ /WARNINGS
-gnatwa ^ /WARNINGS=OPTIONAL -gnatwa ^ /WARNINGS=OPTIONAL
-gnatwA ^ /WARNINGS=NOOPTIONAL -gnatwA ^ /WARNINGS=NOOPTIONAL
-gnatwb ^ /WARNINGS=BIASED_ROUNDING
-gnatwB ^ /WARNINGS=NOBIASED_ROUNDING
-gnatwc ^ /WARNINGS=CONDITIONALS -gnatwc ^ /WARNINGS=CONDITIONALS
-gnatwC ^ /WARNINGS=NOCONDITIONALS -gnatwC ^ /WARNINGS=NOCONDITIONALS
-gnatwd ^ /WARNINGS=IMPLICIT_DEREFERENCE -gnatwd ^ /WARNINGS=IMPLICIT_DEREFERENCE
-gnatwD ^ /WARNINGS=NOIMPLICIT_DEREFERENCE -gnatwD ^ /WARNINGS=NOIMPLICIT_DEREFERENCE
-gnatwe ^ /WARNINGS=ERROR -gnatwe ^ /WARNINGS=ERRORS
-gnatwf ^ /WARNINGS=UNREFERENCED_FORMALS -gnatwf ^ /WARNINGS=UNREFERENCED_FORMALS
-gnatwF ^ /WARNINGS=NOUNREFERENCED_FORMALS -gnatwF ^ /WARNINGS=NOUNREFERENCED_FORMALS
-gnatwg ^ /WARNINGS=UNRECOGNIZED_PRAGMAS
-gnatwG ^ /WARNINGS=NOUNRECOGNIZED_PRAGMAS
-gnatwh ^ /WARNINGS=HIDING -gnatwh ^ /WARNINGS=HIDING
-gnatwH ^ /WARNINGS=NOHIDING -gnatwH ^ /WARNINGS=NOHIDING
-gnatwi ^ /WARNINGS=IMPLEMENTATION -gnatwi ^ /WARNINGS=IMPLEMENTATION
-gnatwI ^ /WARNINGS=NOIMPLEMENTATION -gnatwI ^ /WARNINGS=NOIMPLEMENTATION
-gnatwj ^ /WARNINGS=OBSOLESCENT
-gnatwJ ^ /WARNINGS=NOOBSOLESCENT
-gnatwk ^ /WARNINGS=CONSTANT_VARIABLES
-gnatwK ^ /WARNINGS=NOCONSTANT_VARIABLES
-gnatwl ^ /WARNINGS=ELABORATION -gnatwl ^ /WARNINGS=ELABORATION
-gnatwL ^ /WARNINGS=NOELABORATION -gnatwL ^ /WARNINGS=NOELABORATION
-gnatwm ^ /WARNINGS=MODIFIED_UNREF
-gnatwM ^ /WARNINGS=NOMODIFIED_UNREF
-gnatwn ^ /WARNINGS=NORMAL
-gnatwo ^ /WARNINGS=OVERLAYS -gnatwo ^ /WARNINGS=OVERLAYS
-gnatwO ^ /WARNINGS=NOOVERLAYS -gnatwO ^ /WARNINGS=NOOVERLAYS
-gnatwp ^ /WARNINGS=INEFFECTIVE_INLINE
-gnatwP ^ /WARNINGS=NOINEFFECTIVE_INLINE
-gnatwr ^ /WARNINGS=REDUNDANT -gnatwr ^ /WARNINGS=REDUNDANT
-gnatwR ^ /WARNINGS=NOREDUNDANT -gnatwR ^ /WARNINGS=NOREDUNDANT
-gnatws ^ /WARNINGS=SUPPRESS -gnatws ^ /WARNINGS=SUPPRESS
-gnatwu ^ /WARNINGS=UNUSED -gnatwu ^ /WARNINGS=UNUSED
-gnatwU ^ /WARNINGS=NOUNUSED -gnatwU ^ /WARNINGS=NOUNUSED
-gnatwv ^ /WARNINGS=VARIABLES_UNINITIALIZED
-gnatwV ^ /WARNINGS=NOVARIABLES_UNINITIALIZED
-gnatwx ^ /WARNINGS=IMPORT_EXPORT_PRAGMAS
-gnatwX ^ /WARNINGS=NOIMPORT_EXPORT_PRAGMAS
-gnatwz ^ /WARNINGS=UNCHECKED_CONVERSIONS
-gnatwZ ^ /WARNINGS=NOUNCHECKED_CONVERSIONS
-gnatW8 ^ /WIDE_CHARACTER_ENCODING=UTF8 -gnatW8 ^ /WIDE_CHARACTER_ENCODING=UTF8
-gnatW? ^ /WIDE_CHARACTER_ENCODING=? -gnatW? ^ /WIDE_CHARACTER_ENCODING=?
-gnaty ^ /STYLE= -gnaty ^ /STYLE_CHECKS
-gnatZ ^ /ZERO_COST_EXCEPTIONS
-gnatzc ^ /DISTRIBUTION_STUBS=CALLER
-gnatzr ^ /DISTRIBUTION_STUBS=RECEIVER -gnatzr ^ /DISTRIBUTION_STUBS=RECEIVER
-gnatzs ^ /DISTRIBUTION_STUBS=SENDER
-gnat83 ^ /83 -gnat83 ^ /83
-gnat95 ^ /95
-gnatx ^ /XREF=SUPPRESS -gnatx ^ /XREF=SUPPRESS
-gnatX ^ /EXTENSIONS_ALLOWED -gnatX ^ /EXTENSIONS_ALLOWED
--RTS ^ /RUNTIME_SYSTEM --RTS ^ /RUNTIME_SYSTEM
mode_switches ^ mode_qualifiers
switch ^ qualifier switch ^ qualifier
switches ^ qualifiers switches ^ qualifiers
Switch ^ Qualifier Switch ^ Qualifier
Switches ^ Qualifiers Switches ^ Qualifiers
switch-related ^ qualifier-related
stdout ^ SYS$OUTPUT stdout ^ SYS$OUTPUT
stderr ^ SYS$ERROR stderr ^ SYS$ERROR
-bargs ^ /BINDER_QUALIFIERS -bargs ^ /BINDER_QUALIFIERS
-cargs ^ /COMPILER_QUALIFIERS -cargs ^ /COMPILER_QUALIFIERS
-largs ^ /LINKER_QUALIFIERS -largs ^ /LINKER_QUALIFIERS
-margs ^ /MAKE_QUALIFIERS
-aIDIR ^ /SOURCE_SEARCH=direc -aIDIR ^ /SOURCE_SEARCH=direc
-aODIR ^ /OBJECT_SEARCH=direc -aODIR ^ /OBJECT_SEARCH=direc
-IDIR ^ /SEARCH=direc -IDIR ^ /SEARCH=direc
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
-- -- -- --
-- GNAT SYSTEM UTILITIES -- -- GNAT SYSTEM UTILITIES --
-- -- -- --
-- X G N A T U G -- -- X G N A T U G N --
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2002 Free Software Foundation, Inc. -- -- Copyright (C) 2003-2004 Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -21,67 +21,71 @@ ...@@ -21,67 +21,71 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- This utility is used to process the source of gnat_ug.texi to make a -- This utility is used to process the source of gnat_ugn.texi to make a
-- version suitable for running through standard Texinfo processor. It takes -- version suitable for running through standard Texinfo processor. It is
-- three arguments. The first one is the target type of the manual, which -- invoked as follows:
-- can be one of:
-- -- xgnatugn <target> <in-file> <word-list> [ <out-file> [ <warnings> ] ]
-- unx GNU
-- 1. <target> is the target type of the manual, which is one of:
-- unw Unix and Windows platforms
-- vms OpenVMS -- vms OpenVMS
-- wnt Mirosoft Windows
-- vxworks Embedded Platforms -- 2. <in-file> is the file name of the Texinfo file to be
--
-- The second parameter is the file name of the Texinfo file to be
-- preprocessed. -- preprocessed.
--
-- The third parameter is the name of the word list. This file is used for -- 3. <word-list> is the name of the word list file. This file is used for
-- rewriting the VMS edition. Each line contains a word mapping: The source -- rewriting the VMS edition. Each line contains a word mapping: The source
-- word in the first column, the target words in the second column. The -- word in the first column, the target word in the second column. The
-- columns are separated by a '^' character. When preprocessing for VMS, the -- columns are separated by a '^' character. When preprocessing for VMS, the
-- first word is replaced with the second. (Words consist of letters, -- first word is replaced with the second. (Words consist of letters,
-- digits, and the four characters "?-_~". A sequence of multiple words can -- digits, and the four characters "?-_~". A sequence of multiple words can
-- be replaced if they listed in the first column, separated by a single -- be replaced if they are listed in the first column, separated by a single
-- space character. If multiple words are to be replaced, there has to be -- space character. If multiple words are to be replaced, there must be a
-- replacement for each prefix.) -- replacement for each prefix.)
--
-- The fourth parameter is the name of the output file. It defaults to -- 4. <out-file> (optional) is the name of the output file. It defaults to
-- gnat_ug_unx.texi, gnat_ug_vms.texi, gnat_ug_wnt.texi or gnat_ug_vxw.texi, -- gnat_ugn_unw.texi or gnat_ugn_vms.texi, depending on the target.
-- depending on the target.
-- -- 5. <warnings> (optional, and allowed only if <out-file> is explicit)
-- can be any string. If present, it indicates that warning messages are
-- to be output to Standard_Error. If absent, no warning messages are
-- generated.
-- The following steps are performed: -- The following steps are performed:
--
-- In VMS mode -- In VMS mode
--
-- Any occurrences of ^alpha^beta^ are replaced by beta. The sequence -- Any occurrences of ^alpha^beta^ are replaced by beta. The sequence
-- must fit on a single line, and there can only be one occurrence on a -- must fit on a single line, and there can only be one occurrence on a
-- line. -- line.
--
-- Any occurrences of a word in the Ug_Words list are replaced by the -- Any occurrences of a word in the Ug_Words list are replaced by the
-- appropriate vms equivalents. Note that replacements do not occur -- appropriate vms equivalents. Note that replacements do not occur
-- within ^alpha^beta^ sequences. -- within ^alpha^beta^ sequences.
--
-- Any occurence of [filename].extension, where extension one of the -- Any occurence of [filename].extension, where extension one of the
-- following: -- following:
--
-- "o", "ads", "adb", "ali", "ada", "atb", "ats", "adc", "c" -- "o", "ads", "adb", "ali", "ada", "atb", "ats", "adc", "c"
--
--
-- replaced by the appropriate VMS names (all upper case with .o -- replaced by the appropriate VMS names (all upper case with .o
-- replaced .OBJ). Note that replacements do not occur within -- replaced .OBJ). Note that replacements do not occur within
-- ^alpha^beta^ sequences. -- ^alpha^beta^ sequences.
--
-- In UNX, VXWORKS or WNT mode -- In UNW mode
--
-- Any occurrences of ^alpha^beta^ are replaced by alpha. The sequence -- Any occurrences of ^alpha^beta^ are replaced by alpha. The sequence
-- must fit on a single line. -- must fit on a single line.
--
-- In all modes -- In both modes
--
-- The sequence ^^^ is replaced by a single ^. This escape sequence -- The sequence ^^^ is replaced by a single ^. This escape sequence
-- must be used if the literal character ^ is to appear in the -- must be used if the literal character ^ is to appear in the
-- output. A line containing this escape sequence may not also contain -- output. A line containing this escape sequence may not also contain
-- a ^alpha^beta^ sequence. -- a ^alpha^beta^ sequence.
--
-- Recognize @ifset and @ifclear (this is because we have menu problems -- Recognize @ifset and @ifclear (this is because we have menu problems
-- if we let makeinfo handle the ifset/ifclear pairs -- if we let makeinfo handle the ifset/ifclear pairs
...@@ -92,17 +96,18 @@ with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; ...@@ -92,17 +96,18 @@ with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Strings.Maps; use Ada.Strings.Maps; with Ada.Strings.Maps; use Ada.Strings.Maps;
with Ada.Strings.Maps.Constants; use Ada.Strings.Maps.Constants; with Ada.Strings.Maps.Constants; use Ada.Strings.Maps.Constants;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Text_IO; use Ada.Text_IO;
with GNAT.Spitbol; use GNAT.Spitbol; with GNAT.Spitbol; use GNAT.Spitbol;
with GNAT.Spitbol.Table_VString; use GNAT.Spitbol.Table_VString; with GNAT.Spitbol.Table_VString; use GNAT.Spitbol.Table_VString;
procedure Xgnatug is procedure Xgnatugn is
procedure Usage; procedure Usage;
-- Print usage information. Invoked if an invalid command line is -- Print usage information. Invoked if an invalid command line is
-- encountered. -- encountered.
Output_File : File_Type; Output_File : File_Type;
-- The preprocessed output is written to this file. -- The preprocessed output is written to this file
type Input_File is record type Input_File is record
Name : VString; Name : VString;
...@@ -116,7 +121,10 @@ procedure Xgnatug is ...@@ -116,7 +121,10 @@ procedure Xgnatug is
-- Returns a line from Input and performs the necessary -- Returns a line from Input and performs the necessary
-- line-oriented checks (length, character set, trailing spaces). -- line-oriented checks (length, character set, trailing spaces).
Have_Errors : Boolean := False; Number_Of_Warnings : Natural := 0;
Number_Of_Errors : Natural := 0;
Warnings_Enabled : Boolean;
procedure Error procedure Error
(Input : Input_File; (Input : Input_File;
At_Character : Natural; At_Character : Natural;
...@@ -150,11 +158,11 @@ procedure Xgnatug is ...@@ -150,11 +158,11 @@ procedure Xgnatug is
-- It contains the Texinfo source code. Process_Source_File -- It contains the Texinfo source code. Process_Source_File
-- performs the necessary replacements. -- performs the necessary replacements.
type Target_Type is (VMS, WNT, UNX, VXWORKS); type Target_Type is (UNW, VMS);
Target : Target_Type; Target : Target_Type;
-- The target for which preprocessing is performed: VMS, Windows, -- The target for which preprocessing is performed:
-- GNU, and embedded platforms ("UNX" and "VXWORKS" are misnomers). -- UNW (Unix and Windows) or VMS
-- The Target avariable is initialized using the command line. -- The Target variable is initialized using the command line.
Valid_Characters : constant Character_Set Valid_Characters : constant Character_Set
:= To_Set (Span => (' ', '~')); := To_Set (Span => (' ', '~'));
...@@ -162,8 +170,9 @@ procedure Xgnatug is ...@@ -162,8 +170,9 @@ procedure Xgnatug is
-- file (after line breaks have been removed). Valid characters -- file (after line breaks have been removed). Valid characters
-- are all printable ASCII characters and the space character. -- are all printable ASCII characters and the space character.
Word_Characters : constant Character_Set Word_Characters : constant Character_Set :=
:= (To_Set (Ranges => (('0', '9'), ('a', 'z'), ('A', 'Z'))) (To_Set (Ranges =>
(('0', '9'), ('a', 'z'), ('A', 'Z')))
or To_Set ("?-_~")); or To_Set ("?-_~"));
-- The characters which are permitted in words. Other (valid) -- The characters which are permitted in words. Other (valid)
-- characters are assumed to be delimiters between words. Note that -- characters are assumed to be delimiters between words. Note that
...@@ -174,7 +183,7 @@ procedure Xgnatug is ...@@ -174,7 +183,7 @@ procedure Xgnatug is
-- Controls whether Xgnatug rejects superfluous space characters -- Controls whether Xgnatug rejects superfluous space characters
-- at the end of lines. -- at the end of lines.
Maximum_Line_Length : constant Positive := 2000; Maximum_Line_Length : constant Positive := 79;
Fatal_Line_Length_Limit : constant Positive := 5000; Fatal_Line_Length_Limit : constant Positive := 5000;
Fatal_Line_Length : exception; Fatal_Line_Length : exception;
-- If Maximum_Line_Length is exceeded in an input file, an error -- If Maximum_Line_Length is exceeded in an input file, an error
...@@ -221,6 +230,9 @@ procedure Xgnatug is ...@@ -221,6 +230,9 @@ procedure Xgnatug is
-- always have a VMS or a non-VMS version, regardless of the value of -- always have a VMS or a non-VMS version, regardless of the value of
-- Target. -- Target.
function In_VMS_Section return Boolean;
-- Returns True if in an "@ifset vms" section.
procedure Check_No_Pending_Conditional; procedure Check_No_Pending_Conditional;
-- Checks that all preprocessing directives have been properly matched by -- Checks that all preprocessing directives have been properly matched by
-- their @end counterpart. If this is not the case, print an error -- their @end counterpart. If this is not the case, print an error
...@@ -237,15 +249,13 @@ procedure Xgnatug is ...@@ -237,15 +249,13 @@ procedure Xgnatug is
end record; end record;
Conditional_Stack_Depth : constant := 3; Conditional_Stack_Depth : constant := 3;
Conditional_Stack : array (1 .. Conditional_Stack_Depth)
of Conditional_Context; Conditional_Stack :
array (1 .. Conditional_Stack_Depth) of Conditional_Context;
Conditional_TOS : Natural := 0; Conditional_TOS : Natural := 0;
-- Pointer to the Top Of Stack for Conditional_Stack. -- Pointer to the Top Of Stack for Conditional_Stack.
-----------------------------------
-- Implementation of Subprograms --
-----------------------------------
----------- -----------
-- Usage -- -- Usage --
----------- -----------
...@@ -253,12 +263,14 @@ procedure Xgnatug is ...@@ -253,12 +263,14 @@ procedure Xgnatug is
procedure Usage is procedure Usage is
begin begin
Put_Line (Standard_Error, Put_Line (Standard_Error,
"usage: xgnatug TARGET SOURCE DICTIONARY [OUTFILE]"); "usage: xgnatug TARGET SOURCE DICTIONARY [OUTFILE [WARNINGS]]");
New_Line; New_Line;
Put_Line (Standard_Error, "TARGET is one of:"); Put_Line (Standard_Error, "TARGET is one of:");
for T in Target_Type'Range loop for T in Target_Type'Range loop
Put_Line (Standard_Error, " " & Target_Type'Image (T)); Put_Line (Standard_Error, " " & Target_Type'Image (T));
end loop; end loop;
New_Line; New_Line;
Put_Line (Standard_Error, "SOURCE is the source file to process."); Put_Line (Standard_Error, "SOURCE is the source file to process.");
New_Line; New_Line;
...@@ -269,11 +281,17 @@ procedure Xgnatug is ...@@ -269,11 +281,17 @@ procedure Xgnatug is
Put_Line (Standard_Error, Put_Line (Standard_Error,
"OUT-FILE, if present, is the output file to be created;"); "OUT-FILE, if present, is the output file to be created;");
Put_Line (Standard_Error, Put_Line (Standard_Error,
"If OUT-FILE is absent, the output file is one of " & "If OUT-FILE is absent, the output file is either " &
"gnat_ug_unx.texi, "); "gnat_ugn_unw.texi, ");
Put_Line (Standard_Error,
"or gnat_ugn_vms.texi, depending on TARGET.");
New_Line;
Put_Line (Standard_Error,
"WARNINGS, if present, is any string;");
Put_Line (Standard_Error, Put_Line (Standard_Error,
"gnat_ug_vms.texi, gnat_ug_wnt.texi or gnat_ug_vxw.texi, " & "it will result in warning messages (e.g., line too long))");
"depending on TARGET."); Put_Line (Standard_Error,
"being output to Standard_Error.");
end Usage; end Usage;
-------------- --------------
...@@ -287,6 +305,7 @@ procedure Xgnatug is ...@@ -287,6 +305,7 @@ procedure Xgnatug is
begin begin
Input.Line := Input.Line + 1; Input.Line := Input.Line + 1;
Get_Line (Input.Data, Line_Buffer, Last); Get_Line (Input.Data, Line_Buffer, Last);
if Last = Line_Buffer'Last then if Last = Line_Buffer'Last then
Error (Input.all, "line exceeds fatal line length limit"); Error (Input.all, "line exceeds fatal line length limit");
raise Fatal_Line_Length; raise Fatal_Line_Length;
...@@ -341,7 +360,8 @@ procedure Xgnatug is ...@@ -341,7 +360,8 @@ procedure Xgnatug is
-- space character. -- space character.
begin begin
Have_Errors := True; Number_Of_Errors := Number_Of_Errors + 1;
if At_Character > 0 then if At_Character > 0 then
Put_Line (Standard_Error, Put_Line (Standard_Error,
S (Input.Name) & ':' S (Input.Name) & ':'
...@@ -368,7 +388,9 @@ procedure Xgnatug is ...@@ -368,7 +388,9 @@ procedure Xgnatug is
Message : String) Message : String)
is is
begin begin
if Warnings_Enabled then
Warning (Input, 0, Message); Warning (Input, 0, Message);
end if;
end Warning; end Warning;
procedure Warning procedure Warning
...@@ -382,6 +404,12 @@ procedure Xgnatug is ...@@ -382,6 +404,12 @@ procedure Xgnatug is
-- space character. -- space character.
begin begin
if not Warnings_Enabled then
return;
end if;
Number_Of_Warnings := Number_Of_Warnings + 1;
if At_Character > 0 then if At_Character > 0 then
Put_Line (Standard_Error, Put_Line (Standard_Error,
S (Input.Name) & ':' S (Input.Name) & ':'
...@@ -407,27 +435,33 @@ procedure Xgnatug is ...@@ -407,27 +435,33 @@ procedure Xgnatug is
begin begin
while not End_Of_File (Dictionary_File.Data) loop while not End_Of_File (Dictionary_File.Data) loop
declare declare
Line : String := Get_Line (Dictionary_File'Access); Line : constant String :=
Split : Natural := Index (Line, (1 => VMS_Escape_Character)); Get_Line (Dictionary_File'Access);
Split : constant Natural :=
Index (Line, (1 => VMS_Escape_Character));
begin begin
if Line'Length = 0 then if Line'Length = 0 then
Error (Dictionary_File, "empty line in dictionary file"); Error (Dictionary_File, "empty line in dictionary file");
elsif Line (Line'First) = ' ' then elsif Line (Line'First) = ' ' then
Error (Dictionary_File, 1, "line starts with space character"); Error (Dictionary_File, 1, "line starts with space character");
elsif Split = 0 then elsif Split = 0 then
Error (Dictionary_File, "line does not contain " Error (Dictionary_File, "line does not contain "
& VMS_Escape_Character & " character"); & VMS_Escape_Character & " character");
else else
declare declare
Source : constant String Source : constant String :=
:= Trim (Line (1 .. Split - 1), Both); Trim (Line (1 .. Split - 1), Both);
Target : constant String Target : constant String :=
:= Trim (Line (Split + 1 .. Line'Last), Both); Trim (Line (Split + 1 .. Line'Last), Both);
Two_Spaces : constant Natural Two_Spaces : constant Natural :=
:= Index (Source, " "); Index (Source, " ");
Non_Word_Character : constant Natural Non_Word_Character : constant Natural :=
:= Index (Source, Word_Characters or To_Set (" "), Index (Source,
Word_Characters or
To_Set (" "),
Outside); Outside);
begin begin
...@@ -443,8 +477,10 @@ procedure Xgnatug is ...@@ -443,8 +477,10 @@ procedure Xgnatug is
if Source'Length = 0 then if Source'Length = 0 then
Error (Dictionary_File, "source is empty"); Error (Dictionary_File, "source is empty");
elsif Target'Length = 0 then elsif Target'Length = 0 then
Error (Dictionary_File, "target is empty"); Error (Dictionary_File, "target is empty");
else else
Set (Ug_Words, Source, V (Target)); Set (Ug_Words, Source, V (Target));
...@@ -455,8 +491,8 @@ procedure Xgnatug is ...@@ -455,8 +491,8 @@ procedure Xgnatug is
for J in Source'Range loop for J in Source'Range loop
if Source (J) = ' ' then if Source (J) = ' ' then
declare declare
Prefix : String renames Source (Source'First Prefix : String renames
.. J - 1); Source (Source'First .. J - 1);
begin begin
if not Is_Known_Word (Prefix) then if not Is_Known_Word (Prefix) then
...@@ -475,27 +511,27 @@ procedure Xgnatug is ...@@ -475,27 +511,27 @@ procedure Xgnatug is
end Read_Dictionary_File; end Read_Dictionary_File;
------------------------- -------------------------
-- Process_Source_Line -- -- Rewrite_Source_Line --
------------------------- -------------------------
function Rewrite_Source_Line (Line : String) return String is function Rewrite_Source_Line (Line : String) return String is
-- We use a simple lexer to split the line into tokens: -- We use a simple lexer to split the line into tokens:
--
-- Word consisting entirely of Word_Characters -- Word consisting entirely of Word_Characters
-- VMS_Alternative ^alpha^beta^ replacement (but not ^^^) -- VMS_Alternative ^alpha^beta^ replacement (but not ^^^)
-- Space a space character -- Space a space character
-- Other everything else (sequence of non-word characters) -- Other everything else (sequence of non-word characters)
-- VMS_Error incomplete VMS alternative -- VMS_Error incomplete VMS alternative
-- End_Of_Line no more characters on this line -- End_Of_Line no more characters on this line
--
-- A sequence of three VMS_Escape_Characters is automatically -- A sequence of three VMS_Escape_Characters is automatically
-- collapsed to an Other token. -- collapsed to an Other token.
type Token_Span is record type Token_Span is record
First, Last : Positive; First, Last : Positive;
end record; end record;
-- The character range covered by a token in Line. -- The character range covered by a token in Line
type Token_Kind is (End_Of_Line, Word, Other, type Token_Kind is (End_Of_Line, Word, Other,
VMS_Alternative, VMS_Error); VMS_Alternative, VMS_Error);
...@@ -513,13 +549,13 @@ procedure Xgnatug is ...@@ -513,13 +549,13 @@ procedure Xgnatug is
Input_Position : Positive := Line'First; Input_Position : Positive := Line'First;
Token : Token_Record; Token : Token_Record;
-- The position of the next character to be processed by Next_Token. -- The position of the next character to be processed by Next_Token
procedure Next_Token; procedure Next_Token;
-- Returns the next token in Line, starting at Input_Position. -- Returns the next token in Line, starting at Input_Position
Rewritten_Line : VString; Rewritten_Line : VString;
-- Collects the line as it is rewritten. -- Collects the line as it is rewritten
procedure Rewrite_Word; procedure Rewrite_Word;
-- The current token is assumed to be a Word. When processing the VMS -- The current token is assumed to be a Word. When processing the VMS
...@@ -536,6 +572,10 @@ procedure Xgnatug is ...@@ -536,6 +572,10 @@ procedure Xgnatug is
-- This is set to true if a VMS_Alternative has been encountered, or a -- This is set to true if a VMS_Alternative has been encountered, or a
-- ^^^ token. -- ^^^ token.
----------------
-- Next_Token --
----------------
procedure Next_Token is procedure Next_Token is
Remaining_Line : String renames Line (Input_Position .. Line'Last); Remaining_Line : String renames Line (Input_Position .. Line'Last);
Last_Character : Natural; Last_Character : Natural;
...@@ -564,20 +604,22 @@ procedure Xgnatug is ...@@ -564,20 +604,22 @@ procedure Xgnatug is
-- Find the second and third escape character. If one of -- Find the second and third escape character. If one of
-- them is not present, generate an error token. -- them is not present, generate an error token.
VMS_Second_Character VMS_Second_Character :=
:= Index (Remaining_Line (Remaining_Line'First + 1 Index (Remaining_Line (Remaining_Line'First + 1
.. Remaining_Line'Last), .. Remaining_Line'Last),
(1 => VMS_Escape_Character)); (1 => VMS_Escape_Character));
if VMS_Second_Character = 0 then if VMS_Second_Character = 0 then
Input_Position := Remaining_Line'Last + 1; Input_Position := Remaining_Line'Last + 1;
Token := (VMS_Error, Remaining_Line'First); Token := (VMS_Error, Remaining_Line'First);
return; return;
end if; end if;
VMS_Third_Character VMS_Third_Character :=
:= Index (Remaining_Line (VMS_Second_Character + 1 Index (Remaining_Line (VMS_Second_Character + 1
.. Remaining_Line'Last), .. Remaining_Line'Last),
(1 => VMS_Escape_Character)); (1 => VMS_Escape_Character));
if VMS_Third_Character = 0 then if VMS_Third_Character = 0 then
Input_Position := Remaining_Line'Last + 1; Input_Position := Remaining_Line'Last + 1;
Token := (VMS_Error, Remaining_Line'First); Token := (VMS_Error, Remaining_Line'First);
...@@ -615,7 +657,6 @@ procedure Xgnatug is ...@@ -615,7 +657,6 @@ procedure Xgnatug is
Last_Character := Index (Remaining_Line, Word_Characters, Outside); Last_Character := Index (Remaining_Line, Word_Characters, Outside);
if Last_Character /= Remaining_Line'First then if Last_Character /= Remaining_Line'First then
-- If we haven't found a character which is not in -- If we haven't found a character which is not in
-- Word_Characters, all remaining characters are part of the -- Word_Characters, all remaining characters are part of the
-- current Word token. -- current Word token.
...@@ -635,10 +676,15 @@ procedure Xgnatug is ...@@ -635,10 +676,15 @@ procedure Xgnatug is
-- of them. -- of them.
Input_Position := Last_Character + 1; Input_Position := Last_Character + 1;
Token := (Other, Remaining_Line'First, Token := (Other,
Remaining_Line'First,
(Remaining_Line'First, Last_Character)); (Remaining_Line'First, Last_Character));
end Next_Token; end Next_Token;
------------------
-- Rewrite_Word --
------------------
procedure Rewrite_Word is procedure Rewrite_Word is
First_Word : String First_Word : String
renames Line (Token.Span.First .. Token.Span.Last); renames Line (Token.Span.First .. Token.Span.Last);
...@@ -704,7 +750,7 @@ procedure Xgnatug is ...@@ -704,7 +750,7 @@ procedure Xgnatug is
end if; end if;
end loop; end loop;
-- Rewrite Seq, and add the lost space if necessary. -- Rewrite Seq, and add the lost space if necessary
Append (Rewritten_Line, Append (Rewritten_Line,
Get_Replacement_Word (Line (Seq.First .. Seq.Last))); Get_Replacement_Word (Line (Seq.First .. Seq.Last)));
...@@ -719,11 +765,11 @@ procedure Xgnatug is ...@@ -719,11 +765,11 @@ procedure Xgnatug is
end if; end if;
Next_Token; Next_Token;
if Token.Kind = Other if Token.Kind = Other
and then Line (Token.Span.First .. Token.Span.Last) = "." and then Line (Token.Span.First .. Token.Span.Last) = "."
then then
-- Deal with extensions
-- Deal with extensions.
Next_Token; Next_Token;
if Token.Kind = Word if Token.Kind = Word
...@@ -749,7 +795,6 @@ procedure Xgnatug is ...@@ -749,7 +795,6 @@ procedure Xgnatug is
-- iteration of the main loop. -- iteration of the main loop.
end if; end if;
else else
-- We have an unknown Word, followed by an unknown token. -- We have an unknown Word, followed by an unknown token.
-- The unknown token will be processed by the outer loop. -- The unknown token will be processed by the outer loop.
...@@ -758,9 +803,13 @@ procedure Xgnatug is ...@@ -758,9 +803,13 @@ procedure Xgnatug is
end if; end if;
end Rewrite_Word; end Rewrite_Word;
-----------------------------
-- Maybe_Rewrite_Extension --
-----------------------------
procedure Maybe_Rewrite_Extension is procedure Maybe_Rewrite_Extension is
begin begin
-- Again, we need no special processing in the non-VMS case. -- Again, we need no special processing in the non-VMS case
if Target = VMS if Target = VMS
and then Line (Token.Span.First .. Token.Span.Last) = "." and then Line (Token.Span.First .. Token.Span.Last) = "."
...@@ -791,7 +840,7 @@ procedure Xgnatug is ...@@ -791,7 +840,7 @@ procedure Xgnatug is
begin begin
-- The following parser recognizes the following special token -- The following parser recognizes the following special token
-- sequences: -- sequences:
--
-- Word "." Word rewrite as file name if second word is extension -- Word "." Word rewrite as file name if second word is extension
-- Word " " Word rewrite as a single word using Ug_Words table -- Word " " Word rewrite as a single word using Ug_Words table
...@@ -809,10 +858,16 @@ procedure Xgnatug is ...@@ -809,10 +858,16 @@ procedure Xgnatug is
when VMS_Alternative => when VMS_Alternative =>
if VMS_Context_Determined then if VMS_Context_Determined then
if (not In_VMS_Section)
or else
Line (Token.VMS.First .. Token.VMS.Last) /=
Line (Token.Non_VMS.First .. Token.Non_VMS.Last)
then
Warning (Source_File, Token.First, Warning (Source_File, Token.First,
"VMS alternative already determined " "VMS alternative already determined "
& "by conditionals"); & "by conditionals");
end if; end if;
end if;
if Target = VMS then if Target = VMS then
Append (Rewritten_Line, Line (Token.VMS.First Append (Rewritten_Line, Line (Token.VMS.First
.. Token.VMS.Last)); .. Token.VMS.Last));
...@@ -827,6 +882,7 @@ procedure Xgnatug is ...@@ -827,6 +882,7 @@ procedure Xgnatug is
Next_Token; Next_Token;
end case; end case;
end loop; end loop;
return S (Rewritten_Line); return S (Rewritten_Line);
end Rewrite_Source_Line; end Rewrite_Source_Line;
...@@ -852,8 +908,10 @@ procedure Xgnatug is ...@@ -852,8 +908,10 @@ procedure Xgnatug is
Have_Conditional : Boolean := False; Have_Conditional : Boolean := False;
-- True if we have encountered a conditional preprocessing -- True if we have encountered a conditional preprocessing
-- directive. -- directive.
Cond : Conditional; Cond : Conditional;
-- The kind of the directive. -- The kind of the directive.
Flag : Target_Type; Flag : Target_Type;
-- Its flag. -- Its flag.
...@@ -866,18 +924,22 @@ procedure Xgnatug is ...@@ -866,18 +924,22 @@ procedure Xgnatug is
and then Line (1 .. Ifset'Length) = Ifset and then Line (1 .. Ifset'Length) = Ifset
then then
Cond := Set; Cond := Set;
declare declare
Arg : constant String Arg : constant String :=
:= Trim (Line (Ifset'Length + 1 .. Line'Last), Both); Trim (Line (Ifset'Length + 1 .. Line'Last), Both);
begin begin
Flag := Target_Type'Value (Arg); Flag := Target_Type'Value (Arg);
if Translate (Target_Type'Image (Flag), Lower_Case_Map) if Translate (Target_Type'Image (Flag), Lower_Case_Map)
/= Arg /= Arg
then then
Error (Source_File, "flag has to be lowercase"); Error (Source_File, "flag has to be lowercase");
end if; end if;
Have_Conditional := True; Have_Conditional := True;
exception exception
when Constraint_Error => when Constraint_Error =>
Error (Source_File, "unknown flag for '@ifset'"); Error (Source_File, "unknown flag for '@ifset'");
...@@ -887,9 +949,10 @@ procedure Xgnatug is ...@@ -887,9 +949,10 @@ procedure Xgnatug is
and then Line (1 .. Ifclear'Length) = Ifclear and then Line (1 .. Ifclear'Length) = Ifclear
then then
Cond := Clear; Cond := Clear;
declare declare
Arg : constant String Arg : constant String :=
:= Trim (Line (Ifclear'Length + 1 .. Line'Last), Both); Trim (Line (Ifclear'Length + 1 .. Line'Last), Both);
begin begin
Flag := Target_Type'Value (Arg); Flag := Target_Type'Value (Arg);
...@@ -898,7 +961,9 @@ procedure Xgnatug is ...@@ -898,7 +961,9 @@ procedure Xgnatug is
then then
Error (Source_File, "flag has to be lowercase"); Error (Source_File, "flag has to be lowercase");
end if; end if;
Have_Conditional := True; Have_Conditional := True;
exception exception
when Constraint_Error => when Constraint_Error =>
Error (Source_File, "unknown flag for '@ifclear'"); Error (Source_File, "unknown flag for '@ifclear'");
...@@ -906,6 +971,7 @@ procedure Xgnatug is ...@@ -906,6 +971,7 @@ procedure Xgnatug is
end if; end if;
if Have_Conditional then if Have_Conditional then
-- We create a new conditional context and suppress the -- We create a new conditional context and suppress the
-- directive in the output. -- directive in the output.
...@@ -919,6 +985,7 @@ procedure Xgnatug is ...@@ -919,6 +985,7 @@ procedure Xgnatug is
declare declare
First, Last : Natural; First, Last : Natural;
begin begin
Find_Token (Source => Line (Endsetclear'Length + 1 Find_Token (Source => Line (Endsetclear'Length + 1
.. Line'Length), .. Line'Length),
...@@ -926,6 +993,7 @@ procedure Xgnatug is ...@@ -926,6 +993,7 @@ procedure Xgnatug is
Test => Inside, Test => Inside,
First => First, First => First,
Last => Last); Last => Last);
if Last = 0 then if Last = 0 then
Error (Source_File, "'@end' without argument"); Error (Source_File, "'@end' without argument");
else else
...@@ -943,18 +1011,22 @@ procedure Xgnatug is ...@@ -943,18 +1011,22 @@ procedure Xgnatug is
-- We fall through to the ordinary case for other @end -- We fall through to the ordinary case for other @end
-- directives. -- directives.
end if; -- @end without argument end if; -- @end without argument
end; end;
end if; -- Have_Conditional end if; -- Have_Conditional
if not Have_Conditional then if not Have_Conditional then
-- The ordinary case. -- The ordinary case.
if not Currently_Excluding then if not Currently_Excluding then
Put_Line (Output_File, Rewritten); Put_Line (Output_File, Rewritten);
end if; end if;
end if; end if;
end; end;
end loop; end loop;
Check_No_Pending_Conditional; Check_No_Pending_Conditional;
end Process_Source_File; end Process_Source_File;
...@@ -971,6 +1043,10 @@ procedure Xgnatug is ...@@ -971,6 +1043,10 @@ procedure Xgnatug is
procedure Add (Extension, Replacement : String); procedure Add (Extension, Replacement : String);
-- Adds an extension with a custom replacement. -- Adds an extension with a custom replacement.
---------
-- Add --
---------
procedure Add (Extension : String) is procedure Add (Extension : String) is
begin begin
Add (Extension, Translate (Extension, Upper_Case_Map)); Add (Extension, Translate (Extension, Upper_Case_Map));
...@@ -1040,6 +1116,7 @@ procedure Xgnatug is ...@@ -1040,6 +1116,7 @@ procedure Xgnatug is
procedure Push_Conditional (Cond : Conditional; Flag : Target_Type) is procedure Push_Conditional (Cond : Conditional; Flag : Target_Type) is
Will_Exclude : Boolean; Will_Exclude : Boolean;
begin begin
-- If we are already in an excluding context, inherit this property, -- If we are already in an excluding context, inherit this property,
-- otherwise calculate it from scratch. -- otherwise calculate it from scratch.
...@@ -1066,9 +1143,10 @@ procedure Xgnatug is ...@@ -1066,9 +1143,10 @@ procedure Xgnatug is
& Integer'Image (Conditional_Stack (J).Starting_Line)); & Integer'Image (Conditional_Stack (J).Starting_Line));
end if; end if;
end loop; end loop;
Conditional_TOS := Conditional_TOS + 1; Conditional_TOS := Conditional_TOS + 1;
Conditional_Stack (Conditional_TOS) Conditional_Stack (Conditional_TOS) :=
:= (Starting_Line => Source_File.Line, (Starting_Line => Source_File.Line,
Cond => Cond, Cond => Cond,
Flag => Flag, Flag => Flag,
Excluding => Will_Exclude); Excluding => Will_Exclude);
...@@ -1089,6 +1167,7 @@ procedure Xgnatug is ...@@ -1089,6 +1167,7 @@ procedure Xgnatug is
& Integer'Image (Conditional_Stack & Integer'Image (Conditional_Stack
(Conditional_TOS).Starting_Line)); (Conditional_TOS).Starting_Line));
end if; end if;
when Clear => when Clear =>
if Conditional_Stack (Conditional_TOS).Cond /= Clear then if Conditional_Stack (Conditional_TOS).Cond /= Clear then
Error (Source_File, Error (Source_File,
...@@ -1097,12 +1176,15 @@ procedure Xgnatug is ...@@ -1097,12 +1176,15 @@ procedure Xgnatug is
(Conditional_TOS).Starting_Line)); (Conditional_TOS).Starting_Line));
end if; end if;
end case; end case;
Conditional_TOS := Conditional_TOS - 1; Conditional_TOS := Conditional_TOS - 1;
else else
case Cond is case Cond is
when Set => when Set =>
Error (Source_File, Error (Source_File,
"'@end ifset' without corresponding '@ifset'"); "'@end ifset' without corresponding '@ifset'");
when Clear => when Clear =>
Error (Source_File, Error (Source_File,
"'@end ifclear' without corresponding '@ifclear'"); "'@end ifclear' without corresponding '@ifclear'");
...@@ -1131,9 +1213,25 @@ procedure Xgnatug is ...@@ -1131,9 +1213,25 @@ procedure Xgnatug is
return True; return True;
end if; end if;
end loop; end loop;
return False; return False;
end VMS_Context_Determined; end VMS_Context_Determined;
--------------------
-- In_VMS_Section --
--------------------
function In_VMS_Section return Boolean is
begin
for J in 1 .. Conditional_TOS loop
if Conditional_Stack (J).Flag = VMS then
return Conditional_Stack (J).Cond = Set;
end if;
end loop;
return False;
end In_VMS_Section;
---------------------------------- ----------------------------------
-- Check_No_Pending_Conditional -- -- Check_No_Pending_Conditional --
---------------------------------- ----------------------------------
...@@ -1145,6 +1243,7 @@ procedure Xgnatug is ...@@ -1145,6 +1243,7 @@ procedure Xgnatug is
when Set => when Set =>
Error (Source_File, "Missing '@end ifset' for '@ifset' at line" Error (Source_File, "Missing '@end ifset' for '@ifset' at line"
& Integer'Image (Conditional_Stack (J).Starting_Line)); & Integer'Image (Conditional_Stack (J).Starting_Line));
when Clear => when Clear =>
Error (Source_File, Error (Source_File,
"Missing '@end ifclear' for '@ifclear' at line" "Missing '@end ifclear' for '@ifclear' at line"
...@@ -1163,13 +1262,14 @@ procedure Xgnatug is ...@@ -1163,13 +1262,14 @@ procedure Xgnatug is
begin begin
Initialize_Extensions; Initialize_Extensions;
Valid_Command_Line := Argument_Count in 3 .. 4; Valid_Command_Line := Argument_Count in 3 .. 5;
-- First argument: Target. -- First argument: Target.
if Valid_Command_Line then if Valid_Command_Line then
begin begin
Target := Target_Type'Value (Argument (1)); Target := Target_Type'Value (Argument (1));
exception exception
when Constraint_Error => when Constraint_Error =>
Valid_Command_Line := False; Valid_Command_Line := False;
...@@ -1182,6 +1282,7 @@ begin ...@@ -1182,6 +1282,7 @@ begin
begin begin
Source_File.Name := V (Argument (2)); Source_File.Name := V (Argument (2));
Open (Source_File.Data, In_File, Argument (2)); Open (Source_File.Data, In_File, Argument (2));
exception exception
when Name_Error => when Name_Error =>
Valid_Command_Line := False; Valid_Command_Line := False;
...@@ -1194,6 +1295,7 @@ begin ...@@ -1194,6 +1295,7 @@ begin
begin begin
Dictionary_File.Name := V (Argument (3)); Dictionary_File.Name := V (Argument (3));
Open (Dictionary_File.Data, In_File, Argument (3)); Open (Dictionary_File.Data, In_File, Argument (3));
exception exception
when Name_Error => when Name_Error =>
Valid_Command_Line := False; Valid_Command_Line := False;
...@@ -1203,23 +1305,22 @@ begin ...@@ -1203,23 +1305,22 @@ begin
-- Fourth argument: Output_File. -- Fourth argument: Output_File.
if Valid_Command_Line then if Valid_Command_Line then
if Argument_Count = 4 then if Argument_Count in 4 .. 5 then
Output_File_Name := V (Argument (4)); Output_File_Name := V (Argument (4));
else else
case Target is case Target is
when UNW =>
Output_File_Name := V ("gnat_ugn_unw.texi");
when VMS => when VMS =>
Output_File_Name := V ("gnat_ug_vms.texi"); Output_File_Name := V ("gnat_ugn_vms.texi");
when WNT =>
Output_File_Name := V ("gnat_ug_wnt.texi");
when UNX =>
Output_File_Name := V ("gnat_ug_unx.texi");
when VXWORKS =>
Output_File_Name := V ("gnat_ug_vxw.texi");
end case; end case;
end if; end if;
Warnings_Enabled := Argument_Count = 5;
begin begin
Create (Output_File, Out_File, S (Output_File_Name)); Create (Output_File, Out_File, S (Output_File_Name));
exception exception
when Name_Error | Use_Error => when Name_Error | Use_Error =>
Valid_Command_Line := False; Valid_Command_Line := False;
...@@ -1229,6 +1330,7 @@ begin ...@@ -1229,6 +1330,7 @@ begin
if not Valid_Command_Line then if not Valid_Command_Line then
Usage; Usage;
Set_Exit_Status (Failure); Set_Exit_Status (Failure);
else else
Read_Dictionary_File; Read_Dictionary_File;
Close (Dictionary_File.Data); Close (Dictionary_File.Data);
...@@ -1238,10 +1340,41 @@ begin ...@@ -1238,10 +1340,41 @@ begin
Process_Source_File; Process_Source_File;
Close (Output_File); Close (Output_File);
Close (Source_File.Data); Close (Source_File.Data);
if Have_Errors then
New_Line (Standard_Error);
if Number_Of_Warnings = 0 then
Put_Line (Standard_Error, " NO Warnings");
else
Put (Standard_Error, Integer'Image (Number_Of_Warnings));
Put (Standard_Error, " Warning");
if Number_Of_Warnings > 1 then
Put (Standard_Error, "s");
end if;
New_Line (Standard_Error);
end if;
if Number_Of_Errors = 0 then
Put_Line (Standard_Error, " NO Errors");
else
Put (Standard_Error, Integer'Image (Number_Of_Errors));
Put (Standard_Error, " Error");
if Number_Of_Errors > 1 then
Put (Standard_Error, "s");
end if;
New_Line (Standard_Error);
end if;
if Number_Of_Errors /= 0 then
Set_Exit_Status (Failure); Set_Exit_Status (Failure);
else else
Set_Exit_Status (Success); Set_Exit_Status (Success);
end if; end if;
end if; end if;
end Xgnatug; end Xgnatugn;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment