macro_rocessor

Lightweight macro processor with syntax similar to C language.

Version: 0.0.12

Initial release. Use at your own risk!

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_''';

Libraries

macro_processor
macro_processor.expression_evaluator
macro_processor.internal.ast
macro_processor.internal.parsers.directive_parser
macro_processor.internal.parsers.expression_parser
macro_processor.macro_definition
macro_processor.macro_expander