Skip to content

Instantly share code, notes, and snippets.

@joseoliv
Created June 27, 2019 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joseoliv/fe2d422cba143d64e6101ba78ff3782f to your computer and use it in GitHub Desktop.
Save joseoliv/fe2d422cba143d64e6101ba78ff3782f to your computer and use it in GitHub Desktop.
cep
package metaobjectTest
@doc{*
This annotation takes two parameters. The first is a number. There should be
an error from the line of the annotation plus this number. The second parameter
is the error message that the compiler should issue (or a similar message).
The compiler checks if there is an error in the indicated line. If not,
an error message is issued. That is, suppose the code
@cep(1, "Expression expected)
var k = 1 + ;
is in a file being compiled. The compiler will point the error and print
a message that a metaobject pointed out that there is an error in the line
with the real error. If there were no error, the compiler would issue an
error telling that it itself should have pointed out an error in the line
"var k = 1 + ;".
*}
object Cep
func run {
@cep(3, "Type error")
@cep(1, "Expression expected)
var k = 1 + ;
1 + "A string cannot be added to an Int";
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment