AAda Compiler Error Package

16
Jan
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
-- AAda Compiler base package
with aada_compiler_token_position;
 
package aada_compiler_error_package is
 
  -- the compiler object transmitted to nearly all sub-routines
  -- (limited because there can be only one)
  type aada_compiler_error is limited private;
 
  -- all the errors that the compiler will eventually emit
  type errcode is range 10_000 .. 99_999;
 
  -----------------------------------------------------------
  -- lexer errors (10,000 .. 10,999)
  -----------------------------------------------------------
  -- identifier/number with two underscores in a row
  two_underscores_error:           constant errcode := 10_001;
  -- underscore in the wrong place (i.e. 16#_123_._456_#)
  invalid_underscore_error:        constant errcode := 10_002;
  -- underscore at the start or by itself
  unexpected_underscore_error:     constant errcode := 10_003;
  -- base is out of range (2 .. 36)
  unacceptable_numeric_base_error: constant errcode := 10_004;
  -- floating point starting with the decimal point (i.e. ".123")
  invalid_floating_point_error:    constant errcode := 10_005;
  -- something is wrong in that based number (missing #, digits, etc.)
  invalid_based_number_error:      constant errcode := 10_006;
  -- invalid exponent declaration (E by itself or followed by non-digits)
  invalid_exponent_error:          constant errcode := 10_007;
  -- input file has unwanted characters, generally control characters
  unexpected_character_error:      constant errcode := 10_008;
  -- illegal identifier representing a reserved work but which is not one
  illegal_identifier_error:        constant errcode := 10_009;
  -- two punctuation characters in an identifier
  two_punctuation_error:           constant errcode := 10_010;
  -- illegal punctuation characters in an identifier (at the end)
  illegal_punctuation_error:       constant errcode := 10_011;
 
  -----------------------------------------------------------
  -- parser errors (20,000 .. 20,999)
  -----------------------------------------------------------
  -- we expected an opening parenthesis and got something else
  expected_open_parenthesis_error:      constant errcode := 20_000;
  -- we expected a ';' instead of the proposed token
  expected_semi_colon_error:            constant errcode := 20_001;
  -- we expected a closing parenthesis and got something else
  expected_close_parenthesis_error:     constant errcode := 20_002;
  -- we expected a terminal and got something else in our expression
  unexpected_token_in_expression_error: constant errcode := 20_003;
  -- expected the "in" keyword after "not", ...
  expected_in_keyword_error:            constant errcode := 20_004;
  -- expected the "and", "or", "xor" before "not"
  expected_relation_keyword_before_not: constant errcode := 20_005;
  -- expected the arrow (=>) operator
  expected_arrow_error:                 constant errcode := 20_006;
  -- the token we found was not an identifier but should have been to be legal
  expected_an_identifier_error:         constant errcode := 20_007;
 
  -- AAda Compiler message handling
  procedure todo(compiler_error: in out aada_compiler_error;
                  code: in errcode;
                  position: aada_compiler_token_position.token_position_type;
                  message: in string);
 
  procedure error(compiler_error: in out aada_compiler_error;
                  code: in errcode;
                  position: aada_compiler_token_position.token_position_type;
                  message: in string);
 
  procedure warning(compiler_error: in out aada_compiler_error;
                    code: in errcode;
                    position: aada_compiler_token_position.token_position_type;
                    message: in string);
 
private
 
  type aada_compiler_error is
    record
      -- number of todo, errors, and warnings found along the way
      todo_count: natural := 0;
      error_count: natural := 0;
      warning_count: natural := 0;
      -- warnings are errors
      warnings_are_errors: boolean := false;
    end record;
 
end aada_compiler_error_package;
 
-- vim: ts=2 sw=2 et syntax=ada
Project aada v1.0-338 (Project id #3)
Process Done (Last compiled on 2012/01/13 01:21:26)
Description Alexis Ada Compiler written in Ada (my first attempt was in C++ which is not correct for an Ada compiler.)
Syndicate content