repl.it
Go

A turing complete language based on pikachus, brainf and an r/ProgrammerHumour post

fork
loading
Files
  • main.go
  • bf.go
  • script.pika
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main

import (
  "fmt"
  "io/ioutil"
  "strings"
  
)
func check(e error){
  if e != nil{
    panic(e)
  }
  return
}
func main() {
  var filename string
  fmt.Print("input a file name ")
  fmt.Scan(&filename)
  file,err := ioutil.ReadFile(filename)
  check(err)
  script := string(file)
  
  eval(script)

}
func eval(s string) {
  forbidden := []byte("+-><[],.")
  for _,v:=range forbidden{
    strings.Replace(s,string(v),"",-1)
  }
  
  s=strings.Replace(s,"pikachu","]",-1)
  s=strings.Replace(s,"pikapika",".",-1)
  s=strings.Replace(s,"pikapi","<",-1)
  s=strings.Replace(s,"pichu","[",-1)
  s=strings.Replace(s,"pika","+",-1)
  s=strings.Replace(s,"chu","-",-1)
  s=strings.Replace(s,"achu",",",-1)
  s=strings.Replace(s,"pi",">",-1)
  s=strings.Replace(s," ","", -1)
  program,err:=Compile_bf(s)
  check(err)
  Execute_bf(program)
  
}



?