view interps/egobf/src/wib.b @ 12500:e48c08805365 draft default tip

<b_jonas> ` learn \'The password of the month is Cthulhuquagdonic Mothraquagdonic Narwhalicorn.\' # https://logs.esolangs.org/libera-esolangs/2024-04.html#lKE Infinite craft
author HackEso <hackeso@esolangs.org>
date Wed, 01 May 2024 06:39:10 +0000
parents 859f9b4339e6
children
line wrap: on
line source

#!@prefix@/bin/egobfi8
[
Written In Brainfuck (wib) v0.96
Brainfuck to C translator by Mats Linander

This program reads brainfuck sourcecode from stdin, translates it into c code
and outputs it to stdout. Wib assumes that EOF == -1.

Windows based c compilers may have problems compiling code generated by wib
as it produces unix style newlines ('\n'==0x0a).


Changelog

v0.96:   2003-05-??
 * New itoa routine
 * Some tinkering to reduce size
v0.95:   2003-05-03
 * Bugfix. Wib said "++*p" where it should have been "--*p".
v0.94:   2003-04-22
 * Wib is now officially an optimizing translator, a series of n '+' now
   produces an output of *p+=n;\n. The same goes for '-'.
v0.93:   2002-08-22
 * Removed all - that were immediately followed by + and vice versa.
v0.92:   2002-08-21
 * Changed the output for dots, EOF should be EOF and nothing else.
   AFAIK this means wib follows the spec.
 * Made wib assume EOF==EOF&&EOF!='\0'
 * Put this stuff within brackets. Since *p is always zero at this point,
   the loop will never be entered and any chars can be used here.
 * Changed the GPL copyright statement to the ordinary one, including special
   chars.
v0.91:   2002-05-23
 * Added the GPL license statement thingie
v0.90:   2002-05-20
 * Wib now outputs 'if((*p=getchar())==EOF)*p=0;\n' when a dot is read
   Noticed that almost every other bf compiler does it so why not mine?
v0.80:   2002-05-19
 * First working version


  Copyright (C) 2002, 2003, 2004 Mats Linander

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

]





+++++++[->>+++++<<]>>.<[-]<[-]+++++++[->+++++[->>+++<<]<]>>>.<<[-]<[-]>>>[-
<<+>>>+>+>+>+>+>+<<<<<<]<<[->>+<<]>>>+++++.>------.>+++.>++++++++++++.>----
-.>----.>>++++++++[-<++++>]<.>>++++++[->+++++[-<<++>>]<]<.<<[->>>+>+>+>+>+>
+>+          <<<<<<<<<]>>>>>          >>>[-<<<<<<<<+      >>>>>>>>]<<<<<+++
+++++      ++++++.>+++++++++++      ++++.     >-.>+++     +.>++++++++++.>>+
++>++      +++++++[-<<+++++>>]      <<+.       >.>>++     ++++[->+++++[-<<+
+>>]<      ]<++.>++++++++++.<<      <<<<       <<<<<<     <<<<<<.>.>.>.>.>.
>.>.>      .>.>.>.>.>+++.>----      --.>>     >>>[-]<     [->+<]<[->+<]<[->
+<]<[      ->+<]>>>>>+++++++[-      >+++++++[-<<<<<<+     +>>>>>>]<]<<<<<.>
.>.>.      >.<<<<+.>>.<<--.<<<      <<-        .<<.>>     >>>>>+.-------.>+
++++.      ---....<++.>>>---.>      .<<<<      ++++++     .>>.<<--.<<<<<.<<
.++++      ++++++.>>--.<+.>>>-      -.>>>      >>>.>.           <<<<<.<++.<
<.<<<      ----------.>>>>>-.>      >.<.<      +.<<<<            <++++++++.
+.>>>      >>>>>>>+++[->>++<<]      >>-.<      .<<<<<     <++[-   >>>>>>>>>
>+>>>      >+>+>+>+>+>+>+>+>>>      +>>>>      +>+>+>     +>+>>>   +<<<<<<<
<<<<<<      <<<<<<<<<<<<<<<<<      <<<<<]      <<<<[-     >>>>>>   >>>>>>>>
>>+>>>>      >>>         >>>      >>>>+<<      <<<<<<     <<<<<<   <<<<<<<<
<<<<<<<<      ]     >     >      >>>>>---      -[->>>     >>+>+>   >+>>>>>>
>>>>>+>+>>         +>>         >>>>>>+>+>      >+<<<<     <<<<<    <<<<<<<<
<<<<<<<<<<<<      <<<<]      >>>[->>>>>          >>+             >>>>>>>>>>
>>>>+<<<<<<<<<<<<<<<<<<<<<]>[->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+>+<<<<<<<<<<<<
<<<<<<<<<<<<<<<<<<<]>+>->>-->-->>+++++>++++>--------->----------->---------
---->-------->--------------->++>---->-->>--->-->>+++++++>-------->------->
---->----------->---->-->>--->>++<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[-]<[-]<[-]
<[-]<[-],+[---------------------------------------------->[-]+<[>[-]<[->>+<
<]]>[>>[-]>[-]<<<[>>+>[-]++++++++++[-<---------->]+<[>[-]<[-<<<+>>>]]<<<[->
>>+<<<]>>>>[[-]<[-]>++++++++++[-<---------->]>>>>.<.<<.>>>>++.------------.
-..+++++++++++.>.<<<<<<[-]]++++++++++[-<++++++++++>]<<,--------------------
-------------------------<[-]+>[<[-]>[-<<+>>]]<<[->>+<<]>]>>>>>>>.<.<<.>>>>
++.-->>>>>>>>>>>>>>>>>>>>>>>>>>>[-]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[->>>>>
>>>>>>>>>>>>>>>>>>                                           >>>>>>>>>>+<<<
<<<<<<<<<<<<<<<<<  <<<<<<<<<<<<<]>>>>>>>>>>>>>>>>>>>>>>>>>   >>>>>>>>[->+<]
>>>++++++++++[-<   ++++++++++>]<<>>[-]>[-]>[-]>[-]>[-]>[-    ]>[-]<<<<<<<<[
->>+>+<<<]>>>[-    <<<+>>>]<<<>[->>+>+<<<]>>>[-<<<+>>>]<  <  <<>>>[>>[-]<<<
[->>>+>>+<<<<<  ]  >>>>>[-<<<<<+>>>>>]<<<<[<->->>>+<<<<  >>  >>>>+<<<<<<[[-
>>>>>+<<<<<]>  >>  >>>[-]<<<<<<]>>>>>[-<<<<<+>>>>>]<<<  <<>  >>>>>[[-]<<<<<
[-]>>>>>]<<<  <<]  <[[->>>>>+<<<<<]>>+>>[-<<<+>>>]<<<  <]>>  >>>[-<<<<<+>>>
>>]<<<<][-]  <[-]  >>[-<<+>>]>[-<<+>>]>[-]>[-]>[-]<<  <<<<<  <>[->>>+>+<<<<
]>>>>[-<<<  <+>>>  >]<<[->>+>+<<<]>>>[-<<<+>>>]<<[-  >-<]>>  [-]+<[>-<[-]]>
[[-]<<<[-  ]<+>>>  >]<[-]<[-]<<<<>>>>[-]>[-]<<<<<[  ->>>>+>  +<<<<<]>>>>>[-
<<<<<+>>  >>>]<>[  -]+<[>[-]<[-]]>[<<[-]<[-]<[->>  +>+<<<]>  >>[-<<<+>>>]>[
-]]<<<<                                           <>>[<<[-]  <+>>>>[-<<<+>>
>]++++  ++++[-<++  ++++>]<.[-]]<[-]++++++++++<>>  [-]>[-]>[  -]>[-]>[-]>[-]
>[-]<<  <<<<<<[->  >+>+<<<]>>>[-<<<+>>>]<<<>[->>  +>+<<<]>>  >[-<<<+>>>]<<<
<>>>[>  >[-]<<<[-  >>>+>>+<<<<<]>>>>>[-<<<<<+>>>  >>]<<<<[<  ->->>>+<<<<>>>
>>>+<<  <<<<[[->>  >>>+<<<<<]>>>>>>[-]<<<<<<]>>>  >>[-<<<<<  +>>>>>]<<<<<>>
>>>>[[  -]<<<<<[-  ]>>>>>]<<<<<]<[[->>>>>+<<<<<]  >>+>>[-<<  <+>>>]<<<<]>>>
>>[-<<  <<<+>>>>>  ]<<<<][-]<[-]>>[-<<+>>]>[-<<+  >>]>[-]>[  -]>[-]<<<<<<<<
>[->>>  +>+<<<<]>  >>>[-<<<<+>>>>]<<[->>+>+<<<]>  >>[-<<<+>  >>]<<[->-<]>>[
-]+<[>  -<[-]]>[[  -]<<<[-]<+>>>>]<[-]<[-]<<<<>>  >>[-]>[-]  <<<<<[->>>>+>+
<<<<<]  >>>>>[-<<  <<<+>>>>>]<>[-]+<[>[-]<[-]]>[  <<[-]<[-]  <[->>+>+<<<]>>
>[-<<<  +>>>]>[-]  ]<<<<<>[-]+>[<[-]<[-]>>>[-<<<  +>>>]++++  ++++[-<++++++>
]<.[-]  ]<[<<[[-]  >>[-]++++++++[-<<++++++>>]<<.  [-]]>>[-]  ][-]++++++++[-
<+++++  +>]<.<[-]  >[-]>[-]>[-]>[-]>[-]>[-]>[-]>  [-]>[-]<<  <<<<<<<<<<<<<<
<<<<<<  <<<<<<<<<  <<<<<.>.<<<<<<<<<<[-]>[-]]>[-  <<+>>]<<+  +>[-]+<[>[-]<[
->>+<<  ]]>[>>[-]  >[-]<<<[>>+>[-]++++++++++[-<-  ---------  >]+<[>[-]<[-<<
<+>>>]  ]<<<[->>>                                            +<<<]>>>>[[-]<
[-]>++  ++++++++  [-<---------->]>>>>.<.<.>>>++.  --------  ----.-..+++++++
++++.>  .<<<<<<  [-]]++++++++++[-<++++++++++>]<<  ,------  ----------------
------  ------  ---------<[-]+>[<[-]>[-<<+>>]]<<  [->>+<  <]>]>>>>>>>.<.<.>
>>++.-  ->>>>  >>>>>>>>>>>>>>>>>>>>>>>[-]<<<<<<<  <<<<<  <<<<<<<<<<<<<<<<<<
<<<[->  >>>>  >>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<  <<<<  <<<<<<<<<<<<<<<<<<<
<<<<<]  >>>  >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>[->+<  ]>>  >++++++++++[-<++++++
++++>]  <<  >>[-]>[-]>[-]>[-]>[-]>[-]>[-]<<<<<<<  <[  ->>+>+<<<]>>>[-<<<+>>
>]<<<>  [  ->>+>+<<<]>>>[-<<<+>>>]<<<<>>>[>>[-]<  <  <[->>>+>>+<<<<<]>>>>>[
-<<<<<    +>>>>>]<<<<[<->->>>+<<<<>>>>>>+<<<<<<[    [->>>>>+<<<<<]>>>>>>[-]
<<<<<<   ]>>>>>[-<<<<<+>>>>>]<<<<<>>>>>>[[-]<<<<   <[-]>>>>>]<<<<<]<[[->>>>
>+<<<<                                            <]>>+>>[-<<<+>>>]<<<<]>>>
>>[-<<<<<+>>>>>]<<<<][-]<[-]>>[-<<+>>]>[-<<+>>]>[-]>[-]>[-]<<<<<<<<>[->>>+>
+<<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>.<<<<<<<<<<[-]>[-]]>[-<<+>>]<<-->[-]+<[>-<[->>+<<]]>[>>>>..>>>.
<.>>.>.<<<<<<<<<[-]]>[-<<+>>]<<--------------->[-]+<[>-<[->>+<<]]>[>>>>>>.<
<..>>>>.>.<<<<<<<<<[-]]>[-<<+>>]<<-->[-]+<[>-<[->>+<<]]>[>>>>>>.<..>>>.>.<<
<<<<<<<[-]]>[-<<+>>]<<----------------------------->[-]+<[>-<[->>+<<]]>[>>>
>>>>>>>>>>>>>>>>>>>>>.>.>.>.>.>.>.>.>.>.<<<<<<<<<<.<<<<<<<<<<<<<<<<<<<<<<<[
-]]>[-<<+>>]<<-->[-]+<[>-<[->>+<<]]>[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.<<<
<<<<<<<<.<<<<<<<<<<<<<<<<<<<<<<<[-]]>[-<<+>>]<<++++++++++++++++++++++++++++
+++++++++++++++++++++>[-]+<[>-<[->>+<<]]>[>>>>>>>.<.>>++.-->>>>.>.<<.>>>.>.
>.>.>.>>>.>.>.<<<<<<<<<<<<<<<<<<<<<<<[-]]>[-<<+>>]<<-->[-]+<[>-<[->>+<<]]>[
>>>>>>.>>>>.>.>>>.>.>.>.>.>.>.>.>.>.<<<<<<<<<<<<<<<<<<<<<<<[-]]>[-<<+>>]<<+
++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<+<[>[-]>,+<<[-]][-]>
[>[-]<[-]]>[-<<+>>]<<]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.<<<<<<<<<<<.