version 1.5, 2000/09/08 18:57:49 |
version 1.8, 2020/03/14 01:21:56 |
|
|
%% $OpenXM: OpenXM/doc/OpenXM-specs/formal-expression.tex,v 1.4 2000/09/08 17:14:54 takayama Exp $ |
%% $OpenXM: OpenXM/doc/OpenXM-specs/formal-expression.tex,v 1.7 2000/09/09 21:59:13 takayama Exp $ |
//&jp \section{ CMO の形式的表現方法 } |
//&jp \section{ CMO 綵√茵憝号 } |
//&eg \section{ A formal expression of CMO } |
//&eg \section{ A formal expression of CMO } |
|
|
/*&jp |
/*&jp |
前の節で CMO の表現方法を形式的に定義せず, |
膀 CMO 茵憝号綵√絎臂, |
CMO のPrimitive の表現法を説明したが, |
CMO Primitive 茵憝茯, |
ここでは, CMO の Lisp 風表現 (Lisp-like expression) |
с, CMO Lisp 蘂茵 (Lisp-like expression) |
である |
с |
CMOexpression |
CMOexpression |
および前節で説明した CMO の標準 encoding 法をもう一度説明する. |
喝膀ц CMO 罔羣 encoding 羈筝綺茯. |
% (タグの省略記法がほしい.) |
% (帥違ヨ羈祉.) |
*/ |
*/ |
/*&eg |
/*&eg |
In the previous section, we have explained the format of CMO's in the |
In the previous section, we have explained the format of CMO's in the |
|
|
In this section, we will introduce CMOexpression which is like the |
In this section, we will introduce CMOexpression which is like the |
bracket expression of Lisp. |
bracket expression of Lisp. |
We again explain a standard encoding method of CMO, |
We again explain a standard encoding method of CMO, |
which we have already explained in the previous section. |
which we have already explained in the previous section, but |
|
the explanation is more formal. |
*/ |
*/ |
|
|
/*&jp |
/*&jp |
|
|
まず, CMOexpression を形式的に 拡張 BNF 記法を用いて定義しよう. |
障, CMOexpression 綵√ ≦宍 BNF 荐羈絎臂. |
タイプライタフォントでかかれた記号は終端記号を意味する. |
帥ゃゃ帥潟с荐垩腟腴荐垩潟. |
``:'' は定義を意味する. ``$|$'' は''または''を意味する. |
``:'' 絎臂潟. ``$|$'' ''障''潟. |
\{ X \} は X の 0 回以上の繰り返しを表す. |
\{ X \} X 0 篁ヤ膵違菴茵. |
[ x ] は X が 0 回または 1 回出現することを表す. |
[ x ] X 0 障 1 榊憗茵. |
この記法を用いると CMOexpression は次のように定義できる. |
荐羈 CMOexpression 罨<絎臂с. |
|
|
*/ |
*/ |
/*&eg |
/*&eg |
Line 56 By using this notation, CMOexpression is defined as fo |
|
Line 57 By using this notation, CMOexpression is defined as fo |
|
\end{eqnarray*} |
\end{eqnarray*} |
*/ |
*/ |
/*&jp |
/*&jp |
終端記号 {\tt int32} は, 32 bit integer を表す, 10 進または 16 進の数字の |
腟腴荐 {\tt int32} , 32 bit integer 茵, 10 蚊障 16 蚊医 |
列である. |
с. |
終端記号 {\tt string} は''文字''の列である. |
腟腴荐 {\tt string} ''絖''с. |
終端記号 {\tt byte} は 8 bit データを表す, 10 進または 16 進の数字の列である. |
腟腴荐 {\tt byte} 8 bit 若帥茵, 10 蚊障 16 蚊医с. |
*/ |
*/ |
/*&eg |
/*&eg |
Terminal {\tt int32} is signed 32 bit integer. |
Terminal {\tt int32} is signed 32 bit integer. |
Line 68 Terminal {\tt byte} is 8 bit data. |
|
Line 69 Terminal {\tt byte} is 8 bit data. |
|
*/ |
*/ |
|
|
/*&jp |
/*&jp |
CMOexpression にあらわれる各要素を区切るために {\tt ,} (コンマ) を用いてもよい. |
CMOexpression 荀膣阪 {\tt ,} (潟潟) . |
{\tt cmo\_tag} は {\tt CMO\_} で始まる定数である. |
{\tt cmo\_tag} {\tt CMO\_} у障絎違с. |
CMOexpression で表現される object を CMObject と呼ぶ. |
CMOexpression ц;憗 object CMObject 若. |
|
|
*/ |
*/ |
/*&eg |
/*&eg |
Line 80 The comma ({\tt ,}) may be used to separate each eleme |
|
Line 81 The comma ({\tt ,}) may be used to separate each eleme |
|
*/ |
*/ |
|
|
/*&jp |
/*&jp |
この表記法 CMOexpression を利用して, CMO Primitive の object を記述 |
茵荐羈 CMOexpression , CMO Primitive object 荐菴 |
してみよう. |
帥. |
Object 自体の構造を説明するため, |
Object 篏罕茯, |
BNF をもうすこし拡張して, 非終端記号, 終端記号名のみならず, 変数の |
BNF ≦宍, 腟腴荐, 腟腴荐垸帥, 紊違 |
名前も書くことにする. こうすることにより, object の意味の説明も容易になる |
吾. , object 潟茯絎号 |
からである. また ``---'' でコメントのはじまりを表すものとする. |
с. 障 ``---'' с潟<潟障茵. |
*/ |
*/ |
/*&eg |
/*&eg |
Let us describe CMO's in the Primitive group. |
Let us describe CMO's in the Primitive group. |
Line 94 we may also put variable names to CMOexpressions. |
|
Line 95 we may also put variable names to CMOexpressions. |
|
The start of comments are denoted by ``---''. |
The start of comments are denoted by ``---''. |
*/ |
*/ |
/*&jp |
/*&jp |
たとえば, (CMObject の) 32 bit integer である integer32 を |
, (CMObject ) 32 bit integer с integer32 |
BNFで定義すれば, |
BNFу臂, |
\begin{center} |
\begin{center} |
Integer32 \ : \ ({\tt CMO\_INT32}, {\tt int32}) |
Integer32 \ : \ ({\tt CMO\_INT32}, {\tt int32}) |
\end{center} |
\end{center} |
と書くのが本来の書き方による記法であるが, ここでは, |
吾ャ吾鴻荐羈с, с, |
\begin{eqnarray*} |
\begin{eqnarray*} |
\mbox{Integer32} \ &:& \ ({\tt CMO\_INT32}, {\sl int32}\ n) \\ |
\mbox{Integer32} \ &:& \ ({\tt CMO\_INT32}, {\sl int32}\ n) \\ |
& & \ \mbox{--- 32 bit integer $n$ を表す. } \\ |
& & \ \mbox{--- 32 bit integer $n$ 茵. } \\ |
\end{eqnarray*} |
\end{eqnarray*} |
と書くことを許すことにする. |
吾荐宴. |
このように書くことにより, 非終端記号 Integer32 は, |
吾, 腟腴荐 Integer32 , |
\begin{center} |
\begin{center} |
Integer32 \ : \ ({\tt CMO\_INT32}, {\tt int32}) |
Integer32 \ : \ ({\tt CMO\_INT32}, {\tt int32}) |
\end{center} |
\end{center} |
のように, 終端記号 {\tt CMO\_INT32} と {\tt int32} を成分にもち, |
, 腟腴荐 {\tt CMO\_INT32} {\tt int32} , |
CMObject の |
CMObject |
({\tt CMO\_INT32}, {\sl int32}\ n) |
({\tt CMO\_INT32}, {\sl int32}\ n) |
は, |
, |
32 bit integer $n$ を表現しているんだということが, 1 行でわかる. |
32 bit integer $n$ 茵憗, 1 茵с. |
*/ |
*/ |
/*&jp |
/*&jp |
この記法を用いて, 前節で導入した, Primitive の CMObject を |
荐羈, 膀уャ, Primitive CMObject |
形式的に定義しよう. |
綵√絎臂. |
*/ |
*/ |
/*&eg |
/*&eg |
By using this notation, let us define formally CMObjects in the group |
By using this notation, let us define formally CMObjects in the group |
Line 152 Document of CMObject/Primitive is at {\tt http://www.m |
|
Line 153 Document of CMObject/Primitive is at {\tt http://www.m |
|
*/ |
*/ |
|
|
|
|
//&jp Cstring で, {\sl string} s の部分を {\tt byte} に分解すれば, |
//&jp Cstring , {\sl string} s {\tt byte} 茹c, |
//&eg In the definition of ``Cstring'', if we decompose ``{\sl string} s'' into bytes, then ``Cstring'' should be defined as |
//&eg In the definition of ``Cstring'', if we decompose ``{\sl string} s'' into bytes, then ``Cstring'' should be defined as |
/*&C |
/*&C |
\begin{eqnarray*} |
\begin{eqnarray*} |
Line 161 Document of CMObject/Primitive is at {\tt http://www.m |
|
Line 162 Document of CMObject/Primitive is at {\tt http://www.m |
|
\ldots, {\sl byte}\ \mbox{s[n-1]}) |
\ldots, {\sl byte}\ \mbox{s[n-1]}) |
\end{eqnarray*} |
\end{eqnarray*} |
*/ |
*/ |
//&jp となる. |
//&jp . |
/*&jp |
/*&jp |
また, |
障, |
``Group CMObject/Primitive requires nothing'' |
``Group CMObject/Primitive requires nothing'' |
は, 以下は, グループ CMObject/Primitive の定義であり, |
, 篁ヤ, 違若 CMObject/Primitive 絎臂с, |
このグループの CMObject を定義するのに, 要請される CMObject のグループは |
違若 CMObject 絎臂, 荀茫 CMObject 違若 |
ないことを示す. |
腓冴. |
``Error2, Null, Integer32, Datum, Cstring, Mathcap, List |
``Error2, Null, Integer32, Datum, Cstring, Mathcap, List |
$\in$ CMObject/Primitive'' |
$\in$ CMObject/Primitive'' |
は, グループ CMObject/Primitive には, Error2, Null, Integer32, |
, 違若 CMObject/Primitive , Error2, Null, Integer32, |
Datum, Cstring なるクラスの object が属することを示す. |
Datum, Cstring 鴻 object 絮腓冴. |
*/ |
*/ |
/*&eg |
/*&eg |
``Group CMObject/Primitive requires nothing'' |
``Group CMObject/Primitive requires nothing'' |
Line 188 are members of the group CMObject/Primitive. |
|
Line 189 are members of the group CMObject/Primitive. |
|
*/ |
*/ |
|
|
/*&jp |
/*&jp |
では, 実際のデータの表現の例をみてみよう. |
с, 絎若帥茵憗箴帥帥. |
たとえば, 32 bit integer の 1234 は, |
, 32 bit integer 1234 , |
*/ |
*/ |
/*&eg |
/*&eg |
Let us see examples. |
Let us see examples. |
Line 201 Let us see examples. |
|
Line 202 Let us see examples. |
|
\end{center} |
\end{center} |
*/ |
*/ |
/*&jp |
/*&jp |
とかく. |
. |
文字列 ``Hello'' は |
絖 ``Hello'' |
*/ |
*/ |
/*&eg |
/*&eg |
The string ``Hello'' is expressed as |
The string ``Hello'' is expressed as |
Line 212 The string ``Hello'' is expressed as |
|
Line 213 The string ``Hello'' is expressed as |
|
({\tt CMO\_STRING}, 5, "Hello") |
({\tt CMO\_STRING}, 5, "Hello") |
\end{center} |
\end{center} |
*/ |
*/ |
//&jp と書く. |
//&jp 吾. |
|
|
/*&C |
/*&C |
|
|
*/ |
*/ |
/*&jp |
/*&jp |
CMOexpression と, CMObject の区別を理解しておくのは重要である. |
CMOexpression , CMObject 阪ャ茹c荀с. |
たとえば |
|
\begin{center} |
\begin{center} |
({\tt CMO\_INT32}, 234, "abc",({\tt CMO\_STRING})) |
({\tt CMO\_INT32}, 234, "abc",({\tt CMO\_STRING})) |
\end{center} |
\end{center} |
は CMOexpression ではあるが, CMObject ではない. |
CMOexpression с, CMObject с. |
これは, 文法的には正しいプログラムだが, なにをやるのかは全く不明な |
, 羈罩c違, 鋇 |
プログラムと似ている. |
違篌若. |
|
|
*/ |
*/ |
|
|
/*&jp |
/*&jp |
さて, Open math 風 (\cite{openmath}) |
, Open math 蘂 (\cite{openmath}) |
の XML 表現法も可能であり, その場合は, 上の二つの例は次のように |
XML 茵憝純с, 翫, 筝篋ゃ箴罨< |
書く. |
吾. |
*/ |
*/ |
/*&eg |
/*&eg |
It is possible to express CMO by XML like Open math (\cite{openmath}). |
CMO's are expressed by XML like Open Math (\cite{openmath}). |
See example below. |
See example below. |
*/ |
*/ |
|
|
/*&C |
/*&C |
|
|
\begin{verbatim} |
\begin{verbatim} |
<cmo_int32> |
<cmo> |
1234 |
<cmo_int32> |
</cmo_int32> |
<int32> 1234 </int32> |
|
</cmo_int32> |
|
|
<cmo_string> |
<cmo_string> |
5 |
<int32 for="length"> 5 </int32> |
"Hello" |
<string> "Hello" </string> |
</cmo_string> |
</cmo_string> |
|
</cmo> |
\end{verbatim} |
\end{verbatim} |
*/ |
*/ |
|
|
|
//&jp \noindent cmo\_string 罨<. |
|
//&eg \noindent cmo\_string may be expressed as follows. |
/*&C |
/*&C |
|
\begin{verbatim} |
|
|
|
<cmo> |
|
<cmo_string> |
|
<int32 for="length"> 5 </int32> |
|
<byte> 'H' </byte> <byte> 'e' </byte> <byte> 'l' </byte> |
|
<byte> 'l' </byte> <byte> 'o' </byte> |
|
</cmo_string> |
|
</cmo> |
|
\end{verbatim} |
*/ |
*/ |
|
|
|
//&jp \noindent 翫 cmo\_string DTD 絎臂罨<. \\ |
|
//&eg \noindent In this case, the DTD for cmo\_string is as follows; \\ |
|
//&C \verb+ <!ELEMENT cmo_string (int32, byte*)> + |
|
/*&C |
|
|
|
\bigbreak |
|
*/ |
|
|
/*&jp |
/*&jp |
次に, 標準 encoding 法を説明しよう. |
罨<, 罔羣 encoding 羈茯. |
標準 encoding 法では, cmo\_tag を ネットワークバイトオーダーの |
罔羣 encoding 羈с, cmo\_tag 若ゃ若若 |
32 bit integer {\tt int32} に, |
32 bit integer {\tt int32} , |
その他のフィールドは, 定義に記述されているデータ型に従い, |
篁c若, 絎臂荐菴違若水緇, |
byte データ {\tt byte} かまたは |
byte 若 {\tt byte} 障 |
ネットワークバイトオーダーの 32 bit integer {\tt int32} に, 変換する. |
若ゃ若若 32 bit integer {\tt int32} , 紊. |
*/ |
*/ |
/*&eg |
/*&eg |
Let us explain the standard encoding method. |
Let us explain the standard encoding method. |
Line 276 and byte data are encoded as it is. |
|
Line 298 and byte data are encoded as it is. |
|
*/ |
*/ |
|
|
/*&jp |
/*&jp |
高速の通信方法を用いて |
蕭篆≧号 |
効率を重視する接続の場合には, {\tt int32} を network byte order |
合荀・膓翫, {\tt int32} network byte order |
に変換する操作がおおきなオーバヘッドとなることが |
紊篏若 |
報告されている. |
怨. |
100Mbps の通信路で 12Mbytes の {\tt CMO\_ZZ} の転送では |
100Mbps 篆∴君 12Mbytes {\tt CMO\_ZZ} 荵∫с |
約 90\% の時間が network byte order への変換についやされているという |
膣 90\% network byte order 吾紊ゃ |
実験データもある. |
絎薑若帥. |
効率を重視した encoding 法については後述する. |
合荀 encoding 羈ゃ緇菴違 \ref{subsection:byteorder}. |
*/ |
*/ |
/*&eg |
/*&eg |
When we are using a high speed network, |
When we are using a high speed network, |
the translation from the internal expression of 32 bit integers to |
the translation from the internal expression of 32 bit integers to |
network byte order may become a bottle neck. |
network byte order may become a bottle neck. |
There are experimental data which presents that 90 percents of the transmission |
There are experimental data which presents that 90 percents of the transmission |
time are |
time are used |
for the translation to the network byte order to send {\tt CMO\_ZZ} of size |
for the translation to the network byte order to send {\tt CMO\_ZZ} of size |
12M bytes on a 100Mbps network. |
12M bytes. |
In a later section, we will discuss a protocol to avoid the translation. |
We used a 100Mbps network. |
|
In a later section \ref{subsection:byteorder}, |
|
we will discuss a protocol to avoid the translation. |
*/ |
*/ |
|
|
/*&C |
/*&C |
Line 301 In a later section, we will discuss a protocol to avoi |
|
Line 325 In a later section, we will discuss a protocol to avoi |
|
*/ |
*/ |
|
|
/*&jp |
/*&jp |
標準 encoding と CMOexpression の間の変換は容易である. |
罔羣 encoding CMOexpression 紊絎号с. |
前節で用いたデータの表記法, |
膀х若帥茵荐羈, |
たとえば, |
, |
*/ |
*/ |
/*&eg |
/*&eg |
The translation between the standard encoding and CMOexpression |
The translation between the standard encoding and CMOexpression |
|
|
\end{center} |
\end{center} |
*/ |
*/ |
/*&jp |
/*&jp |
は, CMOexpression |
, CMOexpression |
*/ |
*/ |
/*&eg |
/*&eg |
is the encoding of the CMOexpression |
is the encoding of the CMOexpression |
Line 331 is the encoding of the CMOexpression |
|
Line 355 is the encoding of the CMOexpression |
|
\end{center} |
\end{center} |
*/ |
*/ |
/*&jp |
/*&jp |
の 標準 encoding 法による表現である. |
罔羣 encoding 羈茵憗с. |
*/ |
*/ |
|
|
/*&C |
/*&C |
Line 341 is the encoding of the CMOexpression |
|
Line 365 is the encoding of the CMOexpression |
|
*/ |
*/ |
|
|
/*&jp |
/*&jp |
(実験的) |
(絎薑) |
CMO は XML 規格に準拠している. |
CMO OX packets XML 荀 \cite{xml} 羣. |
XML 規格の Attribute を binary encode するために |
XML 荀若 Attribute binary encode |
特別なタグ \\ |
劫ャ帥 \\ |
*/ |
*/ |
/*&eg |
/*&eg |
(Experimental) |
(Experimental) |
CMO is complient to XML specification. |
CMO and OX packets are complient to XML specification \cite{xml}. |
In order to encode ``Attribute'' in XML in a binary format, |
In order to encode ``Attribute'' in XML in our binary format, |
we have a tag: \\ |
we have a tag: \\ |
*/ |
*/ |
//&C \verb! #define CMO_ATTRIBUTE_LIST (LARGEID+3) ! \\ |
//&C \verb! #define CMO_ATTRIBUTE_LIST (LARGEID+3) ! \\ |
/*&jp |
/*&jp |
を用意してある. |
. |
*/ |
*/ |
/*&jp |
/*&jp |
たとえば Attribute {\tt font="Times-Roman" } は \\ |
Attribute {\tt font="Times-Roman" } \\ |
*/ |
*/ |
/*&eg |
/*&eg |
For example, the attibute {\tt font="Times-Roman" } is encoded as \\ |
For example, the attibute {\tt font="Times-Roman" } is encoded as \\ |
Line 369 For example, the attibute {\tt font="Times-Roman" } is |
|
Line 393 For example, the attibute {\tt font="Times-Roman" } is |
|
\end{verbatim} |
\end{verbatim} |
*/ |
*/ |
/*&jp |
/*&jp |
と encoding される. |
encoding . |
*/ |
*/ |
//&C |
//&C |
/*&jp |
/*&jp |
この特別な CMO tag {\tt CMO\_ATTRIBUTE\_LIST} 以外は, |
劫ャ CMO tag {\tt CMO\_ATTRIBUTE\_LIST} 篁ュ, |
XML 表現では XML のタグとして理解される. |
XML 茵憗с XML 帥違茹c. |
*/ |
*/ |
/*&eg |
/*&eg |
All tags except this special CMO tag {\tt CMO\_ATTRIBUTE\_LIST} |
All tags except this special CMO tag {\tt CMO\_ATTRIBUTE\_LIST} |
are XML tags in the CMO/XML expression. |
are XML tags in the CMO/XML expression. |
*/ |
*/ |
|
/*&jp |
|
CMO/XML {\it comment}, {\it for} ゃ |
|
attributes CMO binary expression 潟潟若. |
|
*/ |
|
/*&eg |
|
CMO/XML attributes such as {\it comment}, {\it for} |
|
are not encoded in the CMO binary expression. |
|
*/ |