Skip to content
Tim Disney edited this page Feb 14, 2014 · 1 revision

How do I output comments?

Comments in a rule macro or inside a #{...} template should "just work". If you want to create comment strings programmatically you can use a token's leadingComments property.

macro m {
	case {_ () } => {
		var x = makeValue(42, #{here});
		x.token.leadingComments = [{
			type: "Line",
			value: "hello, world"
		}];
		return withSyntax ($x = [x]) #{
			$x
		}
	}
}
m()

will expand to

//hello, world
42;