challenge BFコンパイラー

「どう書く?」でまだ出ていないのが不思議なお題。それがBF処理系。 ここでは、BFで書かれたソースを、同じ言語に変換するコンパイラーを募集します。

私自身、すでにPerlとJavaScriptに関しては http://blog.livedoor.jp/dankogai/archives/50545151.html でやっているのですが、他の言語バージョンも是非見たいので。

Dan the Brainf.ucker

以下のようにonelinerで可能です。 ただしLanguage::BF 0.03が必要です。 CodeRepos経由 で、

  • svn co svn.coderepos.org/share/lang/perl/Language-BF
  • cd Language-BF/trunk
  • perl Makefile.PL
  • make install

するか、CPANにVersion 0.03が現れるのをお待ち下さい。

Dan the Brainf.cker

1
2
3
4
perl -MLanguage::BF \
  -e 'print Language::BF->new_from_file(shift)->as_perl' t/hello.bf \
  | perl
Hello World!

Posted feedbacks - Common Lisp

コードをラベルと命令の列みたいなのにして、
prog の中へ放り込みます。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(defun compile-bf (str &optional (size 30000) (offset 0))
  (let ((tags ()))
    (flet ((translate (c)
             (case c
               (#\> '((incf ptr)))
               (#\< '((decf ptr)))
               (#\+ '((setf *ptr (logand (1+ *ptr) #xff))))
               (#\- '((setf *ptr (logand (1- *ptr) #xff))))
               (#\. '((write-char (code-char *ptr))))
               (#\, '((setf *ptr (char-code (read-char)))))
               (#\[ (let ((t1 (gensym)) (t2 (gensym)))
                      (setf tags (list* t1 t2 tags))
                      `(,t1 (if (= *ptr 0) (go ,t2)))))
               (#\] (let ((t1 (pop tags)) (t2 (pop tags)))
                      `((if (/= *ptr 0) (go ,t1)) ,t2))))))
      `(symbol-macrolet ((*ptr (aref array ptr)))
         (prog ((array ,(make-array size :initial-element 0))
                (ptr ,offset))
           ,@(loop for c across str append (translate c)))))))

;;; test
(eval (compile-bf "+++++++++[>++++++++>+++++++++++>+++++<<<-]>.>++.
+++++++..+++.>-.------------.<++++++++.--------.+++.------.--------.>+."))

<a href=http://www.silka.org/>buy valium online</a>
The increased and prolonged sedation is identified to occur with cimetidine, ketoconazole, fluvoxamine, fluoxetine and omeprazole.

System Message: WARNING/2 (<string>, line 4)

Definition list ends without a blank line; unexpected unindent.

<a href=http://www.silka.org/>buy valium online</a>

In patients with myasthenia gravis who are prescribed with Valium, care should be taken on account of preexisting muscle weakness. http://www.silka.org/ - valium pill

System Message: ERROR/3 (<string>, line 8)

Unexpected indentation.
No prescription is needed!

System Message: WARNING/2 (<string>, line 9)

Block quote ends without a blank line; unexpected unindent.

If Valium is to be combined with other centrally-acting agents, for example, antipsychotics, anxiolytics/sedatives, antidepressants, hypnotics, anticonvulsants, narcotic analgesics, anesthetics and sedative antihistamines, it should be borne in mind that their effects may potentiate or be potentiated by the action of Valium.


Hi, <a href=http://nicheblogssquad.com/>Play Online Casino</a>

System Message: ERROR/3 (<string>, line 3)

Unexpected indentation.
These websites are absolutely legitimate and authorized by government.

System Message: WARNING/2 (<string>, line 4)

Block quote ends without a blank line; unexpected unindent.
<a href=http://nicheblogssquad.com/>Play Casino For Fun</a>
Online gaming is taking the industry by storm and people don't even require leaving their home to have some fun with gambling.
http://nicheblogssquad.com/ - Best Online Casinos
Some websites are freely accessible, while you'll require putting down a certain deposit in others.

На финансовом рынке страны Всеукраинский Акционерный Банк (<a href=http://www.express-release.com/organization/1417>VAB Банк</a>) работает с 1992 года и, согласно данным НБУ, входит в группу крупных финансовых учреждений. С октября 2006 года – в составе универсальной финансовой группы VAB Group. Региональная сеть Банка по состоянию на 1.03.2009 г. представлена 22 филиалами и 151 отделениями в Украине, а также представительством в г. Будапешт (Венгрия). В числе акционеров <a href=http://www.express-release.com/organization/1417>VAB Банк</a> – крупная международная компания TBIF Financial Services BV (Амстердам, Нидерланды). По состоянию на 1 января 2009 года объем чистых активов VAB Банка составил 7,7 млрд грн, регулятивный капитал Банка – 925 млн грн. <a href=http://www.express-release.com/organization/1417>VAB Банк</a> <a href=http://www.express-release.com/organization/1417>VAB Банк</a> http://www.express-release.com/organization/1417 - VAB Банк


Biden War On Drugs <a href=http://greenheartmedicaluniversity.com/>order acomplia online</a>

System Message: ERROR/3 (<string>, line 3)

Unexpected indentation.
Almost half of the volunteers who took part in the study showed improvement in HDL-cholesterol level beyond the expected increase resulting from weight loss.

System Message: WARNING/2 (<string>, line 4)

Block quote ends without a blank line; unexpected unindent.
<a href=http://greenheartmedicaluniversity.com/>buy acomplia on line</a>
In test periods, Acomplia is found to associate a few side effects among which vomiting tendency and nausea was most common.
http://greenheartmedicaluniversity.com/ - buy acomplia
It was initially launched in UK and then gradually launched in Denmark, Ireland, Germany, Finland and Norway in the last 6 months of that year.

Better Medicine Canada fartonast <a href=http://www.jo3design.com/>Vardenafil Online</a>

System Message: ERROR/3 (<string>, line 3)

Unexpected indentation.
If a patient has an allergy to the drug content of Levitra, this drug is not recommended for him.

System Message: WARNING/2 (<string>, line 4)

Block quote ends without a blank line; unexpected unindent.
<a href=http://www.jo3design.com/>Buy Levitra On Line</a>
Levitra loosens the muscles around the penile area of the male body allowing blood to flow into the penis at increased rates.
http://www.jo3design.com/ - Levitra Online Sales
Levitra is a pill that is taken orally by the male suffering from erectile dysfunction, once daily preferably before sexual intercourse.
http://www.foodfashionofindia.com/ - generic finasteride
Patients sometimes experience hive, rash, pores on face and lips and itching.
<a href=http://www.foodfashionofindia.com/>finasteride mg</a>
There are not many reporting of overdose effect.
<a href=http://www.foodfashionofindia.com/>propecia finasteride</a>
Symptoms of male breast cancer are sometimes reported by the users.

Index

Feed

Other

Link

Pathtraq

loading...