main_templates5/bfc.scala
changeset 399 b17a98b0c52f
parent 384 6e1237691307
child 420 4edc1a308652
equal deleted inserted replaced
398:7d9b765d4012 399:b17a98b0c52f
     1 // Core Part about a "Compiler" for the Brainf*** language
     1 // Main Part 5 about a "Compiler" for the Brainf*** language
     2 //======================================================
     2 //============================================================
     3 
     3 
     4 
     4 
     5 object CW10b {
     5 object M5b {
     6 
     6 
     7 
     7 
     8 // !!! Copy any function you need from file bf.scala !!!
     8 // !!! Copy any function you need from file bf.scala !!!
     9 //
     9 //
    10 // If you need any auxiliary function, feel free to 
    10 // If you need any auxiliary function, feel free to 
    93 // memory at the current location to 0. In the compute3 and run3 functions
    93 // memory at the current location to 0. In the compute3 and run3 functions
    94 // below you implement this command by writing the number 0 to mem(mp), 
    94 // below you implement this command by writing the number 0 to mem(mp), 
    95 // that is write(mem, mp, 0). 
    95 // that is write(mem, mp, 0). 
    96 //
    96 //
    97 // The easiest way to modify a string in this way is to use the regular
    97 // The easiest way to modify a string in this way is to use the regular
    98 // expression """[^<>+-,\[\]@#*]""", which recognises everything that is 
    98 // expression """[^<>+-,\[\]]""", which recognises everything that is 
    99 // not a bf-command and replace it by the empty string. Similarly the
    99 // not a bf-command and replace it by the empty string. Similarly the
   100 // regular expression """\[-\]""" finds all occurrences of [-] and 
   100 // regular expression """\[-\]""" finds all occurrences of [-] and 
   101 // by using the Scala method .replaceAll you can replace it with the 
   101 // by using the Scala method .replaceAll you can replace it with the 
   102 // string "0" standing for the new bf-command.
   102 // string "0" standing for the new bf-command.
   103 
   103