=================================================================== RCS file: /home/cvs/OpenXM/src/asir-doc/parts/asir.texi,v retrieving revision 1.4 retrieving revision 1.6 diff -u -p -r1.4 -r1.6 --- OpenXM/src/asir-doc/parts/asir.texi 2000/01/26 01:37:32 1.4 +++ OpenXM/src/asir-doc/parts/asir.texi 2002/09/03 01:50:57 1.6 @@ -1,4 +1,4 @@ -@comment $OpenXM: OpenXM/src/asir-doc/parts/asir.texi,v 1.3 1999/12/21 02:47:31 noro Exp $ +@comment $OpenXM: OpenXM/src/asir-doc/parts/asir.texi,v 1.5 2000/09/23 07:53:24 noro Exp $ \BJP @node ユーザ言語 Asir,,, Top @chapter ユーザ言語 Asir @@ -254,6 +254,7 @@ comprehensible than use of structure like C programs. * return 文:: * if 文:: * ループ break return continue:: +* 構造体定義:: * さまざまな式:: * プリプロセッサ:: * オプション指定:: @@ -267,6 +268,7 @@ comprehensible than use of structure like C programs. * return statement:: * if statement:: * loop break return continue:: +* structure definition:: * various expressions:: * preprocessor:: * option:: @@ -574,7 +576,7 @@ def afo(X) @{ @samp{/*} がいくつあっても最初のもののみが有効となり, 最初に現れた @samp{*/} でコメントは終了したと見なされる. プログラムなどで, コメント を含む可能性がある部分をコメントアウトした場合には, @code{#if 0}, -@code{#endif}を使えばよい. (@xref{プリプロセッサ}) +@code{#endif}を使えばよい. (@xref{プリプロセッサ}.) \E \BEG A comment can span to several lines, but it cannot be nested. @@ -583,7 +585,7 @@ in the subsequent text exist, and the comment terminat @samp{*/}. In order to comment out a program part that may contain comments in it, -use the pair, @code{#if 0} and @code{#endif}. (@xref{preprocessor}) +use the pair, @code{#if 0} and @code{#endif}. (@xref{preprocessor}.) \E @example @@ -650,7 +652,7 @@ S = sum(N); \BJP のように, 式に終端記号 (@samp{;} または @samp{$}) をつけたものである. この単文及び類似の @code{return} 文, @code{break} 文などが文の最小構成 -単位となる. @code{if} 文や @code{for} 文の定義 (@xref{文法の詳細}) を見れ +単位となる. @code{if} 文や @code{for} 文の定義 (@ref{文法の詳細}) を見れ ばわかる通り, それらの本体は, 単なる一つの文として定義されている. 通常 は, 本体には複数の文が書けることが必要となる. このような場合, @samp{@{} と @samp{@}} で文の並びを括って, 一つの文として扱うことがで @@ -988,6 +990,46 @@ statement, and the termination condition will be evalu @code{while} statement. \E @end itemize + +\BJP +@node 構造体定義,,, ユーザ定義函数の書き方 +@subsection 構造体定義 +\E +\BEG +@node structure definition,,, Writing user defined functions +@subsection structure definition +\E + +\BJP +構造体とは, 各成分の要素が名前でアクセスできる固定長配列と思ってよい. +各構造体は名前で区別される. 構造体は, @code{struct} 文により宣言される. +ある型の構造体は, 組み込み関数 @code{newstruct} により生成される. +構造体の各メンバは, 演算子 @code{->} によりアクセスする. +メンバが構造体の場合, @code{->} による指定は入れ子にできる. +\E + +\BEG +A structure data type is a fixed length array and each component of the array +is accessed by its name. Each type of structure is distinguished by its name. +A structure data type is declared by @code{struct} statement. +A structure object is generated by a builtin function @code{newstruct}. +Each member of a structure is accessed by an operatator @code{->}. +If a member of a structure is again a structure, then the specification +by @code{->} can be nested. +\E + +@example +[1] struct rat @{num,denom@}; +0 +[2] A = newstruct(rat); +@{0,0@} +[3] A->num = 1; +1 +[4] A->den = 2; +2 +[5] A; +@{1,2@} +@end example \BJP @node さまざまな式,,, ユーザ定義函数の書き方