Copyright (c) 2004 David Jobet. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".
Table of Contents
List of Examples
Table of Contents
An application starts by calling Nosica's entry point. Nosica's entry point is identified by the following signature :
A Nosica application takes as input a list of string parameters. The size of the array is the number of arguments on the command line plus the name of the executable used to launch the application. Therefore,
args[0] returns the name of the executable
args[1] return the first argument (if any)
...
args[N - 1] returns the last argument (if any)
With N the size of the array (args.length)
Before the actual main of a Nosica program is called, the static initializer of each classes get called. The order in which they get called is not specified and is implementation dependant.
A Nosica application cannot return a value. It must use the System.exit method to do so. If it is not used at all, then the default return value is used (which is 0).
After the actual main of a Nosica program is executed, the static deinitializer of each classes get called. The order in which they get called is not specified and is implementation dependant.
A Nosica source file is made of several parts :
An optional package declaration
An optional list of import declarations
One or more top level Nosica declaration. A top level Nosica declaration is either a class, an interface, an enum, or a metadata type description.
Nosica's top level declarations get their namespaces name from the package in which they get defined, and their own name. Their complete name must match the filesystem's topology.
Example 1.2. TypeName constitution
package package1;
class Test {}
In this example, the complete name of class Test is package1.Test.
It is possible to refer to an other type by their complete name, or by a shorter name provided they get imported. By default, when importing another type, the short name is the name of the type. It is possible to provides an alternate short name.
Example 1.3. Importing a class
import package1.Test;
import package1.Test MyTest;
The first import form allows one to import package1.Test. The rest of the program can refer to it directly via the name "Test". The second import form allows one to import a type and provide its own custom short name. This is particularly usefull when several classes have same name in different packages.
It is possible to define several classes in the same Nosica source file, provided they bear the same name. This is only usefull with generic classes and partial specialisation. This is of no use for interfaces, enum and metadata.
Example 1.4. Generic class declaration
class HashMap<T>
{
// default implementation
}
class HashMap<string>
{
// specific implementation for strings
}
The first form defines a class HashMap that can be applied on any type T. The second form specifies a custom implementation to use when T is in fact a string.
Classes, Interfaces, enums and Metadata have members.
Classes can contain :
at most static initializer
at most static deinitializer
constructors
at most one destructor
methods
properties
operators
cast operators if type is primitive
fields
nested type declaration
An enum is composed of a list of symbolic typed constants. An enum provide a list of transformation functions to/from int/string.
The former example can be seen as syntactic sugar for the following :
class Color implements Enum<Color> {
private int id;
private constructor(int id) { this.id = id; }
private static string[] strings = {"RED", "GREEN", "BLUE"};
static public Color RED = new Color(0);
static public Color GREEN = new Color(1);
static public Color BLUE = new Color(2);
string toString() { return strings[id]; }
int toInt() { return id; }
static Color fromString(string id) {
if (id.equals("RED")) return RED;
if (id.equals("GREEN")) return GREEN;
if (id.equals("BLUE")) return BLUE;
return null;
}
static Color fromInt(int id) {
switch (id)
{
case 0 : return RED;
case 1 : return GREEN;
case 2 : return BLUE;
default : return null;
}
}
}
By default a member has "package" access. That means, it is accessible only by members of the same package. All Nosica top declarations can have either package or public access.
Additionally, it is possible to define finer grain accessibility for classes members :
public : accessible from anywhere
protected : accessible only from derived classes
private : accessible only by members of enclosing class
Uniqueness of a member (its signature) is defined by several properties :
member's type
member's name
member's arguments
member's modifiers
an argument is defined by its type and its varness. ("var" keyword)
member's modifier are staticness and varness. ("static" and "var" keywords)
It is possible to define several members having several same properties, provided at least one property is different. If two members have strictly same properties, this is a compil time error.
Basically, in a nested scope, you cannot hide a name of an enclosing scope. One exception to this is fields : as they can be accessed via the 'this' variable, you're allowed to hide them by a local variable or a method's argument.
The scope of a variable is its enclosing block.
The scope of an argument is the method.
The scope of a field is its class and all methods defined in the class and all inner sub classes (not nested classes).
The scope of variables defined inside a for or foreach statement is the block of the statement.
The memory management for an object starts when the object is created via the "new" static method of the type
memory is allocated for it, and the constructor is run
when the object is no longer in used (the last reference to it reaches end of scope or is assigned another value), then the destructor must be run and the memory reclaimed
Note that the contraint "as soon as" imposes a reference counting algorithm. Thus it does not handle circle references. This may change in the future.
When implemening a method of an interface :
Result types are allowed to be covariant.
Input parameters are allowed to be covariant if and only if a method with invariant parameters is defined.
Example 1.6. covariant example
class A {}
class B extends A {}
interface I {
sub f(A a);
}
class IImpl1 implements I {
public sub f(A a) {} // OK IImpl1.f really implements I.f (arguments are invariant)
}
class IImpl2 implements I {
public sub f(B b) {} // Error IImpl2.f does not implement I.f (arguments are covariant)
}
class IImpl3 implements I {
public sub f(A a) {} // OK IImpl1.f really implements I.f (arguments are invariant)
public sub f(B b) {} // OK IImpl2.f can implements I.f with covariant arguments because IImpl3.f with invariant arguments exist
}
Dispatching is done on all arguments.
Most of the time, dispatching will be done only on the first argument (the 'this' argument), but provided several methods with covariant arguments exist, all necessary arguments will be taken into account to perform the dispatching.
Fields can be marked as proxy of a type.
The provided type must be a super type of the field's type.
All methods of the given interface are automatically "added" to the enclosing type, and the implementation consists of a delegation to the field.
Example 1.8. Proxy example
interface I
{
sub f();
int g();
}
class IImpl implements I
{
public () f() { Console.out << "IImpl.f\n"; }
public int g() { Console.out << "IImpl.g\n"; return 1; }
}
class A
{
private IImpl myField proxies IImpl;
}
is equivalent to :
class A
{
private IImpl myField;
public sub f() { myField.f(); }
public int g() { return myField.g(); }
}
Therefore, this feature can be used to emulate multiple inheritance :
class A extends AbstractA implements I
{
private IImpl myField proxies I;
}
It is always possible to explicitly implement a method delegated to the proxy.
class A extends AbstractA implements I
{
private IImpl myField proxies I;
public sub f() { Console.out << "A.f\n"; }
// g is still forwarded to myField
}
Their implementation is defined "inline" with the allocation statement. Anonymous classes are inner types.
interface I
{
sub f();
}
class SomeClass
{
void someMethod()
{
I i = new I() {
public sub f() { Console.out << "Anonymous I.f\n"; }
}
}
}
This is equivalent to
class SomeClass
{
void someMethod()
{
I i = new AnonymousClass1();
}
private inner class AnonymousClass1 implements I
{
public sub f() { Console.out << "Anonymous I.f\n"; }
}
}
Any method can act as a slot.
Any signal can be connected to any slots, provided their signature matches.
To define a signal, one has just to add the "signal" keyword in front of the method with an empty implementation.
A method must be seen as an implementation of an inner type whose interface is Method<TupleOut, TupleIn> where TupleOut is the result type of method and TupleIn is the list of parameter of the method.
As such, a method is a full closure, and can be used for continuation.
Example 1.9. Methods and Method instantiation
class Foo
{
public () bar(int i)
{
Console.out << "Coucou";
}
}
is equivalent to
class Foo
{
Method<(), (int)> bar = new Method<(), (int)>
{
() operator()(int i)
{
Console.out << "Coucou";
}
}
}
The interface Method is defined as
interface Method<Result, Parameter>
{
Result operator()(Parameter p);
}
A class, an interface or a method can be made generic by adding a generic declaration following the name of the item.
class Vector<T>
{
}
interface Container<T>
{
}
class A
{
public sub f<T>() {
}
}
A generic declaration can provide one constraints over the generic type :
class HashMap<T inherits Hashable>
{
}
The constraints can be a class or an interface. By default, a generic parameter implements Object. That is, writing :
class Vector<T>
{
}
is the same as :
class Vector<T inherits Object>
{
}
Table of Contents
Types are divided into two main categories : value types and reference types.
A value type is either a primitive type, a tuple or an enum.
If the type defines no default constructor, a default is created for it. The purpose is to allow the value type to be instantiable by default.
All reference fields composing the value type are initialised to zero.
All value fields composing the value type get their default constructor called if it exists. If that's not the case, this is a compil time error.
Native types of net.nosica.lang do not get initialised to zero.
A primitive type is a class declared with the "primitive" keyword. It can contains
at most one static initializer
at most one static deinitializer
zero, one or more constructors (if none are defined, a default is created)
at most one destructor
methods
operators
properties
cast operators
fields
Example 2.1. Sample primitive type
primitive class complex
{
public float32 real;
public float32 imaginary;
public complex operator +(complex c) {
complex result;
result.real = real + c.real;
result.imaginary = imaginary + c.imaginary;
return result;
}
public complex float32.operator +(complex c) {
complex result;
result.real = this + c.real;
result.imaginary = c.imaginary;
return result;
}
}
Enum types contains a list of symbolic constants.
An enum types implements the interface Enum.
An enum has its proper type and can be converted to/from string.
Tuple types are built-in types. They are generated on-the-fly by the compiler, pretty much like arrays. Tuples implements the Tuple interface.
A tuple is a lightweight value type holding one or more anonymous variables. The notation is :
(int, string, Object) tuple;
and this is equivalent to write :
primitive class AnonymousTuple
{
public int anonymous0;
public string anonymous1;
public Object anonymous2;
}
each component of the tuple can be made mutable or not via the "var" modifier. Thus, one can write :
(var int, string, var Object) tuple;
it is possible to bind in a one to one relationship a list of variable and a tuple.
This is equivalent to :
int i;
float f;
(i, f) = (1, 2.30);
Thus, when calling a method, it is both possible to use normal parameter list (or variable list), or a tuple.
References type are either classes, interfaces or Arrays.
References types are garbage collected.
Default references types include
Object
Array
None
A class type defines a data structure plus a set of methods working on the data structures.
Members of a class types are
fields
static initializer
static deinitializer
constructors
destructor
methods
properties
operators
A class can extends at most one other class (simple inheritance) and multiple interfaces.
If a class does not explicitly extends a class, it implicitly extends the class Object. Therefore, all classes directly or indirectly inherits from class Object.
There is a special class named None which implicitly extends all known classes of the compiled program. None is the type of the null literal.
An interface defines only a set of methods. There is no instance of an interface. There is only instances of classes that implements interfaces. Interfaces defines a kind of contract to which a class must adhere.
An interface can extends several other interfaces. A class can implements as much interfaces as it wishes.
Arrays are built-in types. They are generated on the fly by the compiler. They implements the Array interface.
Arrays have at least one dimension but they are not limited to one dimension.
Each value types can be boxed via the Box generic class.
The class Box is defined like :
class Box<T> {
public T value proxies T;
}
There is no unboxing. The user must test the instance against the Box<T> type and access the underlying value.
Please note that the underlying value is immutable.
Ultimately, the Box type allows the type system to unify value types and references type because ultimately all types can be converted into an Object.
There are several different types of variables in Nosica : static fields, fields, parameters and local variables.
Variables have a type, possibly an array or a tuple type. Variables may have modifiers : the "var" modifier or the "static" modifier.
Initial value of array elements and tuple's members is the default value.
Static fields are defined with the "static" keyword. They exist before application startup and can be accessed at any time. They cease to exit after application shutdown.
Initial value of a static field is the default value.
Fields are members of a class. They are defined inside a class without the "static" keyword.
Fields are created when the instance of the class is created. They cease to exist after the destructor has been executed.
Initial value of a field is the default value.
Parameters can be given in input or in output as in the following syntax :
Example 3.1. Input and output parameters
(int i, Object o) someCall(float f, Array a) {
i = f.narrow();
o = a;
}
There can be value parameters or references parameters.
A value parameter is a parameter defined without the "var" modifier. It means the parameter is immutable and cannot be modified.
A reference parameter is defined with the "var" modifier. A reference parameter does not create a new storage location. Thus the value of a reference parameter is always the same as the underlying variable used to perform the call.
Output parameters are always mutable.
Much like references parameters, output parameters do not create a new storage location. Instead, they are bound to the variable receiving the value in the caller. If no such variable exist, a new storage location is created in this sole purpose.
A local variables can be declared anywhere inside a block. Some special statements like the for or foreach statement allows the creation of a local variable inside their declaration.
The lifetime of a local variable is limited by the one of its enclosing block. When its enclosing block ends, the variable is said to have reached end of scope and is destroyed.
The initial value of a local variable is the default value.
Table of Contents
A conversion enables one type to be treated as another. Conversions can be implicit or explicit.
Here are the classified implicit conversions :
Implicit reference upcast conversion
Implicit primitive cast conversion
Implicit primitive boxing conversion
Implicit reference immutable conversion
It is possible to convert any reference type to one of its super type. A super type being one of the reference type listed in the extends or implements declaration of the type, recursively.
It is possible to convert an array type TE with an element type E to an immutable array type TS with an element type S provided S is a super type of E.
It is possible to convert a generic type TE with a generic parameter E to an immutable generic type TS with a generic parameter S provided S is a super type of E.
As None is the type of the literal 'null' and None implictly inherits from all existing types of the program, it is therefore possible to assign any variables the 'null' literal.
As Object is the super type of all references types, it is possible to convert any reference type to Object.
A conversion is allowed from a primitive type P1 to another primitive type P2 provided that P1 defines a cast operator to P2.
The user should not provide cast operators that loses data. Safe conversion are defined in the net.nosica.lang packages for the integral type via cast operators.
Unsafe conversion (conversion that loses data) should be declared via explicit narrow() methods.
A primitive type can be converted into a reference type via the boxing conversion.
Here are the classified explicit conversions :
explicit reference downcast conversion
explicit reference upcast conversion
explicit primitive cast conversion
explicit downcast conversion are allowed via the trycast statement.
explicit upcast conversion are allowed via the traditional cast statement.
There are unary, binary, ternary operators and N-ary operators Assignment : = ~ *= /= %= += -= @TODO@
Primary : x.y f(x) a[x] T.new
Unary : ++x --x +x -x !x (T)x
Multiplicative : * / %
Additive : + -
Stream : << >>
Relational : < > <= >=
Equality : == != ~~ !~
Conditional AND : &&
Conditional OR : ||
Implies : =>
Conditional : ?:
Assignment : = ~ *= /= %= += -=
@TODO@
Statement list and blocks
Labeled statements
Local variable declaration
Expression statement
If statement
switch statement
while statement
do statement
for statement
foreach statement
break statement
continue statement
return statement
throw and try statement
@TODO@
Table of Contents
Namespaces are implicitly defined in Nosica using the package declaration.
The package of a nested type is the complete TypeName of the enclosing type.
It is possible to import an alias into a compilation unit using the import declaration.
The compilation unit is the structure of a Nosica file. It consists of an optional top level package declaration, followed by a list of zero or more import declarations, followed by a list of one or more type declarations.
CompilationUnit ::=
[PackageDeclaration]
(ImportDeclaration)*
(TypeDeclaration)+
A package declaration defines the enclosing typename of a type's complete typename.
The syntax is as follows :
PackageDeclaration ::=
"package" TypeName ";"
The compiler will check the file is effectively located into the package defined relatively to the given sourcepath.
Example 7.1. file structure and package
As an example, suppose we have defined the sourcepath to contain the path
/home/joebar/project
and you define a file named Toto.nos in /home/joebar/project/net/myorg/Toto.nos, then the relative path between the sourcepath and the file location is net/myorg/Toto.nos. Therefore, the package declaration to use should be :
package net.myorg;
An import declaration import a symbol from an outer package inside the current compilation unit. There are two forms of import package : the short and extended form. The syntax is as follows :
ImportDeclaration ::=
"import" TypeName [Id];
The short form would be :
import net.myorg.Toto;
Whilst the extended form would be :
import net.myorg.Toto Toto;
The following two examples have exactly the same effect : the class Toto is now available with a short name "Toto", but the long full qualified name is always available : net.myorg.Toto. The difference between the short and the extended form is that in the short form, the chosen alias is always the last part of the fully qualified name, whilst with the extended form you are free to chose the name you want.
If the import declaration specifies a class, an interface, an enum, or a metadata, only the specified entity is imported in the current compilation unit.
It is possible to import a whole package at once. Just specify the package you want to import.
It is forbiddent to use the extended import form to specify an alternate name for the package.
The package import is equivalent to manually importing all elements of the package.
Each compilation unit implicitly imports two packages :
net.nosica.lang package
current package
The purpose is to simplify access to simple types like int, float, string and the likes and to allow the user to access easily related types defined in the same package as the current compilation unit.
Those default packages takes precedence over user defined imports. It is a compil time error to try to import a unit under an already defined import name.
The type declaration can either be a ClassDeclaration, an InterfaceDeclaration, an Enum declaration or a MetaDataType declaration.
Each type declaration defines a name. That name added to the package in which the type is defined forms the fully qualified typename.
Additionnaly, the name of the declared type must match the one of the file in the sourcepath. The case is important.
Table of Contents
The syntax is as follows :
ClassDeclaration ::=
(AccessModifiers | ClassModifiers) "class" id [GenericDeclaration] [ "extends" TypeName ] [ "implements" TypeNameList] "{"
(ClassBodyDeclaration)*
"}"
AccessModifiers ::=
"public"
| "private"
| "protected"
ClassModifiers ::=
"abstract"
| "final"
| "primitive"
| "native"
ClassBodyDeclaration ::=
StaticInitializer
| StaticDeinitializer
| ConstructorDeclaration
| DestructorDeclaration
| MethodDeclaration
| PropertyDeclaration
| OperatorDeclaration
| FieldDeclaration
As a class can be generic, it is possible to define several classes in the same compilation unit. In that case, there must be one and only one complete generic declaration. The other classes must be generic specialisation classes.
Specialisation are allowed to be put in other files bearing the same fully qualified name. They must be defined in a distinct sourcepath.
The syntax is as follows
FieldDeclaration ::=
(AccessModifiers | FieldModifiers)* TupleDeclaration id ";"
FieldModifiers ::=
"static"
| "var"
| "mutable"
Fields are the constituent piece of classes.
Static fields are classes members available at anytime. They are created before program startup and are destroyed after program termination. Static fields are available and already initialised to their default values when the static initializer of the class is executed. Static fields are available when the static deinitializer of the class is executed and are destroyed after the static deinitializer is finished.
Instances fields (non static) are created and initialized to their default value before the instance constructor is run. Instances fields are available when the destructor of the instance is run. They are destroyed after the destructor's execution.
By default, fields are immutable. To make them mutable, one has to use the "var" keyword.
To make a field mutable in an immutable method, the fields has to be further marked as "mutable".
The syntax for method is the generatl syntax for other method-like entities :
MethodDeclaration ::=
(AccessModifier* | MethodModifiers) ResultType [TypeName "."] Id Arguments ["var"] [ThrowsDeclaration] (";" | Block)
MethodModifiers ::=
"static"
| "final"
| "signal"
ResultType ::=
"sub"
| "(" [ResultTypeDeclaration ("," ResultTypeDeclaration)*] ")"
ResultTypeDeclaration ::=
TupleDeclaration Id
Arguments ::=
"(" [Argument ("," Argument)*] ")"
Argument ::=
["var"] TupleDeclaration Id
A method can be made "static". In that case, it is called a class method. If a method is not static, it is said to be an instance method.
By default, a method work on an immutable object. To make a method work on a mutable object you have to suffix it with the "var" modifier.
An argument with a "var" modifier is sait do be a reference parameter. An argument without a "var" modifier is said to be a value parameter.
Value parameters are equivalent to local variable except that they get their values from the caller. Value parameters are immutable.
A reference parameters does not create a local storage. It represents the same storage as the one used to make the call. Reference parameters are always mutable.
Method can be prefixed with a TypeName. If the typename T is a super type of the enclosing type, then the method is overloading the enclosing type's method.
Example 8.1. Specifically overloading a method
interface Base1 {
sub f();
}
interface Base2 {
sub f();
}
class Derived implements Base1, Base2 {
public sub Base1.f() {}
public sub Base2.f() {}
}
It allows one to specifically choose the overloading.
If the typename T is an unrelated type (not a super type), then the method is said to be added to the type T. Specifically :
the method is directly accessible via the type T, but
the method really belongs to E : that means normal access rules applied for private/public/protected access.
Example 8.2. Adding a new method to an existing class
public class OStream {
public OStream append(int i);
public OStream append(float32 i);
// ... other methods
}
public class Color {
private int r;
private int v;
private int b;
public OStream OStream.append(Color c) {
this.append(c.r);
this.append(c.v);
this.append(c.b);
return this;
}
}
The syntax is as follows
OperatorDeclaration ::=
[AccessModifiers] [TypeName "."] "operator" OperatorName Arguments ["var"] [ThrowsDeclaration] (";" | Block)
OperatorName ::=
UnaryOperators
| BinaryOperators
| NaryOperators
| CopyOperator
UnaryOperators ::= "-" | "+" | "--" | "++" | "!"
BinaryOperators ::= "-" | "+" | "*" | "/" | "%" | "^" | "-=" | "+=" | "*=" | "/=" | "%=" | "^=" | "~~" | "!~" | "<<" | ">>"
NaryOperators ::= "() | ?:"
CopyOperator ::= "~"
Unary operators are always prefix. Binary operators are always infix.
There is no such things as postfix operator as this is handled by the more general method notation.
See the example to add methods in an existing class.
Unary operators have a ()->T signature.
Example 8.3. Unary operator signature
class T {
private int i;
public constructor(int i) {this.i = i; }
public T operator -() {
return T(-i);
}
}
Binary operators have a T->T signature.
Example 8.4. Binary operator signature
class T {
private int i;
public constructor(int i) {this.i = i; }
public T operator -(T rhs) {
return T(i - rhs.i);
}
}
The copy operator has a special signature which is T->().
The syntax is as follows
PropertyDeclaration ::=
"property" TupleDeclaration id "{"
[ [AccessModifiers] "get" (";" | Block) ]
[ [AccessModifiers] "set" (";" | Block) ]
"}"
A property declaration act as a Field, but it completes the field declaration with accessors : a get accessor if the equivalent field is to be readable, and a set accessor if the equivalent field is to be writable. If the PropertyDeclaration defines only a get accessor, the equivalent field is said to be read-only. If the PropertyDeclaration defines only a set accessor, the equivalent field is said to be write-only.
In the set form, the implicit argument is Id (the id used to define the property).
Example 8.6. Set property
property int i {
public get { return 1; }
protected set { Console.out << i << "\n"; }
}
Array properties are like 'normal' properties except they modelize access to an array.
Array properties can have a name or they can be anonymous.
The syntax is as follows :
ArrayPropertyDeclaration ::=
"property" TupleDeclaration [id] Arguments "{"
[ [AccessModifiers] "get" (";" | Block) ]
[ [AccessModifiers] "set" (";" | Block) ]
"}"
When the array property is anonymous, then the implicit parameter is named "value".
The syntax is as follows
ConstructorDeclaration ::=
[AccessModifiers] "constructor" Arguments [ThrowsDeclaration] (";" | ConstructorBlock)
ConstructorBlock ::=
"{"
[ExplicitConstructorInvocation]
(BlockStatements)*
"}"
ExplicitConstructorInvocation ::=
"this" FormalParameters
|
"super" FormalParameters
Fields are initialised to their default values when entering the ConstructorDeclaration.
The syntax is as follows
DestructorDeclaration ::=
"destructor" "("")" (";" | Block)
Array can have multiple dimensions.
int[] i = int[].new(10);
int[,] j = int[,].new(10, 10);
int[][] k = int[][].new(10);
for (int l = 0; l < k.length; ++l)
j[l] = new int[].new(10);
Arrays implement the Array interface.
public interface Array<T>
{
word length {
get;
};
word dimension {
get;
};
word length(word dim);
T[] {
get;
set;
}
}
In this interface, only mono dimensional array get/set properties are declared. A real array type will have two set of array get/set accessors : a mono dimensional pair of accessors, and a multi dimensional pair of accessors if the type is multi dimensional.
This allows to represent all multi dimensional arrays with a mono dimensional representation suitable for iterations for example.
This also allow to have one super type for all arrays.
Here's the syntax
InterfaceDeclaration ::=
[AccessModifiers] "interface" id [GenericDeclaration] ["extends" TypeNameList] "{"
(InterfaceMemberDeclaration)*
"}"
InterfaceMemberDeclaration ::=
MethodDeclaration
| PropertyDeclaration
| OperatorDeclaration
Here's the syntax
EnumDeclaration ::=
[AccessModifiers] "enum" Id "{"
IdList
"}"
IdList ::=
[Id ("," Id)* ]An enum declaration contains one or more symbolic typed constant.All enums implements the inteface Enum which defines explicit conversion from/to int and string.interface Enum {
string toString();
sub fromString(string str);
int toInt();
sub fromInt(int id);
}
Here's the syntax
TupleDeclaration ::=
TupleMember
| "(" TupleMembers ")"
TupleMembers ::=
[TupleMember ("," TupleMember)* ]
TupleMember ::=
TypeName
| TupleDeclaration
Each tuple implements the tuple interface which is just empty.
A tuple is a primitive class with no methods and N anonymous fields. The Ith field has the type of Ith typename of the tuple.
There is no way to access directly the members of a tuple.
Version 1.2, November 2002
Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
0. PREAMBLE
The purpose of this License is to make a manual, textbook, or other functional and useful document "free" in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.
This License is a kind of "copyleft", which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.
We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.
1. APPLICABILITY AND DEFINITIONS
This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The "Document", below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as "you". You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law.
A "Modified Version" of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.
A "Secondary Section" is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document's overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.
The "Invariant Sections" are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none.
The "Cover Texts" are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words.
A "Transparent" copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not "Transparent" is called "Opaque".
Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only.
The "Title Page" means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, "Title Page" means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text.
A section "Entitled XYZ" means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as "Acknowledgements", "Dedications", "Endorsements", or "History".) To "Preserve the Title" of such a section when you modify the Document means that it remains a section "Entitled XYZ" according to this definition.
The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License.
2. VERBATIM COPYING
You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and you may publicly display copies.
3. COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document's license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.
If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.
It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.
4. MODIFICATIONS
You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:
* A. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission.
* B. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has fewer than five), unless they release you from this requirement.
* C. State on the Title page the name of the publisher of the Modified Version, as the publisher.
* D. Preserve all the copyright notices of the Document.
* E. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices.
* F. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below.
* G. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document's license notice.
* H. Include an unaltered copy of this License.
* I. Preserve the section Entitled "History", Preserve its Title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section Entitled "History" in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence.
* J. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the "History" section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission.
* K. For any section Entitled "Acknowledgements" or "Dedications", Preserve the Title of the section, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein.
* L. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles.
* M. Delete any section Entitled "Endorsements". Such a section may not be included in the Modified Version.
* N. Do not retitle any existing section to be Entitled "Endorsements" or to conflict in title with any Invariant Section.
* O. Preserve any Warranty Disclaimers.
If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles.
You may add a section Entitled "Endorsements", provided it contains nothing but endorsements of your Modified Version by various parties--for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.
You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.
5. COMBINING DOCUMENTS
You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled "History" in the various original documents, forming one section Entitled "History"; likewise combine any sections Entitled "Acknowledgements", and any sections Entitled "Dedications". You must delete all sections Entitled "Endorsements."
6. COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.
7. AGGREGATION WITH INDEPENDENT WORKS
A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an "aggregate" if the copyright resulting from the compilation is not used to limit the legal rights of the compilation's users beyond what the individual works permit. When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document's Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate.
8. TRANSLATION
Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail.
If a section in the Document is Entitled "Acknowledgements", "Dedications", or "History", the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title.
9. TERMINATION
You may not copy, modify, sublicense, or distribute the Document except as expressly provided for under this License. Any other attempt to copy, modify, sublicense or distribute the Document is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
10. FUTURE REVISIONS OF THIS LICENSE
The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See http://www.gnu.org/copyleft/.
Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License "or any later version" applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation.