Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Macro expansion callback: http://ideone.com/aKLt9
- Input:
- ==============================
- std::string input =
- "Greeting is <<hello>> world!\n"
- "Side effects are <<sideeffect>> and <<other>> vars are untouched\n"
- "Empty <<>> macros are ok, as are stray '>>' pairs.\n"
- "<<nested <<macros>> (<<hello>>?) work>>\n"
- "The order of expansion (evaluation) is _eager_: '<<<<hello>>>>' will expand to the same as '<<bye>>'\n"
- "Lastly you can do algorithmic stuff too: <<!esrever ~ni <<hello>>>>\n"
- #ifdef SUPPORT_ESCAPES // bonus: escapes
- "You can escape \\<<hello>> (not expanded to '<<hello>>')\n"
- "Demonstrate how it <<avoids <\\<nesting\\>> macros>>.\n"
- #endif
- ;
- Output:
- ==============================
- this is a side effect while parsing
- Greeting is bye world!
- Side effects are (done) and <<other>> vars are untouched
- Empty <<>> macros are ok, as are stray '>>' pairs.
- <<nested <<macros>> (bye?) work>>
- The order of expansion (evaluation) is _eager_: 'We meet again' will expand to the same as 'We meet again'
- Lastly you can do algorithmic stuff too: eyb in reverse!
- You can escape <<hello>> (not expanded to 'bye')
- Demonstrate how it <<avoids <<nesting>> macros>>.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement