예제 #1
0
파일: parser.go 프로젝트: seerdomin/gocc
func getParserData(pkg string, prods ast.SyntaxProdList, itemSets *items.ItemSets, symbols *symbols.Symbols, cfg config.Config) *parserData {
	return &parserData{
		Debug:          cfg.DebugParser(),
		ErrorImport:    path.Join(pkg, "errors"),
		TokenImport:    path.Join(pkg, "token"),
		NumProductions: len(prods),
		NumStates:      itemSets.Size(),
		NumSymbols:     symbols.NumSymbols(),
	}
}
예제 #2
0
파일: gototable.go 프로젝트: seerdomin/gocc
func getGotoTableData(itemSets *items.ItemSets, sym *symbols.Symbols) *gotoTableData {
	data := &gotoTableData{
		NumNTSymbols: sym.NumNTSymbols(),
		Rows:         make([]string, itemSets.Size()),
	}
	for i, set := range itemSets.List() {
		data.Rows[i] = genGotoRow(set, sym)
	}
	return data
}
예제 #3
0
func getActionTableData(prods ast.SyntaxProdList, itemSets *items.ItemSets,
	tokMap *token.TokenMap) (actTab *actionTableData, conflicts map[int]items.RowConflicts) {

	actTab = &actionTableData{
		Rows: make([]string, itemSets.Size()),
	}
	conflicts = make(map[int]items.RowConflicts)
	row, cnflcts := "", items.RowConflicts{}
	for i := range actTab.Rows {
		if row, cnflcts = genActionRow(prods, itemSets.Set(i), tokMap); len(cnflcts) > 0 {
			conflicts[i] = cnflcts
		}
		actTab.Rows[i] = row
	}
	return
}