public ProtoSpecColumn(string name, ProtoSpecColumnType columnType, string classModule, string className) { Name = name; ColumnType = columnType; ClassModule = classModule; ClassName = className; }
string ColumnTypeToString(ProtoSpecColumnType type) { string columnType = ""; switch (type) { case ProtoSpecColumnType.Byte: columnType = "byte"; break; case ProtoSpecColumnType.Short: columnType = "short"; break; case ProtoSpecColumnType.Int: columnType = "int"; break; case ProtoSpecColumnType.Long: columnType = "long"; break; case ProtoSpecColumnType.String: columnType = "string"; break; case ProtoSpecColumnType.List: columnType = "list"; break; case ProtoSpecColumnType.Enum: columnType = "enum"; break; } return(columnType); }
public ProtoSpecColumn(string name, ProtoSpecColumnType columnType, ProtoSpecEnumValueList values) { Name = name; ColumnType = columnType; Values = values; }
public ProtoSpecColumn(string name, ProtoSpecColumnType columnType, ProtoSpecSubset format) { Name = name; ColumnType = columnType; Format = format; }
public ProtoSpecColumn(string name, ProtoSpecColumnType columnType) { Name = name; ColumnType = columnType; }
private ProtoSpecSubset ParseSpecSubset(ProtoSpecAction action) { if (CurrentToken.Type != ProtoSpecTokenType.LeftBrace) { Error("规格定义起始位置,缺少'{'"); } ProtoSpecSubset subset = new ProtoSpecSubset(action); while (true) { NextToken(); if (CurrentToken.Type != ProtoSpecTokenType.Identifier) { if (CurrentToken.Type != ProtoSpecTokenType.EndOfFile && CurrentToken.Type != ProtoSpecTokenType.RightBrace) { Error("缺少列名"); } break; } string name = CurrentToken.Text; NextToken(); if (CurrentToken.Type != ProtoSpecTokenType.Colon) { Error("列名之后缺少':'"); break; } NextToken(); if (IsColumnType(CurrentToken.Type) == false) { Error("缺少类型定义"); break; } ProtoSpecColumnType type = (ProtoSpecColumnType)CurrentToken.Type; ProtoSpecColumn column = null; if (CurrentToken.Type == ProtoSpecTokenType.List) { NextToken(); if (CurrentToken.Type == ProtoSpecTokenType.LeftAngular) { NextToken(); if (CurrentToken.Type != ProtoSpecTokenType.Identifier) { Error("列表类型缺少类型名"); break; } string part1 = CurrentToken.Text; string part2 = null; NextToken(); if (CurrentToken.Type == ProtoSpecTokenType.Dot) { NextToken(); if (CurrentToken.Type != ProtoSpecTokenType.Identifier) { Error("列表类型的模块名后缺少类型名"); break; } part2 = CurrentToken.Text; NextToken(); } if (CurrentToken.Type != ProtoSpecTokenType.RightAngular) { Error("列表类型后缺少闭合符号'>'"); break; } if (part2 == null) { column = new ProtoSpecColumn(name, type, part1); } else { column = new ProtoSpecColumn(name, type, part1, part2); } } else { ProtoSpecSubset format = ParseSpecSubset(action); column = new ProtoSpecColumn(name, type, format); } } else if (CurrentToken.Type == ProtoSpecTokenType.TypeOf) { NextToken(); if (CurrentToken.Type != ProtoSpecTokenType.LeftAngular) { Error("自定义类型前缺少起始符号'<'"); break; } NextToken(); if (CurrentToken.Type != ProtoSpecTokenType.Identifier) { Error("自定义类型的模块名后缺少类型名"); break; } string part1 = CurrentToken.Text; string part2 = null; NextToken(); if (CurrentToken.Type == ProtoSpecTokenType.Dot) { NextToken(); if (CurrentToken.Type != ProtoSpecTokenType.Identifier) { Error("自定义类型的模块名后缺少类型名"); break; } part2 = CurrentToken.Text; NextToken(); } if (CurrentToken.Type != ProtoSpecTokenType.RightAngular) { Error("自定义类型后缺少闭合符号'>'"); break; } if (part2 == null) { column = new ProtoSpecColumn(name, type, part1); } else { column = new ProtoSpecColumn(name, type, part1, part2); } } else if (CurrentToken.Type == ProtoSpecTokenType.Enum) { ProtoSpecEnumValueList values = ParseEnum(); column = new ProtoSpecColumn(name, type, values); } else { column = new ProtoSpecColumn(name, type); } subset.Columns.Add(column); } if (CurrentToken.Type != ProtoSpecTokenType.RightBrace) { Error("规格定义结束位置,缺少'}'"); } return(subset); }