1 /* $Id: advance.h,v 1.10 2003/10/14 21:41:08 moniot Exp $ 2 3 Declarations shared between advance.c and include.c 4 5 Copyright (c) 2001 by Robert K. Moniot. 6 7 Permission is hereby granted, free of charge, to any person 8 obtaining a copy of this software and associated documentation 9 files (the "Software"), to deal in the Software without 10 restriction, including without limitation the rights to use, 11 copy, modify, merge, publish, distribute, sublicense, and/or 12 sell copies of the Software, and to permit persons to whom the 13 Software is furnished to do so, subject to the following 14 conditions: 15 16 The above copyright notice and this permission notice shall be 17 included in all copies or substantial portions of the 18 Software. 19 20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 21 KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 22 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 23 PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 24 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 26 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 27 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 29 Acknowledgement: the above permission notice is what is known 30 as the "MIT License." 31 */ 32 33 #ifdef ADVANCE 34 #define ADVANCE_SHARED 35 #else 36 #define ADVANCE_SHARED extern 37 #endif 38 39 ADVANCE_SHARED 40 int 41 next_index, /* Index in line of next_char */ 42 noncomment_line_count, /* Number of noncomment lines read so far */ 43 sticky_EOF; /* Signal to delay EOF a bit for sake 44 of error messages in include files. */ 45 46 ADVANCE_SHARED 47 LINENO_t 48 prev_line_num; /* line number of previous input line */ 49 50 51 /* Standard maximum line length depends on source form. */ 52 ADVANCE_SHARED 53 COLNO_t 54 std_max_stmt_col; 55 56 /* Define tab stops: NXTCOL(c,col_num) is next column after col_num. 57 This formula maps [1-8]->9, [9-16]->17, etc. if C is a tab, 58 otherwise just adds 1 to COL. 59 */ 60 #define NXTCOL(C,COL) ((C)=='\t'?( (((COL)-1)/8+1)*8+1 ):COL+1) 61 /* This is the same but counts tabs, for support of -port=tab warning */ 62 #define PORT_NXTCOL(C,COL) ((C)=='\t'?(++tab_count, (((COL)-1)/8+1)*8+1 ):COL+1) 63 64 /* Definition of source-line buffer structure. Source file is read in 65 entirely before processing begins. 66 */ 67 68 struct src_line { 69 char *line; /* buffer holding source code of line */ 70 struct src_line *next, /* link to next line */ 71 *prev; /* link to prev line */ 72 LINENO_t line_num; /* number of line within source file */ 73 int start_index, end_index; /* span containing interesting source */ 74 COLNO_t start_col; /* like start_index but accounts for tabs */ 75 unsigned 76 printed: 1, /* line has been printed */ 77 /* Flags indicating categories of lines */ 78 contin: 1, /* line is a continuation line */ 79 comment: 1, /* line is a comment line */ 80 blank: 1, /* line is blank (implies comment) */ 81 cpp_line_directive: 1, /* Unix #line directive */ 82 /* the next flags are for f77 or f90 warnings */ 83 d_comment: 1, /* line is a 'D' comment */ 84 f90_comment: 1, /* line is or has an '!' comment */ 85 overlength: 1, /* line exceeds std max length */ 86 empty_contin: 1, /* line is an '&' on otherwise comment line */ 87 contin_wo_amp: 1; /* freeform continued line lacks initial '&' */ 88 }; 89 90 91 typedef struct src_line srcLine; 92 93 ADVANCE_SHARED 94 LINENO_t prev_stmt_line_num; /* line number of previous noncomment */ 95 96 #if 0 /* this approach would require sharing advance.h just for this */ 97 ADVANCE_SHARED 98 srcLine *prev_stmt_srcLine; /* source line of previous noncomment */ 99 100 /* macro to yield line number of previous noncomment. */ 101 #define prev_stmt_line_num (prev_stmt_srcLine?prev_stmt_srcLine->line_num:(LINENO_t)1) 102 #endif 103 104 ADVANCE_SHARED 105 srcLine *curr_srcLine, /* rec of line being lexed */ 106 *next_srcLine, /* rec of line on deck */ 107 *srcBuffer /* 1st rec of source buffer for current file */ 108 #ifdef ADVANCE 109 = (srcLine *)NULL 110 #endif 111 ; 112 113 ADVANCE_SHARED 114 srcLine *mkhtml_bookmark; /* used by mkhtml to find start of subprog */ 115 116 PROTO(srcLine * gulp_srcfile,(FILE *fd)); 117 PROTO(void free_srcBuffer, (srcLine *srcBuffer)); 118 119 #ifdef MACINTOSH 120 #define ENDL '\r' 121 #else 122 #define ENDL '\n' 123 #endif 124