Mercurial > hg > index.cgi
annotate lwcc/cpp.h @ 301:6f7fe78bb868 ccdev
Add string -> number conversion for preproc expression evaluator
Q&D conversion from string to signed number. It should be noted that this
really should be done during tokenization and the type of number be set by
the tokenizer, including parsing floating point values. Then the
preprocessor can decide what to do with non-integer numbers.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sun, 15 Sep 2013 14:22:10 -0600 |
parents | 8d6c47395653 |
children | d85d173ba120 |
rev | line source |
---|---|
295 | 1 /* |
2 lwcc/cpp.h | |
3 | |
4 Copyright © 2013 William Astle | |
5 | |
6 This file is part of LWTOOLS. | |
7 | |
8 LWTOOLS is free software: you can redistribute it and/or modify it under the | |
9 terms of the GNU General Public License as published by the Free Software | |
10 Foundation, either version 3 of the License, or (at your option) any later | |
11 version. | |
12 | |
13 This program is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
16 more details. | |
17 | |
18 You should have received a copy of the GNU General Public License along with | |
19 this program. If not, see <http://www.gnu.org/licenses/>. | |
20 */ | |
21 | |
22 #ifndef cpp_h_seen___ | |
23 #define cpp_h_seen___ | |
24 | |
25 #include <stdio.h> | |
26 | |
296 | 27 //#include "symbol.h" |
295 | 28 #include "token.h" |
29 | |
30 #define TOKBUFSIZE 32 | |
31 | |
296 | 32 struct expand_e |
33 { | |
34 struct expand_e *next; | |
35 struct symtab_e *s; // symbol table entry of the expanding symbol | |
36 }; | |
37 | |
295 | 38 struct preproc_info |
39 { | |
40 const char *fn; | |
41 FILE *fp; | |
42 struct token *tokqueue; | |
296 | 43 struct token *curtok; |
295 | 44 void (*errorcb)(const char *); |
45 void (*warningcb)(const char *); | |
296 | 46 int eolstate; // internal for use in handling newlines |
47 int lineno; // the current input line number | |
48 int column; // the current input column | |
49 int trigraphs; // nonzero if we're going to handle trigraphs | |
295 | 50 int ra; |
51 int qseen; | |
52 int ungetbufl; | |
53 int ungetbufs; | |
54 int *ungetbuf; | |
55 int unget; | |
56 int eolseen; | |
57 int nlseen; | |
296 | 58 int ppeolseen; // nonzero if we've seen only whitespace (or nothing) since a newline |
59 int skip_level; // nonzero if we're in a false conditional | |
60 int found_level; // nonzero if we're in a true conditional | |
61 int else_level; // for counting #else directives | |
62 int else_skip_level; // ditto | |
63 struct symtab_e *sh; // the preprocessor's symbol table | |
64 struct token *sourcelist; // for expanding a list of tokens | |
65 struct expand_e *expand_list; // record of which macros are currently being expanded | |
298
6112c67728ba
Add stringification and token concatenation
William Astle <lost@l-w.ca>
parents:
296
diff
changeset
|
66 char *lexstr; // for lexing a string (token pasting) |
6112c67728ba
Add stringification and token concatenation
William Astle <lost@l-w.ca>
parents:
296
diff
changeset
|
67 int lexstrloc; // ditto |
300 | 68 struct preproc_info *n; // next in file stack |
69 struct preproc_info *filestack; // stack of saved files during include | |
295 | 70 }; |
71 | |
72 extern struct preproc_info *preproc_init(const char *); | |
73 extern struct token *preproc_next_token(struct preproc_info *); | |
296 | 74 extern struct token *preproc_next_processed_token(struct preproc_info *); |
295 | 75 extern void preproc_finish(struct preproc_info *); |
76 extern void preproc_register_error_callback(struct preproc_info *, void (*)(const char *)); | |
77 extern void preproc_register_warning_callback(struct preproc_info *, void (*)(const char *)); | |
78 extern void preproc_throw_error(struct preproc_info *, const char *, ...); | |
79 extern void preproc_throw_warning(struct preproc_info *, const char *, ...); | |
296 | 80 extern void preproc_unget_token(struct preproc_info *, struct token *); |
81 | |
295 | 82 #endif // cpp_h_seen___ |