~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to fpcsrc/utils/tply/yaccmsgs.pas

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{
 
2
  TP Yacc message and error handling module 2-5-91 AG
 
3
  Note: this module should be USEd by any module using the heap during
 
4
        initialization, since it installs a heap error handler (which
 
5
        terminates the program with fatal error `memory overflow').
 
6
 
 
7
 
 
8
  Copyright (c) 1990-92  Albert Graef <ag@muwiinfa.geschichte.uni-mainz.de>
 
9
  Copyright (C) 1996     Berend de Boer <berend@pobox.com>
 
10
 
 
11
  This program is free software; you can redistribute it and/or modify
 
12
  it under the terms of the GNU General Public License as published by
 
13
  the Free Software Foundation; either version 2 of the License, or
 
14
  (at your option) any later version.
 
15
 
 
16
  This program is distributed in the hope that it will be useful,
 
17
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
  GNU General Public License for more details.
 
20
 
 
21
  You should have received a copy of the GNU General Public License
 
22
  along with this program; if not, write to the Free Software
 
23
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
24
 
 
25
 
 
26
$Revision: 1.3 $
 
27
$Modtime: 96-07-31 14:50 $
 
28
 
 
29
$History: YACCMSGS.PAS $
 
30
 *
 
31
 * *****************  Version 2  *****************
 
32
 * User: Berend       Date: 96-10-10   Time: 21:16
 
33
 * Updated in $/Lex and Yacc/tply
 
34
 * Updated for protected mode, windows and Delphi 1.X and 2.X.
 
35
 
 
36
}
 
37
 
 
38
 
 
39
unit YaccMsgs;
 
40
 
 
41
interface
 
42
 
 
43
 
 
44
var errors, warnings : Integer;
 
45
  (* - current error and warning count *)
 
46
procedure error(msg : String);
 
47
  (* - print current input line and error message (pos denotes position to
 
48
       mark in source file line) *)
 
49
procedure warning(msg : String);
 
50
  (* - print warning message *)
 
51
procedure fatal(msg : String);
 
52
(* - writes a fatal error message, erases Yacc output file and terminates
 
53
     the program with errorlevel 1 *)
 
54
 
 
55
const
 
56
 
 
57
(* sign-on and usage message: *)
 
58
 
 
59
sign_on = 'TP Yacc Version 4.1a [April 2000], Copyright (c) 1990-2000 Albert Graef';
 
60
{$ifdef Unix}
 
61
usage   = 'Usage: pyacc [options] yacc-file[.y] [output-file[.pas]]';
 
62
{$else}
 
63
usage   = 'Usage: yacc [options] yacc-file[.y] [output-file[.pas]]';
 
64
{$endif}
 
65
options = 'Options: -v verbose, -d debug';
 
66
 
 
67
(* command line error messages: *)
 
68
 
 
69
invalid_option                  = 'invalid option ';
 
70
illegal_no_args                 = 'illegal number of parameters';
 
71
 
 
72
(* syntax errors: *)
 
73
 
 
74
open_comment_at_eof             = '101: open comment at end of file';
 
75
missing_string_terminator       = '102: missing string terminator';
 
76
rcurl_expected                  = '103: %} expected';
 
77
rbrace_expected                 = '104: } expected';
 
78
rangle_expected                 = '105: > expected';
 
79
ident_expected                  = '106: identifier expected';
 
80
error_in_def                    = '110: error in definition';
 
81
error_in_rule                   = '111: error in rule';
 
82
syntax_error                    = '112: syntax error';
 
83
unexpected_eof                  = '113: unexpected end of file';
 
84
 
 
85
(* semantic errors: *)
 
86
 
 
87
nonterm_expected                = '201: nonterminal expected';
 
88
literal_expected                = '202: literal expected';
 
89
double_tokennum_def             = '203: literal already defined';
 
90
unknown_identifier              = '204: unknown identifier';
 
91
type_error                      = '205: type error';
 
92
range_error                     = '206: range error';
 
93
empty_grammar                   = '207: empty grammar?';
 
94
 
 
95
(* fatal errors: *)
 
96
 
 
97
cannot_open_file                = 'FATAL: cannot open file ';
 
98
write_error                     = 'FATAL: write error';
 
99
mem_overflow                    = 'FATAL: memory overflow';
 
100
intset_overflow                 = 'FATAL: integer set overflow';
 
101
sym_table_overflow              = 'FATAL: symbol table overflow';
 
102
nt_table_overflow               = 'FATAL: nonterminal table overflow';
 
103
lit_table_overflow              = 'FATAL: literal table overflow';
 
104
type_table_overflow             = 'FATAL: type table overflow';
 
105
prec_table_overflow             = 'FATAL: precedence table overflow';
 
106
rule_table_overflow             = 'FATAL: rule table overflow';
 
107
state_table_overflow            = 'FATAL: state table overflow';
 
108
item_table_overflow             = 'FATAL: item table overflow';
 
109
trans_table_overflow            = 'FATAL: transition table overflow';
 
110
redn_table_overflow             = 'FATAL: reduction table overflow';
 
111
 
 
112
implementation
 
113
 
 
114
uses YaccBase;
 
115
 
 
116
procedure position(var f : Text;
 
117
            lineNo : integer;
 
118
            line : String;
 
119
            pos : integer);
 
120
  (* writes a position mark of the form
 
121
     lineno: line
 
122
               ^
 
123
     on f with the caret ^ positioned at pos in line
 
124
     a subsequent write starts at the next line, indented with tab *)
 
125
  var
 
126
    line1, line2 : String;
 
127
  begin
 
128
    (* this hack handles tab characters in line: *)
 
129
    line1 := intStr(lineNo)+': '+line;
 
130
    line2 := blankStr(intStr(lineNo)+': '+copy(line, 1, pos-1));
 
131
    writeln(f, line1);
 
132
    writeln(f, line2, '^');
 
133
    write(f, tab)
 
134
  end(*position*);
 
135
 
 
136
procedure error(msg : String);
 
137
  begin
 
138
    inc(errors);
 
139
    writeln;
 
140
    position(output, lno, line, cno-tokleng);
 
141
    writeln(msg);
 
142
    writeln(yylst);
 
143
    position(yylst, lno, line, cno-tokleng);
 
144
    writeln(yylst, msg);
 
145
    if ioresult<>0 then ;
 
146
  end(*error*);
 
147
 
 
148
procedure warning(msg : String);
 
149
  begin
 
150
    inc(warnings);
 
151
    writeln;
 
152
    position(output, lno, line, cno-tokleng);
 
153
    writeln(msg);
 
154
    writeln(yylst);
 
155
    position(yylst, lno, line, cno-tokleng);
 
156
    writeln(yylst, msg);
 
157
    if ioresult<>0 then ;
 
158
  end(*warning*);
 
159
 
 
160
procedure fatal(msg : String);
 
161
  begin
 
162
    writeln;
 
163
    writeln(msg);
 
164
    close(yyin); close(yyout); close(yylst); erase(yyout);
 
165
    halt(1)
 
166
  end(*fatal*);
 
167
 
 
168
{$ifndef fpc}
 
169
{$IFNDEF Win32}
 
170
function heapErrorHandler ( size : Word ) : Integer; far;
 
171
  begin
 
172
    if size>0 then
 
173
      fatal(mem_overflow) (* never returns *)
 
174
    else
 
175
      heapErrorHandler := 1
 
176
  end(*heapErrorHandler*);
 
177
{$ENDIF}
 
178
{$endif}
 
179
 
 
180
begin
 
181
  errors := 0; warnings := 0;
 
182
{$ifndef fpc}
 
183
{$IFNDEF Win32}
 
184
  (* install heap error handler: *)
 
185
  heapError := @heapErrorHandler;
 
186
{$ENDIF}
 
187
{$endif}
 
188
end(*YaccMsgs*).