Lhogho  0.0.028
 All Data Structures Files Functions Variables Typedefs Macros Pages
errors.h
Go to the documentation of this file.
1 //
2 // Project: Lhogho
3 // File: errors.h
4 //
5 // Copyright (C) 2007 P.Boytchev
6 //
7 // Revision history:
8 // 2007-06-01 - file created
9 // 2007-06-03 - errors renamed
10 // - ERROR_CROWDED_SOURCES, ERROR_OS_ERROR
11 // - ERROR_INCOMPATIBLE_REDEFINITION
12 // 2007-06-05 - definitions spread to where they belong
13 // 2007-06-09 - added dump_error()
14 // 2007-06-26 - ERROR_NOT_A_NUMBER
15 // 2007-07-01 - ERROR_UNUSED_VALUE
16 // - ERROR_MISSING_VALUE
17 // 2007-09-09 - ERROR_DO_NOT_KNOW
18 // - ERROR_UNKNOWN_VAR
19 //
20 // 2007-09-17 - ERROR_BOOLEAN_EXPECTED
21 // 2007-09-21 - ERROR_NOT_AN_INTEGER, ERROR_NOT_A_LIST
22 // 2007-10-06 - ERROR_NOT_A_WORD
23 // 2007-10-13 - ERROR_INCOMPATIBLE_DATA
24 // 2007-10-17 - ERROR_TOO_BIG_NUMBER, ERROR_TOO_SMALL_NUMBER
25 // 2007-11-04 - ERROR_NOT_A_VAR
26 // 2007-11-12 - EXIT_BY_BYE, EXIT_BY_THROW_TOPLEVEL, EXIT_BY_THROW_SYSTEM
27 // - THROW
28 // 2007-11-15 - EXIT_BY_THROW_TAG
29 // 2008-01-05 - ERROR_VAR_HAS_NO_VALUE
30 // 2008-05-08 - ERROR_NOT_A_FUNCTION
31 // 2008-09-11 - ERROR_NOT_A_TYPE_NAME
32 // 2008-09-13 - ERROR_BAD_PROTOTYPE
33 // 2008-11-22 - ERROR_NOT_A_MEM
34 // 2011-12-26 - Error messages taken from string, stored to array of atoms
35 // 2012-01-20 - Added new_os_error_atom()
36 // 2012-02-02 - ERROR_FILE_NOT_OPENED
37 //
38 //
39 // This program is free software; you can redistribute it and/or modify
40 // it under the terms of the GNU General Public License as published by
41 // the Free Software Foundation; either version 2 of the License, or
42 // (at your option) any later version.
43 //
44 // This program is distributed in the hope that it will be useful,
45 // but WITHOUT ANY WARRANTY; without even the implied warranty of
46 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47 // GNU General Public License for more details.
48 //
49 // You should have received a copy of the GNU General Public License
50 // along with this program; if not, write to the Free Software
51 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
52 //
53 
54 
55 #ifndef LHOGHO_ERRORS_H
56 #define LHOGHO_ERRORS_H
57 
58 
59 #include "atoms.h"
60 
61 
62 
63 //===================================================
66 //===================================================
67 #define ERROR_INCOMPLETE_PAIR 1
68 #define ERROR_EMPTY_EXPRESSION 2
69 #define ERROR_CROWDED_EXPRESSION 3
70 #define ERROR_MISSING_LEFTS 4
71 #define ERROR_MISSING_RIGHTS 5
72 #define ERROR_EMPTY_TO_END 6
73 #define ERROR_MISSING_NAME 7
74 #define ERROR_DUPLICATE_INPUT 8
75 #define ERROR_UNKNOWN_OPTION 9
76 #define ERROR_CROWDED_SOURCES 10
77 #define ERROR_OS_ERROR 11
78 #define ERROR_INCOMPATIBLE_REDEFINITION 12
79 #define ERROR_NOT_A_NUMBER 13
80 #define ERROR_UNUSED_VALUE 14
81 #define ERROR_MISSING_VALUE 15
82 #define ERROR_DO_NOT_KNOW 16
83 #define ERROR_UNKNOWN_VAR 17
84 #define ERROR_BOOLEAN_EXPECTED 18
85 #define ERROR_NOT_AN_INTEGER 19
86 #define ERROR_NOT_A_LIST 20
87 #define ERROR_NOT_A_WORD 21
88 #define ERROR_INCOMPATIBLE_DATA 22
89 #define ERROR_TOO_BIG_NUMBER 23
90 #define ERROR_TOO_SMALL_NUMBER 24
91 #define ERROR_NOT_A_VAR 25
92 #define EXIT_BY_BYE 26 // BYE
93 #define EXIT_BY_THROW_TOPLEVEL 27 // THROW "TOPLEVEL
94 #define EXIT_BY_THROW_SYSTEM 28 // THROW "SYSTEM
95 #define EXIT_BY_THROW_ERROR 29 // THROW "ERROR
96 #define EXIT_BY_THROW_USER_ERROR 30 // THROW "ERROR <value>
97 #define EXIT_BY_THROW_TAG 31 // THROW <tag>
98 #define EXIT_BY_THROW_TAG_VALUE 32 // THROW <tag> <value>
99 #define ERROR_NOT_A_TAG 33
100 #define ERROR_NOT_A_USER_FUNCTION 34
101 #define ERROR_VAR_HAS_NO_VALUE 35
102 #define ERROR_NOT_A_FUNCTION 36
103 #define ERROR_NOT_A_LIST_CONST 37
104 #define ERROR_NOT_A_WORD_CONST 38
105 #define ERROR_MISSING_FOR_LIMITS 39
106 #define ERROR_NOT_A_TYPE_NAME 40
107 #define ERROR_BAD_PROTOTYPE 41
108 #define ERROR_NOT_A_MEM 42
109 #define ERROR_OUT_OF_MEM 43
110 #define ERROR_FILE_NOT_OPENED 44
111 #define ERROR_NOT_BLOCK_OR_DEF 45
112 //#define WARNING_UNSUPPORTED_COMPILER 43
113 
114 
115 #define FIRST_EXIT_CODE 26
116 #define LAST_EXIT_CODE 32
117 #define LAST_ERROR_CODE 45
118 
119 //===================================================
125 //===================================================
127 #define ERRCODE(x) ((x)->unode.s[3])
128 #define ERRPOS(x) ((x)->unode.a[2])
129 #define ERRDATA(x) ((x)->unode.a[3])
130 
131 #define IS_ERROR(x) (ID(x)==ERROR_ID)
132 
134 
135 #define FORMAT_ERR_CODE TEXT("{ERR#%d")
136 #define FORMAT_ERR_POS TEXT("@%d}")
137 
138 
139 extern atom_t error_texts[];
140 extern int last_os_error;
141 
142 extern void init_errors( );
143 extern void finit_errors( );
144 extern atom_t new_error( uint_t code, atom_t data );
145 extern atom_t new_os_error( chars_t filename );
146 extern atom_t new_os_error_atom( atom_t filename );
147 extern atom_t new_parse_error( uint_t code, int position, atom_t source );
148 
149 extern void add_error_source( atom_t error, atom_t source );
150 extern int get_error_position( atom_t data, chars_t* source );
151 
152 extern void delete_error( atom_t a );
153 extern void dump_error( atom_t a, int level );
154 extern void clear_all_errors( );
155 
156 #endif //LHOGHO_ERRORS_H

[ HOME | INDEX | ATOMS | VARS | REFERENCE ]
Lhogho Developer's Documentation
Wed Jul 10 2013