Example #1
0
func Run(filename string) {
	b, err := ioutil.ReadFile(filename)
	if err != nil {
		panic(err)
	}

	p := parser.ParseFromString(filename, string(b)+"\n")

	v := compiler.Compile(p)
	compiler.PrintOut(v)

	//a := generator.GenerateAST(p)

	//fset := token.NewFileSet()

	//var buf bytes.Buffer
	//printer.Fprint(&buf, fset, a)
	//fmt.Printf("%s\n", buf.String())
}
Example #2
0
func Run() {
	r := bufio.NewReader(os.Stdin)

	for {
		fmt.Print(">> ")
		line, _, _ := r.ReadLine()
		p := parser.ParseFromString(PROGRAMNAME, string(line)+"\n")
		fmt.Println(p)

		// a := generator.GenerateAST(p)
		//a := generator.EvalExprs(p)
		//fset := token.NewFileSet()
		//ast.Print(fset, a)

		//var buf bytes.Buffer
		//printer.Fprint(&buf, fset, a)
		//fmt.Printf("%s\n", buf.String())
	}
}