Skip to content

Instantly share code, notes, and snippets.

View joseoliv's full-sized avatar

José de Oliveira Guimarães joseoliv

View GitHub Profile
@joseoliv
joseoliv / Cyan-in-20-minutes
Last active August 30, 2022 12:53
Cyan in 20 minutes
package main
// import a Cyan package
import cyan.math
import cyan.reflect
// import a Java package
import java.lang
@doc{*
@joseoliv
joseoliv / Helloworld.cyan
Last active March 12, 2021 18:44
Hello world program in Cyan
package main
object Program
func run {
"Hello world" println
}
end
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)
@joseoliv
joseoliv / SymbolToString.cyan
Created June 26, 2019 22:25
symbolToString
package metaobjectTest
@doc{*
Annotation 'symbolToString' takes a single parameter and produces
a string whose contents is the parameter. Then the annotation is
an expression of type String.
This annotation is used mainly in generic prototypes to convert
a generic parameter to a string.
@joseoliv
joseoliv / Shout.cyan
Last active March 25, 2020 16:17
shout
package metaobjectTest
@doc{*
Annotation 'shout' can be attached to a method. It changes
all strings to uppercase letters. This is a demonstration
metaobject, of course.
*}
object Shout
@joseoliv
joseoliv / ShouldCallSuperMethod
Created June 25, 2019 04:13
shouldCallSuperMethod
package metaobjectTest
@doc{*
Metaobject 'shouldCallSuperMethod' is an action function. Its
associated metaobject declares a method 'eval' that may be
called by other metaobjects. It cannot be associated to
an annotation:
// compile-time error
@shouldCallSuperMethod
@joseoliv
joseoliv / GetPackageValueFromKey.cyan
Created June 25, 2019 03:58
getPackageValueFromKey
package metaobjectTest
@doc{*
Annotation 'GetPackageValueFromKey' is String expression. It is
"" if its parameter is not a key of the package of the current
prototype. If it is, the expression is the value associated to
the key in the package but transformed into a string by either
method toString of Java or method asString of Cyan.
@joseoliv
joseoliv / GetProgramValueFromKey.cyan
Created June 25, 2019 03:55
getProgramValueFromKey
package metaobjectTest
@doc{*
Annotation 'getProgramValueFromKey' is String expression. It is
"" if its parameter is not a program key. If it is, the expression
is the value associated to the key in the program but
transformed into a string by either method toString of Java or
method asString of Cyan.
@joseoliv
joseoliv / SetVariable.cyan
Last active June 25, 2019 03:49
setVariable
package metaobjectTest
@doc{*
Annotation 'setVariable' can be attached to the program or a package.
It takes two parameters, a key and a value, and associates the
program or package key to the value. If the attached annotation is
the program, the value can be got from method
Object getProgramValueFromKey(String key)
of WrProgram. If the attached annotation is a package, the value can
package metaobjectTest
import cyan.io
@doc{*
Annotation 'runPastCode'
*}
object RunPastCode