Skip to content

Instantly share code, notes, and snippets.



Created Jun 24, 2019
What would you like to do?
package metaobjectTest
Annotation 'rpn' takes an expression in Reverse Polish Notation (RPN)
in the attached DSL and evaluates it at compile-time. The annotation
is an expression of type Int. Only positive integer numbers are allowed
in the RPN expression.
This is a demonstration metaobject.
object Rpn
func run {
let value = @rpn{* 1 2 3 * + *};
assert value = 7;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment