-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.h
65 lines (56 loc) · 2.05 KB
/
error.h
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
/* error.h: Copyright (C) 2011 by Brian Raiter <[email protected]>
* License GPLv2+: GNU GPL version 2 or later.
* This is free software; you are free to change and redistribute it.
* There is NO WARRANTY, to the extent permitted by law.
*/
#ifndef _error_h_
#define _error_h_
/*
* This module provides basic reporting and tracking of errors that
* occur while processing input files.
*/
/* The complete list of error message types.
*/
enum errortype
{
errNone = 0,
errSyntax, /* general syntax error */
errFileIO, /* file I/O failure (see errno) */
errBadCharLiteral, /* invalid character sequence in quotes */
errOpenCharLiteral, /* unclosed single quote */
errOpenStringLiteral, /* unclosed double quote */
errOpenComment, /* unclosed multi-line comment */
errBrokenComment, /* comment spanning removed line */
errDanglingElse, /* unmatched #else found */
errDanglingEnd, /* unmatched #end found */
errOpenIf, /* unclosed #if */
errIfsTooDeep, /* way too many nested #ifs */
errOpenParenthesis, /* unclosed left parenthesis */
errMissingOperand, /* operand expected to follow expression */
errZeroDiv, /* division by zero in an expression */
errEmptyIf, /* missing #if parameter */
errIfSyntax, /* general syntax error inside #if parameter */
errDefinedSyntax, /* general syntax error in defined operand */
errCount
};
/* Displays a formatted error message to the user.
*/
extern void error(enum errortype type);
/* Sets the input filename to display in error messages.
*/
extern void seterrorfile(char const *file);
/* Sets the current line number for the input filename, to be
* displayed when errors are reported.
*/
extern void seterrorline(unsigned long lineno);
/* Increments the current line number.
*/
extern void nexterrorline(void);
/* Returns the number of errors that have occurred so far.
*/
extern int geterrormark(void);
/* Returns true if any new errors have occurred since the given mark
* was retrieved.
*/
extern int errorsincemark(int mark);
#endif