I'm working on a parsetable and decided I'd like to see the table in a readable format. When I created the csv with a large grammar, it successfully outputs the results. However, the parse table isn't correct. So, I'm trying to test with a more simple grammar. For some reason this code produces a csv file with my large grammar, but with the simple grammar the file is blank. What am I doing wrong here?
func WriteTableToFile() {
f, err := os.Create("tableFile3.csv")
Check(err)
defer f.Close()
w := csv.NewWriter(f)
var tsl []string
tsl = append(tsl, " ")
tsl, _ = UnionSlices(tsl, TerminalSymbolList)
w.Write(tsl)
fmt.Println(tsl)
for ntk := range ParseTable {
var writeSlice []string
writeSlice = append(writeSlice, ntk)
for _, tk := range TerminalSymbolList {
for _, p := range ParseTable[ntk][tk] {
writeSlice = append(writeSlice, p)
fmt.Println("appending ", p)
}
}
w.Write(writeSlice)
fmt.Println("wrote ", writeSlice)
}
}