SOME Specification
1 Type definitions
Format:
[TYPE DECLARATION] :[INHERITACE LIST] ->[REFERRENCE LIST], ->[REFERRENCE1 DECLARATION], ->[REFERRENCE2 DECLARATION] …
[MEMBER1 DECLARATION]
[MEMBER2 DECLARATION]
[MEMBER3 DECLARATION]
…
1.1 Type declaration
Sample
|
NOTE(or sample as c#)
|
Rules
|
CSampleType
|
class
CSampleType
|
|
ASampleType
|
abastract class
CSampleType
|
|
ISampleInterface
|
interface I
SampleType
|
|
SSampleStruct
|
struct
SSampleStruct
|
|
CSampleType :CBaseType
|
Inheritance
|
|
CSampleType :IInterface1 :IInterface2
|
Multi-Inheritance list
|
Only for interfaces
|
CSampleType ->CRefType1[_ref1]
|
Referrence type
“_ref” will be resolved as private member
|
The type “CRefType1” should have been or will be defined by you in some other place
|
CSampleType ->CRefType1[][_ref1]
|
Collection type
|
|
CSampleType ->CRefType1[r_Ref]
|
“Ref” is a property with get, “r_” means read-only
|
In c#, This will be resolved as a field and a property with “get” accessor
|
CSampleType ->CType1[_ref1], ->CType2[m_ref2]
|
Referrence list
“m_ref” will be resolved as protected member
|
|
CSampleType ->CRefType1[_ref1.()]
|
“_ref1” will be created during the definition
Equals to:
“private CRefType1 _ref = new CRefType1()”
|
In referrence list, no parameter is allowed to be passed through constructor invoking
|
CSampleType :I1 :I2 ->C1[_c1], ->C2[_c2.()]
|
Inheritance and referrence list
|
|
CSampleType :I1 :I2
->C1[_c1]
->C2[_c2<C3>.()]
|
Multi-line defination of referrence list
“C2[_c2<C3>.()]” equals to “C2 _c2 = new C3();”
|
|
1.2 Member declaration
Sample
|
NOTE(or sample as c#)
|
Rules
|
Fields and properties
| ||
Int _number
|
private
int _number
|
|
string m_str
|
protected
string m_str
|
|
String s_Str
|
Public static property
|
|
String s_str
|
Private static field
|
|
String c_Str
|
Public const field
|
|
String c_str
|
Private const field
|
|
string Str
|
Public property with getter and setter, the associated private member (_str) will also be generated
|
|
string r_Str
|
Public property with getter
|
S in“Str”must be captalized
|
string w_Str
|
Public property with setter
|
S in“Str”must be captalized
|
CType1 m_obj.()
|
protected
Type1 m_obj = new Type1()
|
|
CType1[] _objlist
|
Collection defination
|
|
String _str.(“hello”)
Type _obj1.(“hello”,2007)
|
private
string _str = new string(“hello”)
|
In member declaration , only constant variables can be seen in the constructor invoking
|
Methods
| ||
func()
|
protected
void func()
|
|
_func()
|
private
void func()
|
|
Func()
|
public void
Func()
|
|
a_Func()
|
public abstract void
Func()
|
Only abstract class or interface can have this
|
v_Func()
|
public virtual void
Func()
|
|
o_Func()
|
public override void
Func()
|
|
s_Func()
|
public static void
Func()
|
|
s_run()
|
private static void
func()
|
|
CType1 Func()
|
public void
CType1 Func()
|
|
CType1[] Func(CType2[])
|
Collection
|
|
CType1 v_Func(CType2,CType3)
|
Parameter list
|
|
Func(CType1 m_obj)
|
1)If “CType” has been defined by you, “m_obj” must have been defined in referrence list.in this context ,it equals to:
public
void Func(CType1 obj){ this.m_obj = obj;}
2)If “CType” isn’t defined, it will be resolved as a build-in type, in this context, this equals to 2 definitions:
private
CType1 m_obj;
public void
Func(CType1 obj){ this.m_obj = obj;}
but m_obj” also may have been defined by its ancestors, in this situation , you should not redefine it
|
|
Func(CType1 Obj);
Func(CType1 r_Obj);
Func(CType1 g_Obj);
|
Function definition with property definition
|
|
()
|
Public constructor without parameters
|
Constructor should not return anything
|
_()
|
Private constructor
|
|
v_()
|
Protected constructor
|
|
(CType1,CType2)
|
Constructor with parameter
|
|
(CType1 m_obj)
|
Constructor with a parameter and a field definition, as well as an assignment while invoking
|
|
~()
|
destructor
|
Should not contain parameters and returns
|
1.3 common rules
l
A SOME type must begin with either “A”, ”C”, “I” or ”S”
l
In Type definition, every line will be resolved as a single statement
l
You can place type definitions in any order, but if you want to end the definition for a certain type, you must provide at least a single blank line.
2 Sequence definitions
Sample
|
sample as c#)
|
NOTE
|
Rules
| |||
Sequence declaration
| ||||||
CSomeType.main
{
}
|
|
Main entrance defination
|
Only “main” owns this kind of definition format, so “main” is the only “Keyword” in SOME
| |||
CType.Method(obj1, obj2)
{
}
|
|
Definition of “Method” of class “CType”
|
Parameters in the list should differentiate with each other
| |||
obj.Method<CType> (CType1 obj1)
{
}
|
|
if you want to use “this” in the sequence, you should use “obj” to denote “this”
|
| |||
CType.SomeOverrideMethod<CSubType>()
{
}
|
|
Override function define
|
| |||
Object defination statement
| ||||||
CType obj;
|
CType obj;
|
|
| |||
CType obj.();
|
CType type = new CType();
|
Local object creation
|
| |||
CType obj.(obj1,obj2);
|
|
Constructor with parameters
|
| |||
CType obj.(m_obj1 = obj1);
|
|
Constructor with local member assigment
|
| |||
CType obj<CSubType>();
|
CType obj = new CSubType();
|
|
CSubType should be inherited from CType
| |||
|
|
|
| |||
Method invoking
| ||||||
m_obj.();
|
m_obj = new CType();
|
Member object creation
|
| |||
m_obj<CSubType>.()
|
m_obj = new CSubType();
|
|
| |||
myObj.Method1();
myObj.Method1(obj);
myObj.Method1(m_obj = obj);
|
|
|
| |||
myObj.Method1(obj1);
|
|
|
| |||
myObj.Method1(str[“hello”])
{
};
myObj.Method1(obj[obj1])
{
};
|
|
another difination starts,
obj is an alias of obj1,
in the context of definition of “Method1”,
“obj” will be a referrence of “obj1”, and “obj1” would not appear again
|
if you don’t wanna start a new definition of a invoking method, do not use alias mechanism.
You also can choose no-alias pass just like this:
myObj.Metho1(obj)
{
//do something with “obj”
}
| |||
_method1();
|
|
private method invoking
|
| |||
obj.SomeMethod<COtherType>()
{
};
|
1)if obj’s type is COtherType’s offspring:
class
COtherType
{
public void SomeMethod()
{
}
}
2)if obj’s type is COtherType’s ancestor:
class
COtherType
{
public override void SomeMethod()
{
}
}
|
Another difination
|
“COtherType” must be either an offspring or an ancestor of the obj’s type
If you don’t wanna define “SomeMethod”,you should remove “<COtherType>”
| |||
CType1.SomeStaticMethod();
|
|
Static function
|
| |||
CType1 obj1.();
CType2 obj2.();
obj1.SetThisToType2(obj2)
{
obj2.m_obj1 = obj1;
}
|
CType1 obj1 = new CType1();
CType2 obj2 = new CType2();
class
CType1
{
public void SetThisToType2 (CType2 obj2)
{
obj2.m_obj1 = this;
}
}
|
assgin this to other type
|
if in the context of a root definition(sequence), you also should not use “this”, you can do this:
objA<CTypeA> .SomeMethod(obj)
{
obj.m_obj1 = objA;
}
this is another way to define a sequence
| |||
Assignment statement
| ||||||
num = 1;
str = “hello world”;
|
|
single assignment
|
complex expressions are not be supported by SOME currently
| |||
CType obj1 = obj2;
obj = otherobj.Obj;
CType obj1 = obj2.Obj1;
|
|
complex assignment
|
| |||
Return statement
| ||||||
CType.();
CType.(obj1,obj2);
CType.(m_obj1=obj1);
|
return
new CType();
|
|
| |||
obj;
1;
“ok”;
|
return
obj;
return
1;
return
“ok”;
|
|
| |||
|
only digits or const string can be here. any other expression will not be accepted
| |||||
obj1. Obj2;
|
return
obj1.Obj2;
|
|
| |||
Comments
| ||||||
//
|
|
single line comment
|
| |||
/* */
|
|
muitl-line comment
|
| |||
Compound statement
| ||||||
CType obj = [Method invoking]
|
|
defination and invoking
|
| |||
obj = [Method invoking]
|
|
invoking and assigning
|
| |||
Native code snippet
| ||||||
<% int i=500*200; %>
|
|
single line
|
all statements in the snippet area should be reserved as its original appearance
| |||
<%
for(int i=0;i<5;i++)
{
//do something here
}
%>
|
|
multi-line
|
|
2.1 Common Rules
l
Sequence Definition must begin after Type Declaration
l
In a sequence definition, every statement will be ended with “;”, and if you place a pair of curly brackets, that only means you want to make a definition of a method. In this situation, you can place “{“ or “}” anywhere, but you must not forget to add a “;” after “}”.
l
You may start with any method of any type that you’ve defined in the Type Declaration part, each definition seems just like a sequence diagram in UML.
3. Common Rules for all