macro_processor 0.0.2 macro_processor: ^0.0.2 copied to clipboard
Lightweight macro processor with syntax similar to C language.
import "package:macro_processor/macro_processor.dart";
void main() {
var processor = new MacroProcessor();
var environment = {};
environment["OS"] = "linux";
var blocks = processor.process(text, environment);
var result = blocks.map((e) => e.text).join();
print(result);
;
}
String text = '''
#define _SIZE_OF_POINTER_ 64
#define _64BIT_ 0x1p7 / (012 / 0x5)
#define _NOT_32BIT_ _64BIT_
#if _SIZE_OF_POINTER_ == _NOT_32BIT_
#error
#endif
#define _HELLO_ _HI_
#define _HI_ Hello
#if OS == windows
_HELLO_ OS
#elif OS == linux
_HELLO_ OS
Bye windows!
#else
_HELLO_ OS
#endif
#define E YEE!
1E2 E
#define _MIN_VERSION_ 100
#define _VERSION_ 180
#if _VERSION_ < _MIN_VERSION_
#error Wrong version
#endif
Our version: _VERSION_''';