func getTransitionTableData(itemsets *items.ItemSets) []transitionTableRowData { data := make([]transitionTableRowData, itemsets.Size()) for setNo, set := range itemsets.List() { if set.SymbolClasses.MatchAny { data[setNo].MatchAny = true data[setNo].MatchAnyState = set.DotTransition } else { data[setNo].MatchAnyState = -1 } data[setNo].SymRange = make([]transitionTableSymRangeData, set.SymbolClasses.Size()) for rngNo, rng := range set.SymbolClasses.List() { data[setNo].SymRange[rngNo].Range = rng.String() data[setNo].SymRange[rngNo].Test = rangeTest(rng) data[setNo].SymRange[rngNo].State = set.Transitions[rngNo] } data[setNo].Imports = make([]importTransitionData, len(set.Symbols.ImportIdList)) for impI, imprt := range set.Symbols.ImportIdList { if nextSet := set.ImportTransitions[impI]; nextSet != -1 { data[setNo].Imports[impI].Import = imprt data[setNo].Imports[impI].ExtFunc = set.Symbols.ExternalFunction(imprt) data[setNo].Imports[impI].State = nextSet } } } return data }
func getActTab(pkg string, itemsets *items.ItemSets, tokMap *token.TokenMap) *actTab { actab := &actTab{ TokenImport: path.Join(pkg, "token"), Actions: make([]action, itemsets.Size()), } for sno, set := range itemsets.List() { if act := set.Action(); act != nil { switch act1 := act.(type) { case items.Accept: actab.Actions[sno].Accept = tokMap.IdMap[string(act1)] actab.Actions[sno].Ignore = "" case items.Ignore: actab.Actions[sno].Accept = -1 actab.Actions[sno].Ignore = string(act1) } } } return actab }