Skip to content

Instantly share code, notes, and snippets.

@joseoliv
Created June 24, 2019 07:26
Show Gist options
  • Save joseoliv/f10dbcffc00b4443e97ba4e5e3cf2d64 to your computer and use it in GitHub Desktop.
Save joseoliv/f10dbcffc00b4443e97ba4e5e3cf2d64 to your computer and use it in GitHub Desktop.
rpn
package metaobjectTest
@doc{*
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;
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment