コード例 #1
0
ファイル: tables_uncompressed.go プロジェクト: seerdomin/gocc
func getProductionsTableUncompressed() (pt *ProdTabU) {
	pt = new(ProdTabU)
	pt[0] = &ProdTabUEntry{
		String:     "S! : Grammar ;",
		Head:       "S!",
		HeadIndex:  -1,
		NumSymbols: 1,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return X[0], nil
		},
	}
	pt[1] = &ProdTabUEntry{
		String:     "Grammar : LexicalPart SyntaxPart << ast.NewGrammar(X[0], X[1]) >> ;",
		Head:       "Grammar",
		HeadIndex:  NT_Grammar,
		NumSymbols: 2,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewGrammar(X[0], X[1])
		},
	}
	pt[2] = &ProdTabUEntry{
		String:     "Grammar : LexicalPart << ast.NewGrammar(X[0], nil) >> ;",
		Head:       "Grammar",
		HeadIndex:  NT_Grammar,
		NumSymbols: 1,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewGrammar(X[0], nil)
		},
	}
	pt[3] = &ProdTabUEntry{
		String:     "Grammar : SyntaxPart << ast.NewGrammar(nil, X[0]) >> ;",
		Head:       "Grammar",
		HeadIndex:  NT_Grammar,
		NumSymbols: 1,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewGrammar(nil, X[0])
		},
	}
	pt[4] = &ProdTabUEntry{
		String:     "LexicalPart : LexProductions << ast.NewLexPart(nil, nil, X[0]) >> ;",
		Head:       "LexicalPart",
		HeadIndex:  NT_LexicalPart,
		NumSymbols: 1,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewLexPart(nil, nil, X[0])
		},
	}
	pt[5] = &ProdTabUEntry{
		String:     "LexProductions : LexProduction << ast.NewLexProductions(X[0]) >> ;",
		Head:       "LexProductions",
		HeadIndex:  NT_LexProductions,
		NumSymbols: 1,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewLexProductions(X[0])
		},
	}
	pt[6] = &ProdTabUEntry{
		String:     "LexProductions : LexProductions LexProduction << ast.AppendLexProduction(X[0], X[1]) >> ;",
		Head:       "LexProductions",
		HeadIndex:  NT_LexProductions,
		NumSymbols: 2,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.AppendLexProduction(X[0], X[1])
		},
	}
	pt[7] = &ProdTabUEntry{
		String:     "LexProduction : tokId : LexPattern ; << ast.NewLexTokDef(X[0], X[2]) >> ;",
		Head:       "LexProduction",
		HeadIndex:  NT_LexProduction,
		NumSymbols: 4,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewLexTokDef(X[0], X[2])
		},
	}
	pt[8] = &ProdTabUEntry{
		String:     "LexProduction : regDefId : LexPattern ; << ast.NewLexRegDef(X[0], X[2]) >> ;",
		Head:       "LexProduction",
		HeadIndex:  NT_LexProduction,
		NumSymbols: 4,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewLexRegDef(X[0], X[2])
		},
	}
	pt[9] = &ProdTabUEntry{
		String:     "LexProduction : ignoredTokId : LexPattern ; << ast.NewLexIgnoredTokDef(X[0], X[2]) >> ;",
		Head:       "LexProduction",
		HeadIndex:  NT_LexProduction,
		NumSymbols: 4,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewLexIgnoredTokDef(X[0], X[2])
		},
	}
	pt[10] = &ProdTabUEntry{
		String:     "LexPattern : LexAlt << ast.NewLexPattern(X[0]) >> ;",
		Head:       "LexPattern",
		HeadIndex:  NT_LexPattern,
		NumSymbols: 1,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewLexPattern(X[0])
		},
	}
	pt[11] = &ProdTabUEntry{
		String:     "LexPattern : LexPattern | LexAlt << ast.AppendLexAlt(X[0], X[2]) >> ;",
		Head:       "LexPattern",
		HeadIndex:  NT_LexPattern,
		NumSymbols: 3,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.AppendLexAlt(X[0], X[2])
		},
	}
	pt[12] = &ProdTabUEntry{
		String:     "LexAlt : LexTerm << ast.NewLexAlt(X[0]) >> ;",
		Head:       "LexAlt",
		HeadIndex:  NT_LexAlt,
		NumSymbols: 1,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewLexAlt(X[0])
		},
	}
	pt[13] = &ProdTabUEntry{
		String:     "LexAlt : LexAlt LexTerm << ast.AppendLexTerm(X[0], X[1]) >> ;",
		Head:       "LexAlt",
		HeadIndex:  NT_LexAlt,
		NumSymbols: 2,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.AppendLexTerm(X[0], X[1])
		},
	}
	pt[14] = &ProdTabUEntry{
		String:     "LexTerm : . << ast.LexDOT, nil >> ;",
		Head:       "LexTerm",
		HeadIndex:  NT_LexTerm,
		NumSymbols: 1,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.LexDOT, nil
		},
	}
	pt[15] = &ProdTabUEntry{
		String:     "LexTerm : char_lit << ast.NewLexCharLit(X[0]) >> ;",
		Head:       "LexTerm",
		HeadIndex:  NT_LexTerm,
		NumSymbols: 1,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewLexCharLit(X[0])
		},
	}
	pt[16] = &ProdTabUEntry{
		String:     "LexTerm : char_lit - char_lit << ast.NewLexCharRange(X[0], X[2]) >> ;",
		Head:       "LexTerm",
		HeadIndex:  NT_LexTerm,
		NumSymbols: 3,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewLexCharRange(X[0], X[2])
		},
	}
	pt[17] = &ProdTabUEntry{
		String:     "LexTerm : regDefId << ast.NewLexRegDefId(X[0]) >> ;",
		Head:       "LexTerm",
		HeadIndex:  NT_LexTerm,
		NumSymbols: 1,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewLexRegDefId(X[0])
		},
	}
	pt[18] = &ProdTabUEntry{
		String:     "LexTerm : [ LexPattern ] << ast.NewLexOptPattern(X[1]) >> ;",
		Head:       "LexTerm",
		HeadIndex:  NT_LexTerm,
		NumSymbols: 3,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewLexOptPattern(X[1])
		},
	}
	pt[19] = &ProdTabUEntry{
		String:     "LexTerm : { LexPattern } << ast.NewLexRepPattern(X[1]) >> ;",
		Head:       "LexTerm",
		HeadIndex:  NT_LexTerm,
		NumSymbols: 3,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewLexRepPattern(X[1])
		},
	}
	pt[20] = &ProdTabUEntry{
		String:     "LexTerm : ( LexPattern ) << ast.NewLexGroupPattern(X[1]) >> ;",
		Head:       "LexTerm",
		HeadIndex:  NT_LexTerm,
		NumSymbols: 3,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewLexGroupPattern(X[1])
		},
	}
	pt[21] = &ProdTabUEntry{
		String:     "SyntaxPart : FileHeader SyntaxProdList << ast.NewSyntaxPart(X[0], X[1]) >> ;",
		Head:       "SyntaxPart",
		HeadIndex:  NT_SyntaxPart,
		NumSymbols: 2,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewSyntaxPart(X[0], X[1])
		},
	}
	pt[22] = &ProdTabUEntry{
		String:     "SyntaxPart : SyntaxProdList << ast.NewSyntaxPart(nil, X[0]) >> ;",
		Head:       "SyntaxPart",
		HeadIndex:  NT_SyntaxPart,
		NumSymbols: 1,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewSyntaxPart(nil, X[0])
		},
	}
	pt[23] = &ProdTabUEntry{
		String:     "SyntaxProdList : SyntaxProduction << ast.NewSyntaxProdList(X[0]) >> ;",
		Head:       "SyntaxProdList",
		HeadIndex:  NT_SyntaxProdList,
		NumSymbols: 1,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewSyntaxProdList(X[0])
		},
	}
	pt[24] = &ProdTabUEntry{
		String:     "SyntaxProdList : SyntaxProdList SyntaxProduction << ast.AddSyntaxProds(X[0], X[1]) >> ;",
		Head:       "SyntaxProdList",
		HeadIndex:  NT_SyntaxProdList,
		NumSymbols: 2,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.AddSyntaxProds(X[0], X[1])
		},
	}
	pt[25] = &ProdTabUEntry{
		String:     "SyntaxProduction : prodId : Alternatives ; << ast.NewSyntaxProd(X[0], X[2]) >> ;",
		Head:       "SyntaxProduction",
		HeadIndex:  NT_SyntaxProduction,
		NumSymbols: 4,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewSyntaxProd(X[0], X[2])
		},
	}
	pt[26] = &ProdTabUEntry{
		String:     "Alternatives : SyntaxBody << ast.NewSyntaxAlts(X[0]) >> ;",
		Head:       "Alternatives",
		HeadIndex:  NT_Alternatives,
		NumSymbols: 1,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewSyntaxAlts(X[0])
		},
	}
	pt[27] = &ProdTabUEntry{
		String:     "Alternatives : Alternatives | SyntaxBody << ast.AddSyntaxAlt(X[0], X[2]) >> ;",
		Head:       "Alternatives",
		HeadIndex:  NT_Alternatives,
		NumSymbols: 3,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.AddSyntaxAlt(X[0], X[2])
		},
	}
	pt[28] = &ProdTabUEntry{
		String:     "SyntaxBody : Symbols << ast.NewSyntaxBody(X[0], nil) >> ;",
		Head:       "SyntaxBody",
		HeadIndex:  NT_SyntaxBody,
		NumSymbols: 1,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewSyntaxBody(X[0], nil)
		},
	}
	pt[29] = &ProdTabUEntry{
		String:     "SyntaxBody : Symbols g_sdt_lit << ast.NewSyntaxBody(X[0], X[1]) >> ;",
		Head:       "SyntaxBody",
		HeadIndex:  NT_SyntaxBody,
		NumSymbols: 2,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewSyntaxBody(X[0], X[1])
		},
	}
	pt[30] = &ProdTabUEntry{
		String:     "SyntaxBody : error << ast.NewErrorBody(nil, nil) >> ;",
		Head:       "SyntaxBody",
		HeadIndex:  NT_SyntaxBody,
		NumSymbols: 1,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewErrorBody(nil, nil)
		},
	}
	pt[31] = &ProdTabUEntry{
		String:     "SyntaxBody : error Symbols << ast.NewErrorBody(X[1], nil) >> ;",
		Head:       "SyntaxBody",
		HeadIndex:  NT_SyntaxBody,
		NumSymbols: 2,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewErrorBody(X[1], nil)
		},
	}
	pt[32] = &ProdTabUEntry{
		String:     "SyntaxBody : error Symbols g_sdt_lit << ast.NewErrorBody(X[1], X[2]) >> ;",
		Head:       "SyntaxBody",
		HeadIndex:  NT_SyntaxBody,
		NumSymbols: 3,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewErrorBody(X[1], X[2])
		},
	}
	pt[33] = &ProdTabUEntry{
		String:     "SyntaxBody : empty << ast.NewEmptyBody() >> ;",
		Head:       "SyntaxBody",
		HeadIndex:  NT_SyntaxBody,
		NumSymbols: 1,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewEmptyBody()
		},
	}
	pt[34] = &ProdTabUEntry{
		String:     "Symbols : Symbol << ast.NewSyntaxSymbols(X[0]) >> ;",
		Head:       "Symbols",
		HeadIndex:  NT_Symbols,
		NumSymbols: 1,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewSyntaxSymbols(X[0])
		},
	}
	pt[35] = &ProdTabUEntry{
		String:     "Symbols : Symbols Symbol << ast.AddSyntaxSymbol(X[0], X[1]) >> ;",
		Head:       "Symbols",
		HeadIndex:  NT_Symbols,
		NumSymbols: 2,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.AddSyntaxSymbol(X[0], X[1])
		},
	}
	pt[36] = &ProdTabUEntry{
		String:     "Symbol : prodId << ast.NewSyntaxProdId(X[0]) >> ;",
		Head:       "Symbol",
		HeadIndex:  NT_Symbol,
		NumSymbols: 1,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewSyntaxProdId(X[0])
		},
	}
	pt[37] = &ProdTabUEntry{
		String:     "Symbol : tokId << ast.NewTokId(X[0]) >> ;",
		Head:       "Symbol",
		HeadIndex:  NT_Symbol,
		NumSymbols: 1,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewTokId(X[0])
		},
	}
	pt[38] = &ProdTabUEntry{
		String:     "Symbol : string_lit << ast.NewStringLit(X[0]) >> ;",
		Head:       "Symbol",
		HeadIndex:  NT_Symbol,
		NumSymbols: 1,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewStringLit(X[0])
		},
	}
	pt[39] = &ProdTabUEntry{
		String:     "FileHeader : g_sdt_lit << ast.NewFileHeader(X[0]) >> ;",
		Head:       "FileHeader",
		HeadIndex:  NT_FileHeader,
		NumSymbols: 1,
		ReduceFunc: func(X []Attrib) (Attrib, error) {
			return ast.NewFileHeader(X[0])
		},
	}
	return
}
コード例 #2
0
ファイル: tables.go プロジェクト: seerdomin/gocc
	// [16]
	ProdTabEntry{
		"LexTerm : char_lit - char_lit << ast.NewLexCharRange(X[0], X[2]) >> ;",
		"LexTerm",
		3,
		func(X []Attrib) (Attrib, error) {
			return ast.NewLexCharRange(X[0], X[2])
		},
	},
	// [17]
	ProdTabEntry{
		"LexTerm : regDefId << ast.NewLexRegDefId(X[0]) >> ;",
		"LexTerm",
		1,
		func(X []Attrib) (Attrib, error) {
			return ast.NewLexRegDefId(X[0])
		},
	},
	// [18]
	ProdTabEntry{
		"LexTerm : [ LexPattern ] << ast.NewLexOptPattern(X[1]) >> ;",
		"LexTerm",
		3,
		func(X []Attrib) (Attrib, error) {
			return ast.NewLexOptPattern(X[1])
		},
	},
	// [19]
	ProdTabEntry{
		"LexTerm : { LexPattern } << ast.NewLexRepPattern(X[1]) >> ;",
		"LexTerm",