Anonymous avatar Anonymous committed c1a46bb

translate to japanese

Comments (0)

Files changed (1)

-================================
-Writing an Interpreter with PyPy
-================================
-Written by Andrew Brown <brownan@gmail.com>, with help from the PyPy developers
-on the pypy-dev mailing list.
+.. ================================
+.. Writing an Interpreter with PyPy
+.. ================================
 
-This tutorial's master copy and supporting files live at
+===================================
+ PyPy を使ってでインタプリタを書く
+===================================
+
+.. Written by Andrew Brown <brownan@gmail.com>, with help from the PyPy developers
+.. on the pypy-dev mailing list.
+
+pypy-dev mailing list の助力によって Andrew Brown によって書かれました。
+
+.. This tutorial's master copy and supporting files live at
+
+このチュートリアルのマスタコピーと追加のファイルはここにあります。
 https://bitbucket.org/brownan/pypy-tutorial/
 
-When I first learned about the PyPy project, it took me a while to figure out
-exactly what it was about. For those that don't already know, it's two things:
+.. When I first learned about the PyPy project, it took me a while to figure out
+.. exactly what it was about. For those that don't already know, it's two things:
 
-* A set of tools for implementing interpreters for interpreted languages
+私が最初に PyPy プロジェクトについて知ったとき、それがなんであるか正確に理解するのに時間がかかりました。
+それがなんであるかまだ知らない人のために説明すると、それは2つのことで:
+
+.. * A set of tools for implementing interpreters for interpreted languages
+
+* インタプリタ型言語のインタプリタを実装するためのツールセット
   
-* An implementation of Python using this toolchain
+.. * An implementation of Python using this toolchain
+
+* このtoolchainを使用した Python の実装
   
-The second part is probably what most people think PyPy is, but this tutorial
-is *not* about their Python interpreter.  It is about writing your own
-interpreter for your own language.
+.. The second part is probably what most people think PyPy is, but this tutorial
+.. is *not* about their Python interpreter.  It is about writing your own
+.. interpreter for your own language.
 
-This is the project I undertook to help myself better understand how PyPy works
-and what it's all about.
+ほとんどの人は2つ目のパートが PyPy であると思っていますが、このチュートリアルはその Python インタプリタについてのもの **ではありません** 。
+あなた自身の言語のインタプリタを書くためのものです。
 
-This tutorial assumes you know very little about PyPy, how it works, and even
-what it's all about. I'm starting from the very beginning here.
+.. This is the project I undertook to help myself better understand how PyPy works
+.. and what it's all about.
 
-What PyPy Does
-==============
-Here's a brief overview of what PyPy can do. Let's say you want to write an
-interpreted language. This involves writing some kind of source code parser, a
-bytecode interpretation loop, and lots of standard library code.
+このプロジェクトは、私が PyPy がどのように働き、それがなんであるかをよりよく理解するための助けとするためのものです。
 
-That's quite a bit of work for moderately complicated languages, and there's a
-lot of low level work involved. Writing the parser and compiler code usually
-isn't fun, that's why there are tools out there to generate parsers and
-compilers for you.
+.. This tutorial assumes you know very little about PyPy, how it works, and even
+.. what it's all about. I'm starting from the very beginning here.
 
-Even then, you still must worry about memory management in your interpreter,
-and you're going to be re-implementing a lot if you want data types like
-arbitrary precision integers, nice general hash tables, and such. It's enough
-to put someone off from implementing their idea for a language.
+このチュートリアルは PyPy がどのように働き、そしてそれが何であるかについて少しばかり知っているという前提で書かれています。
 
-Wouldn't it be nice if you could write your language in an existing high level
-language like, for example, Python? That sure would be ideal, you'd get all the
-advantages of a high level language like automatic memory management and rich
-data types at your disposal.  Oh, but an interpreted language interpreting
-another language would be slow, right? That's twice as much interpreting going
-on.
 
-As you may have guessed, PyPy solves this problem. PyPy is a sophisticated
-toolchain for analyzing and translating your interpreter code to C code (or JVM
-or CLI). This process is called "translation", and it knows how to translate
-quite a lot of Python's syntax and standard libraries, but not everything. All
-you have to do is write your interpreter in **RPython**, a subset of the Python
-language carefully defined to allow this kind of analysis and translation, and
-PyPy will produce for you a very efficient interpreter.
+.. What PyPy Does
 
-Because efficient interpreters should not be hard to write.
+PyPy が何をするのか
+===================
 
-The Language
-============
-The language I've chosen to implement is dead simple. The language runtime
-consists of a tape of integers, all initialized to zero, and a single pointer
-to one of the tape's cells. The language has 8 commands, described here:
+.. Here's a brief overview of what PyPy can do. Let's say you want to write an
+.. interpreted language. This involves writing some kind of source code parser, a
+.. bytecode interpretation loop, and lots of standard library code.
+
+ここは PyPy で何ができるかの簡単な概要を説明します。例えば、あなたがインタプリタ型言語を作りたいと思っているとします。
+これにはソースコードパーサ、バイトコードインタプリタループそして標準ライブラリのコードを書くことが伴います。
+
+
+.. That's quite a bit of work for moderately complicated languages, and there's a
+.. lot of low level work involved. Writing the parser and compiler code usually
+.. isn't fun, that's why there are tools out there to generate parsers and
+.. compilers for you.
+
+これは適度に複雑な言語を実装するためにはかなりの作業で、さらに多くの低レベルな作業があります。
+パーサとコンパイラのコードを書くことは通常あまり楽しくはありません。それがあなたのためのパーサとコンパイラを生成するツールが存在する理由です。
+
+.. Even then, you still must worry about memory management in your interpreter,
+.. and you're going to be re-implementing a lot if you want data types like
+.. arbitrary precision integers, nice general hash tables, and such. It's enough
+.. to put someone off from implementing their idea for a language.
+
+その場合でも、あなたはまだインタプリタのメモリ管理について心配する必要があります。
+そしてあなたは任意精度の整数や素敵な一般的なハッシュテーブルなどの多くを再実装することになるでしょう。
+その労力は彼らに言語のアイデアを実装することを先送りにさせるためには十分です。
+
+
+.. Wouldn't it be nice if you could write your language in an existing high level
+.. language like, for example, Python? That sure would be ideal, you'd get all the
+.. advantages of a high level language like automatic memory management and rich
+.. data types at your disposal.  Oh, but an interpreted language interpreting
+.. another language would be slow, right? That's twice as much interpreting going on.
+
+もしあなたが既存の高級言語に似た言語で、例えば Python であなたの言語を記述できたとすれば素敵だと思いませんか?
+あなたが自動メモリ管理やリッチなデータ型などの高級言語の全ての利点を利用したいと思うならば、それはたしかに理想的になるでしょう。
+ああ、しかしインタプリタが他の言語を他の言語で解釈することで遅くなると思っていませんか? 実行のために二倍の解釈をしなければいけませんから。
+
+
+.. As you may have guessed, PyPy solves this problem. PyPy is a sophisticated
+.. toolchain for analyzing and translating your interpreter code to C code (or JVM
+.. or CLI). This process is called "translation", and it knows how to translate
+.. quite a lot of Python's syntax and standard libraries, but not everything. All
+.. you have to do is write your interpreter in **RPython**, a subset of the Python
+.. language carefully defined to allow this kind of analysis and translation, and
+.. PyPy will produce for you a very efficient interpreter.
+
+あなたが予想しているとおり、 PyPy はこの問題を解決します。
+PyPy はあなたのインタプリタのコードを C(もしくは JVM や CLI)に解析・変換するための洗練されたツールチェインです。
+このプロセスは"変換"と呼ばれ、 Python の構文と多くの標準ライブラリの構文を変換する方法を知っていますが、全てではありません。
+あなたがしなければならないことは、Python のサブセットである **RPython** で解析と変換ができるように慎重に定義し、インタプリタを書くことが全てです。そして、 PyPy はあなたのために非常に効率的なインタプリタを生成します。
+
+
+.. Because efficient interpreters should not be hard to write.
+
+なので、効率的なインタプリタを書くことは難しくありません。
+
+
+.. The Language
+
+言語
+====
+
+.. The language I've chosen to implement is dead simple. The language runtime
+.. consists of a tape of integers, all initialized to zero, and a single pointer
+.. to one of the tape's cells. The language has 8 commands, described here:
+
+私が実装することを選択した言語は死ぬほど簡単です。
+言語のランタイムは、ゼロで初期化された整数値の書き込めるテープとテープのセルを指すポインタで構成されています。
+言語は以下のような8つのコマンドを持ちます。
 
 >
-    Moves the tape pointer one cell to the right
+    .. Moves the tape pointer one cell to the right
+    
+    テープのポインタを1セル右に動かす
     
 <
-    Moves the tape pointer one cell to the left
+    .. Moves the tape pointer one cell to the left
+
+    テープのポインタを1セル左に動かす
     
 +
-    Increments the value of the cell underneath the pointer
+    .. Increments the value of the cell underneath the pointer
+
+    ポインタが指すセルの値をインクリメントする
     
 -
-    Decrements the value of the cell underneath the pointer
+    .. Decrements the value of the cell underneath the pointer
+
+    ポインタが指すセルの値をデクリメントする
 
 [
-    If the cell under the current pointer is 0, skip to the instruction after
-    the matching ]
+    .. If the cell under the current pointer is 0, skip to the instruction after
+    .. the matching ]
+
+    もしポインタが指すセルの値が 0 ならば対応する ] までスキップする
+    
     
 ]
-    Skip back to the matching [ (evaluating its condition)
+    .. Skip back to the matching [ (evaluating its condition)
+
+    対応する [ まで戻る ([ は評価される)
+    
     
 .
-    Print out a single byte to stdout from the cell under the pointer
+    .. Print out a single byte to stdout from the cell under the pointer
+
+    ポインタが指すセルのバイト値を標準出力にプリントする
     
 ,
-    Read in a single byte from stdin to the cell under the pointer
+    .. Read in a single byte from stdin to the cell under the pointer
+
+    単一バイトを標準出力から読み込み、ポインタが指すセルに格納する
     
-Any unrecognized bytes are ignored.
+    
+.. Any unrecognized bytes are ignored.
 
-Some of you may recognize this language. I will be referring to it as BF.
+認識されないバイトば無視されます。
 
-One thing to notice is that the language is its own bytecode; there is no
-translation from source code to bytecode. This means that the language can be
-interpreted directly: the main eval loop of our interpreter will operate right
-on the source code. This simplifies the implementation quite a bit.
+.. Some of you may recognize this language. I will be referring to it as BF.
+
+何人かはこの言語に見覚えがあるでしょう。私はこれを BF と呼ぶことにします。
+
+.. One thing to notice is that the language is its own bytecode; there is no
+.. translation from source code to bytecode. This means that the language can be
+.. interpreted directly: the main eval loop of our interpreter will operate right
+.. on the source code. This simplifies the implementation quite a bit.
+
+ひとつ、言語は独自のバイトコードを持つことに気づくでしょう。そしてソースコードからバイトコードへの変換はありません。
+これが意味することは、言語は直接解釈できるということです。インタプリタのメインの評価ループは、ソースコード上で動作します。
+これはかなり実装を簡潔にしています。
+
 
 First Steps
 ===========
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.