"codeop" --- Pythonコードをコンパイルする
*****************************************

**ソースコード:** Lib/codeop.py

======================================================================

"codeop" モジュールは、 "code" モジュールで行われているようなPythonの
read-eval-printループをエミュレートするユーティリティを提供します。そ
のため、このモジュールを直接利用する場面はあまり無いでしょう。プログラ
ムにこのようなループを含めたい場合は、 "code" モジュールの方が便利です
。

この仕事には二つの部分があります:

1. Being able to tell if a line of input completes a Python statement:
   in short, telling whether to print '">>>"' or '"..."' next.

2. Remembering which future statements the user has entered, so
   subsequent input can be compiled with these in effect.

"codeop" モジュールはこうしたことのそれぞれを行う方法とそれら両方を行
う方法を提供します。

前者は実行するには:

codeop.compile_command(source, filename='<input>', symbol='single')

   Tries to compile *source*, which should be a string of Python code
   and return a code object if *source* is valid Python code.  In that
   case, the filename attribute of the code object will be *filename*,
   which defaults to "'<input>'".  Returns "None" if *source* is *not*
   valid Python code, but is a prefix of valid Python code.

   *source* に問題がある場合は、例外を発生させます。無効なPython構文が
   ある場合は、 "SyntaxError" を発生させます。また、無効なリテラルがあ
   る場合は、 "OverflowError" または "ValueError" を発生させます。

   The *symbol* argument determines whether *source* is compiled as a
   statement ("'single'", the default), as a sequence of *statement*
   ("'exec'") or as an *expression* ("'eval'").  Any other value will
   cause "ValueError" to be raised.

   注釈:

     ソースの終わりに達する前に、成功した結果をもってパーサは構文解析
     を止めることがあります。このような場合、後ろに続く記号はエラーと
     ならずに無視されます。例えば、バックスラッシュの後ろに改行が2つあ
     って、その後ろにゴミがあるかもしれません。パーサのAPIがより良くな
     ればすぐに、この挙動は修正されるでしょう。

class codeop.Compile

   このクラスのインスタンスは組み込み関数 "compile()" とシグネチャが一
   致する "__call__()" メソッドを持っていますが、インスタンスが
   "__future__" 文を含むプログラムテキストをコンパイルする場合は、イン
   スタンスは有効なその文とともに続くすべてのプログラムテキストを'覚え
   ていて'コンパイルするという違いがあります。

class codeop.CommandCompiler

   Instances of this class have "__call__()" methods identical in
   signature to "compile_command()"; the difference is that if the
   instance compiles program text containing a "__future__" statement,
   the instance 'remembers' and compiles all subsequent program texts
   with the statement in force.
