SHARE
TWEET

Untitled

a guest Jun 25th, 2019 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class
  2.     {
  3.     New(dir)
  4.         {
  5.         .dir = dir
  6.         }
  7.  
  8.     For_each(list, func)
  9.     {
  10.     for (i = 0; i < list.Size(); ++i)
  11.         func(list[i])
  12.     }
  13.  
  14.     isSysFile(files){
  15.         for file in files
  16.             if file is "Sys.vm"
  17.                 return true
  18.         return false
  19.         }
  20.  
  21.     Vm_files()
  22.         {
  23.         vm_files = Dir(.dir $  "\\*.vm")
  24.         translator = ToAsm()
  25.         result = ""
  26.         if .isSysFile(vm_files)
  27.             result = translator.WriteInit()
  28.         for(file in vm_files)
  29.             {
  30.             src = File(.dir $ "\\" $ file)
  31.             txt = src.Read()
  32.             result $= translator.WriteCode(file,txt)
  33.             src.Close()
  34.             }
  35.         asm = File(.dir $ "\\" $ .dir.Split("\\").Back() $ ".asm", "w")
  36.         asm.Write(result)
  37.         asm.Close()
  38.         }
  39.     Jack_files()
  40.         {
  41.         vm_files = Dir(.dir $  "\\*.jack")
  42.  
  43.  
  44.         for(file in vm_files)
  45.             {
  46.             tokenizer = Tokenizing(.dir $ "\\" $ file)
  47.             xml = tokenizer.Xml()
  48.             file = File(.dir $ "\\" $ file.Split(".")[0] $ "A.xml","w")
  49.             file.Write(xml)
  50.             file.Close()
  51.             }
  52.  
  53.         }
  54.  
  55.  
  56.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top