elena-lang
elena-lang copied to clipboard
Support enumeration list
Enumeration list (set of named constants) should be supported.
The proposed syntax:
enum Color : enumeration(Red = 1, Blue = 2, Green = 3);
public program()
{
Color color := Color.Red;
}
A special template might be introduced - enumof So for example the following C code
enum { RED, GREEN, /*...*/ WHITE }
will look in ELENA:
#subject color = enumof:int.
#symbol(color)RED = 0FF0000h.
#symbol(color)GREEN = 000FF00h.
// ...
#symbol(color)WHITE = 0FFFFFFh.
Special attribute is introduced enumlist.
The base class is stateless and limited and cannot be directly initiated, though it is possible to return the children. All children / enum list values should be declared in the same module.
#class(enumlist)Color
{
#constructor red = RED.
#constructor greeen = GREEN.
#method int = $nil.
}
#symbol RED = Color
{
#method int = 0FF0000h.
}
#symbol GREEN= Color
{
#method int = 000FF00h.
}