jsmacro icon indicating copy to clipboard operation
jsmacro copied to clipboard

Allow @include within @ifdefs to conditionally include files

Open smartt opened this issue 13 years ago • 1 comments

smartt avatar Sep 12 '12 21:09 smartt

I think this requires the parsing to be rewritten to go line by line instead of how it is now. Consider for example:

//@define DEBUG 0

var foo = function() {
  //@if DEBUG
  // define inside if needs to work first, and is simpler to demonstrate.
  //@define FOO 1
  //@end

  var bar = "Hello World";

  //@if FOO
  alert('This.');
  alert('That.');
  //@end
};

The way the parsing works now, no matter how you order things, you will never get the expected result. If you parse defines first, you will always get FOO defined to 1, even if DEBUG is 0, and if you parse if/ifdef/else/end first, DEBUG will not have been defined yet.

Skylark13 avatar Feb 11 '13 20:02 Skylark13