func getActionRowData(prods ast.SyntaxProdList, set *items.ItemSet, tokMap *token.TokenMap) (data *actRow, conflicts items.RowConflicts) { data = &actRow{ CanRecover: set.CanRecover(), Actions: make([]string, len(tokMap.TypeMap)), } conflicts = make(items.RowConflicts) for i, sym := range tokMap.TypeMap { act, symConflicts := set.Action(sym) if len(symConflicts) > 0 { conflicts[sym] = symConflicts } switch act1 := act.(type) { case action.Accept: data.Actions[i] = fmt.Sprintf("accept(true),\t\t/* %s */", sym) case action.Error: data.Actions[i] = fmt.Sprintf("nil,\t\t/* %s */", sym) case action.Reduce: data.Actions[i] = fmt.Sprintf("reduce(%d),\t\t/* %s, reduce: %s */", int(act1), sym, prods[int(act1)].Id) case action.Shift: data.Actions[i] = fmt.Sprintf("shift(%d),\t\t/* %s */", int(act1), sym) default: panic(fmt.Sprintf("Unknown action type: %T", act1)) } } return }
func getGotoRowData(itemSet *items.ItemSet, sym *symbols.Symbols) []gotoRowElement { row := make([]gotoRowElement, sym.NumNTSymbols()) for i, nt := range sym.NTList() { row[i].NT = nt row[i].State = itemSet.NextSetIndex(nt) } return row }