Skip to content

Instantly share code, notes, and snippets.

View Property.cyan
package metaobjectTest
@doc{*
Annotation 'property' should be attached to a field. It creates
get and, maybe, set methods for the field. There are four
possibilities for a field of type T:
- the field is declared with 'let' (or without 'var') and
. the field name stars with '_' like '_name'. Then method
func name -> T = _name;
View ParametersToString.cyan
package metaobjectTest
@doc{*
Annotation 'parametersToString' takes any number of parameters
and produces a string with all of them. This is a demonstration
metaobject.
*}
open
object ParametersToString
View SubOverrideTest.cyan
package main
object SubOverrideTest extends metaobjectTest.OverrideTest
override
func withdraw: Int amount { super withdraw: amount }
end
View OverrideTest.cyan
package metaobjectTest
@doc{*
Annotation 'overrideTest' should be attached to a method.
It generates a file with a prototype for testing with
the contents of the attached DSL whenever the attached
method is overridden in a subprototype. Let us see the details.
The following checks are made whenever the method attached
@joseoliv
joseoliv / OnVariableDeclaration.cyan
Last active Aug 30, 2022
onVariableDeclaration
View OnVariableDeclaration.cyan
package metaobjectTest
@doc{*
Annotations of this metaobject should be attached to a local
variable. The attached DSL code is made in Myan, which supports
interpreted Cyan within parameterless methods declared with 'func':
func afterResTypes_codeToAdd {
// interpreted Cyan code
View OnSubprototype.cyan
package metaobjectTest
@doc{*
Annotations of this metaobject should be attached to a prototype. The
Cyan code attached to the annotation is run in phase afterSemAn. Method
afterSemAn_checkSubprototype of the class of metaobject onSubprototype,
overridden from ICheckSubprototype_afterSemAn, just interpret the Cyan
statements attached to the annotation.
@joseoliv
joseoliv / OnOverride_afterResTypes_semAn_afterSemAn.cyan
Last active Aug 30, 2022
onOverride_afterResTypes_semAn_afterSemAn
View OnOverride_afterResTypes_semAn_afterSemAn.cyan
package metaobjectTest
@doc{*
Annotations of this metaobject should be attached to a method.
The attached DSL code is made in Myan, which supports interpreted Cyan
within parameterless methods declared with 'func':
func afterResTypes_codeToAdd {
// interpreted Cyan code
View OnOverride.cyan
package metaobjectTest
@doc{*
Annotations of this metaobject are attached to a declaration. The
Cyan code attached to the annotation is run in phase afterSemAn. Method
afterSemAn_checkOverride of the class of metaobject onOverride,
overridden from ICheckOverride_afterSemAn, just interpret the Cyan
statements attached to the annotation.
@joseoliv
joseoliv / OnOverride_afterResTypes_semAn_afterSemAn.cyan
Last active Aug 30, 2022
onOverride_afterResTypes_semAn_afterSemAn
View OnOverride_afterResTypes_semAn_afterSemAn.cyan
package metaobjectTest
@doc{*
Annotations of this metaobject should be attached to a method.
The attached DSL code is made in Myan, which supports interpreted Cyan
within parameterless methods declared with 'func':
func afterResTypes_codeToAdd {
// interpreted Cyan code
View OnMethodMissing.cyan
package metaobjectTest
@doc{*
Annotations of this metaobject should be attached to a prototype.
The attached DSL code is made in Myan, which supports interpreted Cyan
within parameterless methods declared with 'func':
func afterResTypes_codeToAdd {
// interpreted Cyan code