annotate gcc/ada/scng.ads @ 144:8f4e72ab4e11

fix segmentation fault caused by nothing next cur_op to end
author Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 23 Dec 2018 21:23:56 +0900
parents 84e7813d76e9
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S C N G --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 -- This package contains a generic lexical analyzer. This is used for scanning
kono
parents:
diff changeset
27 -- Ada source files or text files with an Ada-like syntax, such as project
kono
parents:
diff changeset
28 -- files. It is instantiated in Scn and Prj.Err.
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 with Casing; use Casing;
kono
parents:
diff changeset
31 with Styleg;
kono
parents:
diff changeset
32 with Types; use Types;
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 generic
kono
parents:
diff changeset
35 with procedure Post_Scan;
kono
parents:
diff changeset
36 -- Procedure called by Scan for the following tokens: Tok_Char_Literal,
kono
parents:
diff changeset
37 -- Tok_Identifier, Tok_Real_Literal, Tok_Real_Literal, Tok_Integer_Literal,
kono
parents:
diff changeset
38 -- Tok_String_Literal, Tok_Operator_Symbol, and Tok_Vertical_Bar. Used to
kono
parents:
diff changeset
39 -- build Token_Node and also check for obsolescent features.
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 with procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr);
kono
parents:
diff changeset
42 -- Output a message at specified location
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 with procedure Error_Msg_S (Msg : String);
kono
parents:
diff changeset
45 -- Output a message at current scan pointer location
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 with procedure Error_Msg_SC (Msg : String);
kono
parents:
diff changeset
48 -- Output a message at the start of the current token
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 with procedure Error_Msg_SP (Msg : String);
kono
parents:
diff changeset
51 -- Output a message at the start of the previous token
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 with package Style is new Styleg
kono
parents:
diff changeset
54 (Error_Msg, Error_Msg_S, Error_Msg_SC, Error_Msg_SP);
kono
parents:
diff changeset
55 -- Instantiation of Styleg with the same error reporting routines
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 package Scng is
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 procedure Check_End_Of_Line;
kono
parents:
diff changeset
60 -- Called when end of line encountered. Checks that line is not too long,
kono
parents:
diff changeset
61 -- and that other style checks for the end of line are met.
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 procedure Initialize_Scanner (Index : Source_File_Index);
kono
parents:
diff changeset
64 -- Initialize lexical scanner for scanning a new file referenced by Index.
kono
parents:
diff changeset
65 -- Initialize_Scanner does not call Scan.
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 procedure Scan;
kono
parents:
diff changeset
68 -- Scan scans out the next token, and advances the scan state accordingly
kono
parents:
diff changeset
69 -- (see package Scan_State for details). If the scan encounters an illegal
kono
parents:
diff changeset
70 -- token, then an error message is issued pointing to the bad character,
kono
parents:
diff changeset
71 -- and Scan returns a reasonable substitute token of some kind.
kono
parents:
diff changeset
72 -- For tokens Char_Literal, Identifier, Real_Literal, Integer_Literal,
kono
parents:
diff changeset
73 -- String_Literal and Operator_Symbol, Post_Scan is called after scanning.
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 function Determine_Token_Casing return Casing_Type;
kono
parents:
diff changeset
76 pragma Inline (Determine_Token_Casing);
kono
parents:
diff changeset
77 -- Determines the casing style of the current token, which is
kono
parents:
diff changeset
78 -- either a keyword or an identifier. See also package Casing.
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 procedure Set_Special_Character (C : Character);
kono
parents:
diff changeset
81 -- Indicate that one of the following character '#', '$', '?', '`',
kono
parents:
diff changeset
82 -- '\', '^', '_' or '~', when found is a Special token.
kono
parents:
diff changeset
83 -- AI12-0125-03 : target name (ES) is not in this list because '@' is
kono
parents:
diff changeset
84 -- handled as a special token as abbreviation of LHS of assignment.
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 procedure Reset_Special_Characters;
kono
parents:
diff changeset
87 -- Indicate that there is no characters that are Special tokens., which
kono
parents:
diff changeset
88 -- is the default.
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 procedure Set_End_Of_Line_As_Token (Value : Boolean);
kono
parents:
diff changeset
91 -- Indicate if End_Of_Line is a token or not.
kono
parents:
diff changeset
92 -- By default, End_Of_Line is not a token.
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 procedure Set_Comment_As_Token (Value : Boolean);
kono
parents:
diff changeset
95 -- Indicate if a comment is a token or not.
kono
parents:
diff changeset
96 -- By default, a comment is not a token.
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 function Set_Start_Column return Column_Number;
kono
parents:
diff changeset
99 -- This routine is called with Scan_Ptr pointing to the first character
kono
parents:
diff changeset
100 -- of a line. On exit, Scan_Ptr is advanced to the first non-blank
kono
parents:
diff changeset
101 -- character of this line (or to the terminating format effector if the
kono
parents:
diff changeset
102 -- line contains no non-blank characters), and the returned result is the
kono
parents:
diff changeset
103 -- column number of this non-blank character (zero origin), which is the
kono
parents:
diff changeset
104 -- value to be stored in the Start_Column scan variable.
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 end Scng;