[BACK]Return to formal-expression.tex CVS log [TXT][DIR] Up to [local] / OpenXM / doc / OpenXM-specs

Annotation of OpenXM/doc/OpenXM-specs/formal-expression.tex, Revision 1.2

1.2     ! noro        1: %% $OpenXM: OpenXM/doc/OpenXM-specs/formal-expression.tex,v 1.1.1.1 2000/01/20 08:52:46 noro Exp $
1.1       noro        2: //&jp \section{ CMO の形式的表現方法 }
                      3: //&eg \section{ A formal expression of CMO }
                      4:
                      5: /*&jp
                      6: 前の節で CMO の表現方法を形式的に定義せず,
                      7: CMO のBasic0 の表現法を説明したが,
                      8: ここでは, CMO の Lisp 風表現 (Lisp-like expression)
                      9: である
                     10: CMOexpression
                     11: および前節で説明した CMO の標準 encoding 法をもう一度説明する.
                     12: % (タグの省略記法がほしい.)
                     13: */
                     14: /*&eg
                     15: In the previous setion, we have explained the format of CMO's in the
                     16: Basic0 group.
                     17: In this section, we will introduce CMOexpression which is like the
                     18: bracket expression of Lisp.
                     19: We again explain a standard encoding method of CMO,
                     20: which we have already explained in the previous section.
                     21: */
                     22:
                     23: /*&jp
                     24:
                     25: まず, CMOexpression を形式的に 拡張 BNF 記法を用いて定義しよう.
                     26: タイプライタフォントでかかれた記号は終端記号を意味する.
                     27: ``:'' は定義を意味する. ``$|$'' は''または''を意味する.
                     28: \{ X \} は X の 0 回以上の繰り返しを表す.
                     29: [ x ] は X が 0 回または 1 回出現することを表す.
                     30: この記法を用いると CMOexpression は次のように定義できる.
                     31:
                     32: */
                     33: /*&eg
                     34:
                     35: Let us define CMOexpression by the extended BNF expression.
                     36: Symbols in the type writer fonts mean terminals.
                     37: ``:'' means a definition.
                     38: ``$|$'' means ''or''.
                     39: \{ X \} is a repetition of X of more than or equal to 0 times.
                     40: [ x ] stands for X or nothing.
                     41: By using this notation, CMOexpression is defined as follows.
                     42:
                     43: */
                     44:
                     45: /*&C
                     46: \begin{eqnarray*}
                     47: \mbox{CMOexpression}
                     48: &:& \quad
                     49: \mbox{\tt (} \mbox{\tt cmo\_tag} \
                     50: \{ \mbox{ expression} \} \mbox{\tt )}\\
                     51: \mbox{expression}
                     52: &:& \quad  \mbox{CMOexpression} \\
                     53: &   &|\   \mbox{\tt int32}  \\
                     54: &   &|\   \mbox{\tt string} \\
                     55: &   &|\   \mbox{\tt byte} \\
                     56: \end{eqnarray*}
                     57: */
                     58: /*&jp
                     59: 終端記号 {\tt int32} は, 32 bit integer を表す, 10 進または 16 進の数字の
                     60: 列である.
                     61: 終端記号 {\tt string} は''文字''の列である.
                     62: 終端記号 {\tt byte} は 8 bit データを表す, 10 進または 16 進の数字の列である.
                     63: */
1.2     ! noro       64: /*&eg
1.1       noro       65: Terminal {\tt int32} is signed 32 bit integer.
                     66: Terminal {\tt string} is a byte array which usually expresses a string.
                     67: Terminal {\tt byte} is 8 bit data.
                     68: */
                     69:
                     70: /*&jp
                     71: CMOexpression にあらわれる各要素を区切るために {\tt ,} (コンマ) を用いてもよい.
                     72: {\tt cmo\_tag} は {\tt CMO\_} で始まる定数である.
                     73: CMOexpression で表現される object を CMObject と呼ぶ.
                     74:
                     75: */
                     76: /*&eg
                     77: The comma ({\tt ,}) may be used to separate each element in CMOexpressions.
                     78: {\tt cmo\_tag} is a constant that starts with {\tt CMO\_}.
                     79:
                     80: */
                     81:
                     82: /*&jp
                     83: この表記法 CMOexpression を利用して, CMO Basic0 の object を記述
                     84: してみよう.
                     85: Object 自体の構造を説明するため,
                     86: BNF をもうすこし拡張して, 非終端記号, 終端記号名のみならず, 変数の
                     87: 名前も書くことにする. こうすることにより, object の意味の説明も容易になる
                     88: からである. また ``---'' でコメントのはじまりを表すものとする.
                     89: */
                     90: /*&eg
                     91: Let us describe CMO's in the Basic0 group.
                     92: In order to explain the meaning of objects,
                     93: we may also put variable names to CMOexpressions.
                     94: The start of comments are denoted by ``---''.
                     95: */
                     96: /*&jp
                     97: たとえば, (CMObject の) 32 bit integer である integer32 を
                     98: BNFで定義すれば,
                     99: \begin{center}
                    100: Integer32 \  : \ ({\tt CMO\_INT32}, {\tt int32})
                    101: \end{center}
                    102: と書くのが本来の書き方による記法であるが, ここでは,
                    103: \begin{eqnarray*}
                    104: \mbox{Integer32} \  &:& \ ({\tt CMO\_INT32}, {\sl int32}\  n) \\
                    105: & & \  \mbox{--- 32 bit integer $n$ を表す. } \\
                    106: \end{eqnarray*}
                    107: と書くことを許すことにする.
                    108: このように書くことにより, 非終端記号  Integer32 は,
                    109: \begin{center}
                    110: Integer32 \  : \ ({\tt CMO\_INT32}, {\tt int32})
                    111: \end{center}
                    112: のように, 終端記号 {\tt CMO\_INT32} と {\tt int32} を成分にもち,
                    113: CMObject の
                    114: ({\tt CMO\_INT32}, {\sl int32}\ n)
                    115: は,
                    116: 32 bit integer $n$ を表現しているんだということが, 1 行でわかる.
                    117: */
                    118: /*&jp
                    119: この記法を用いて, 前節で導入した, Basic0 の CMObject を
                    120: 形式的に定義しよう.
                    121: */
                    122: /*&eg
                    123: By using this notation, let us define formally CMObjects in the group
                    124: Basic0.
                    125: */
                    126:
                    127: /*&C
                    128:
                    129: \bigbreak
                    130: \noindent
                    131: Group CMObject/Basic0  requires nothing. \\
                    132: Error2, Null, Integer32, Datum, Cstring, Mathcap, List $\in$ CMObject/Basic0. \\
                    133: Document of CMObject/Basic0 is at {\tt http://www.math.kobe-u.ac.jp/OpenXM}
                    134: (in English and Japanese) \\
                    135: \begin{eqnarray*}
                    136: \mbox{Error2}&:& ({\tt CMO\_ERROR2}, {\sl CMObject}\, \mbox{ob}) \\
                    137: \mbox{Null}  &:& ({\tt CMO\_NULL}) \\
                    138: \mbox{Integer32}
                    139: &:& ({\tt CMO\_INT32}, {\sl int32}\ \mbox{n}) \\
                    140: \mbox{Datum} &:& ({\tt CMO\_DATUM}, {\sl int32}\, \mbox{n}, {\sl byte}\,
                    141: \mbox{data[0]},
                    142: \ldots , {\sl byte}\, \mbox{data[n-1]}) \\
                    143: \mbox{Cstring}&:& ({\tt CMO\_STRING},{\sl int32}\,  \mbox{ n},
                    144: {\sl string}\, \mbox{s}) \\
                    145: \mbox{Mathcap}&:& ({\tt CMO\_MATHCAP},{\sl CMObject}\,  \mbox{ob} ) \\
                    146: \mbox{List} &:&
                    147: \mbox{({\tt CMO\_LIST}, {\sl int32}\, m, {\sl CMObject}\, ob[0], $\ldots$,
                    148: {\sl CMObject}\, ob[m-1])} \\
                    149: & & \mbox{---  m is the length of the list.}
                    150: \end{eqnarray*}
                    151:
                    152: */
                    153:
                    154:
                    155: //&jp Cstring で, {\sl string} s の部分を {\tt byte} に分解すれば,
                    156: //&eg In the definition of ``Cstring'', if we decompose  ``{\sl string} s'' into bytes, then  ``Cstring'' should be defined as
                    157: /*&C
                    158: \begin{eqnarray*}
                    159: \mbox{Cstring}&:& ({\tt CMO\_STRING},{\sl int32}\,  \mbox{ n},
                    160: {\sl byte}\, \mbox{s[0]},
                    161: \ldots, {\sl byte}\ \mbox{s[n-1]})
                    162: \end{eqnarray*}
                    163: */
                    164: //&jp となる.
                    165: /*&jp
                    166: また,
                    167: ``Group CMObject/Basic0  requires nothing''
                    168: は, 以下は, グループ CMObject/Basic0 の定義であり,
                    169: このグループの CMObject を定義するのに, 要請される CMObject のグループは
                    170: ないことを示す.
                    171: ``Error2, Null, Integer32, Datum, Cstring, Mathcap, List
                    172: $\in$ CMObject/Basic0''
                    173: は, グループ CMObject/Basic0 には,  Error2, Null, Integer32,
                    174: Datum, Cstring なるクラスの object が属することを示す.
                    175: */
                    176: /*&eg
                    177: ``Group CMObject/Basic0  requires nothing''
                    178: means that there is no super group to define CMO's in the group Basic0.
                    179: ``Error2, Null, Integer32, Datum, Cstring, Mathcap, List
                    180: $\in$ CMObject/Basic0''
                    181: means that
                    182: Error2, Null, Integer32, Datum, Cstring
                    183: are members of the group CMObject/Basic0.
                    184: */
                    185:
                    186: /*&C
                    187:
                    188: */
                    189:
                    190: /*&jp
                    191: では, 実際のデータの表現の例をみてみよう.
                    192: たとえば, 32 bit integer の 1234 は,
                    193: */
                    194: /*&eg
                    195: Let us see examples.
                    196: 32 bit integer 1234 is expressed as
                    197: */
                    198: /*&C
                    199: \begin{center}
                    200: ({\tt CMO\_INT32}, 1234)
                    201: \end{center}
                    202: */
                    203: /*&jp
                    204: とかく.
                    205: 文字列 ``Hello''  は
                    206: */
                    207: /*&eg
                    208: The string ``Hello'' is expressed as
                    209: */
                    210: /*&C
                    211: \begin{center}
                    212: ({\tt CMO\_STRING}, 5, "Hello")
                    213: \end{center}
                    214: */
                    215: //&jp と書く.
                    216:
                    217: /*&C
                    218:
                    219: */
                    220: /*&jp
                    221: CMOexpression と, CMObject の区別を理解しておくのは重要である.
                    222: たとえば
                    223: \begin{center}
                    224: ({\tt CMO\_INT32}, 234, "abc",({\tt CMO\_STRING}))
                    225: \end{center}
                    226: は CMOexpression ではあるが, CMObject ではない.
                    227: これは, 文法的には正しいプログラムだが, なにをやるのかは全く不明な
                    228: プログラムと似ている.
                    229:
                    230: さて, Open math 風 (\cite{openmath})
                    231: の SGML 表現法も可能であり, その場合は, 上の二つの例は次のように
                    232: 書く.
                    233: \begin{verbatim}
                    234: <CMO_INT32>
                    235: 1234
                    236: </CMO_INT32>
                    237:
                    238: <CMO_STRING>
                    239: 5
                    240: "Hello"
                    241: </CMO_STRING>
                    242: \end{verbatim}
                    243: */
                    244:
                    245: /*&C
                    246:
                    247: */
                    248:
                    249: /*&jp
                    250: 次に, 標準 encoding 法を説明しよう.
                    251: 標準 encoding 法では, cmo\_tag を ネットワークバイトオーダーの
                    252: 32 bit integer {\tt int32} に,
                    253: その他のフィールドは, 定義に記述されているデータ型に従い,
                    254: byte データ {\tt byte} かまたは
                    255: ネットワークバイトオーダーの 32 bit integer {\tt int32} に, 変換する.
                    256: */
                    257: /*&eg
                    258: Let us explain the standard encoding method.
                    259: All {\tt int32} data are encoded into network byte order 32 bit integers
                    260: and byte data are encoded as it is.
                    261: */
                    262:
                    263: /*&C
                    264:
                    265: */
                    266:
                    267: /*&jp
                    268: 高速の通信方法を用いて
                    269: 効率を重視する接続の場合には, {\tt int32} を network byte order
                    270: に変換する操作がおおきなオーバヘッドとなることが
                    271: 報告されている.
                    272: 100Mbps の通信路で 12Mbytes の {\tt CMO\_ZZ} の転送では
                    273: 約 90\% の時間が network byte order への変換についやされているという
                    274: 実験データもある.
                    275: 効率を重視した encoding 法については後述する.
                    276: */
                    277: /*&eg
                    278: When we are using a high speed network,
                    279: the translation from the internal expression of 32 bit integers to
                    280: network byte order may become a bottle neck.
                    281: There are experimental data which presents that 90 percents of the transmission
                    282: time are
                    283: for the translation to the network byte order to send {\tt CMO\_ZZ} of size
                    284: 12M bytes on a 100Mbps network.
                    285: In a later section, we will discuss a protocol to avoid the translation.
                    286: */
                    287:
                    288: /*&C
                    289:
                    290: */
                    291:
                    292: /*&jp
                    293: 標準 encoding と CMOexpression の間の変換は容易である.
                    294: 前節で用いたデータの表記法,
                    295: たとえば,
                    296: */
                    297: /*&eg
                    298: The translation between the standard encoding and CMOexpression
                    299: is easy.
                    300: For example,
                    301: */
                    302: /*&C
                    303: \begin{center}
                    304: \begin{tabular}{|c|c|}
                    305: \hline
                    306: {\tt int32 CMO\_INT32}& {\tt int32 1234}  \\
                    307: \hline
                    308: \end{tabular}
                    309: \end{center}
                    310: */
                    311: /*&jp
                    312: は, CMOexpression
                    313: */
                    314: /*&eg
                    315: is the encoding of the CMOexpression
                    316: */
                    317: /*&C
                    318: \begin{center}
                    319: ({\tt CMO\_INT32}, 1234)
                    320: \end{center}
                    321: */
                    322: /*&jp
                    323: の 標準 encoding 法による表現である.
                    324: */
                    325:
                    326:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>