diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-27 13:55:36 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-27 13:55:36 +0000 |
| commit | a91bd145008432fb8c5d91d94ab6f50473a277f5 (patch) | |
| tree | 87af3ebcd2888e129bad9863574567e1c97bb18b /include | |
| parent | 24f410430b33aaf1f288b83ea37e18fa959e9d3e (diff) | |
feat(preprocessor): add file-local conditional switches
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/cps/Lexer.h | 8 | ||||
| -rw-r--r-- | include/cps/Preprocessor.h | 19 |
2 files changed, 26 insertions, 1 deletions
diff --git a/include/cps/Lexer.h b/include/cps/Lexer.h index bec1233..05fb857 100644 --- a/include/cps/Lexer.h +++ b/include/cps/Lexer.h @@ -113,7 +113,13 @@ enum Token { tok_try = -700, tok_catch = -701, tok_endtry = -702, - tok_throw = -703 + tok_throw = -703, + + tok_pp_define = -710, + tok_pp_undef = -711, + tok_pp_ifdef = -712, + tok_pp_ifndef = -713, + tok_pp_endif = -714 }; class Lexer { diff --git a/include/cps/Preprocessor.h b/include/cps/Preprocessor.h new file mode 100644 index 0000000..ebc2806 --- /dev/null +++ b/include/cps/Preprocessor.h @@ -0,0 +1,19 @@ +#pragma once +#include <istream> +#include <string> +#include <vector> + +namespace cps { + +struct PreprocessedSource { + std::string Text; + // One entry per original source line, before processing that line's directive. + std::vector<bool> LibraryLines; + bool HadError = false; +}; + +// Switches and conditional nesting belong to this input only. Masked lines retain +// their byte lengths and line endings so the lexer sees original source locations. +PreprocessedSource preprocess(std::istream &Input); + +} |
