Esempio n. 1
0
func runGogll(bnf string) {
	processing.Rewrite("grammars/bnf/"+bnf+".bnf", "results/confirmed.res")
	file, _ := os.Open("results/confirmed.res")
	r := bufio.NewReader(file)
	line, err := r.ReadString('\n')
	processed := make(map[string]bool)
	for err == nil {
		if strings.Contains(line, ":") {
			line = strings.TrimSpace(line)
			sections := strings.Split(line, ":")
			prod := sections[0]
			line, err = r.ReadString('\n')
			if processed[prod] {
				continue
			}
			example := strings.Join(strings.Split(sections[1], ""), " ")
			bnf := "grammars/modified_bnf/" + prod + ".bnf"
			os.Remove("example.in")
			processing.Write("example.in", example)
			os.Mkdir("graphs/"+prod, 0755)
			runCommand("gogll", "-parser", "-g", "-token", "-tokenmap", "-o=../", "-pkg=gogll_gen", bnf)
			runCommand("go", "run", "../gogll_gen/runner/runner.go", "example.in", "graphs/"+prod)
			filepath.Walk("graphs/"+prod+"/", visit)
			processed[prod] = true
		}
	}
	if err != io.EOF {
		log.Fatal(err)
	}
}
Esempio n. 2
0
func runAmber(bnf string) {
	runCommand("tools/accent/accent/accent", "grammars/acc/"+bnf+".acc")
	runCommand("gcc", "-o", "tools/accent/amber/amber", "-O2", "yygrammar.c", "tools/accent/amber/amber.c")
	file, _ := os.Open("results/potential.res")
	r := bufio.NewReader(file)
	line, err := r.ReadString('\n')
	for err == nil {
		line = strings.TrimSpace(line)
		results := runOutputCommand("tools/accent/amber/amber", "examples", "1000", "check", line)
		processing.Write("results/confirmed.res", results)
		line, err = r.ReadString('\n')
	}
	if err != io.EOF {
		log.Fatal(err)
	}
}
Esempio n. 3
0
func runAcla(bnf string) {
	results := runOutputCommand("java", "-jar", "tools/acla/acla.jar", "-a", "grammars/cfg/"+bnf+".cfg") //, ">", "results/acla.res")
	processing.Write("results/acla.res", results)
	processing.ProcessAmbiguities("results/acla.res")
}