예제 #1
0
        // check dyadic ops and compute result type
        void CheckDyadicType(Symbol sym, DataType datatype1, DataType datatype2, ref DataType datatype)
        {
            var joinop = sym.JoinOp;

            if (datatype1 is DataTypeRelation && datatype2 is DataTypeRelation)
            {
                var cols = DataColumn.Merge(Symbol.ToMergeOp(joinop), datatype1.Heading.Columns, datatype2.Heading.Columns);
                var dups = cols.GroupBy(c => c.Name).Where(g => g.Count() > 1).Select(g => g.Key).ToArray();
                if (dups.Length > 0)
                {
                    Parser.ParseError($"{sym.Name}: duplicate attribute: {dups.Join(",")}");
                }
                datatype = DataTypeRelation.Get(DataHeading.Create(cols));
            }
            else if (datatype1 is DataTypeTuple && datatype2 is DataTypeTuple)
            {
                var cols = DataColumn.Merge(Symbol.ToTupleOp(joinop), datatype1.Heading.Columns, datatype2.Heading.Columns);
                var dups = cols.GroupBy(c => c.Name).Where(g => g.Count() > 1).Select(g => g.Key).ToArray();
                if (dups.Length > 0)
                {
                    Parser.ParseError($"{sym.Name}: duplicate attribute: {dups.Join(",")}");
                }
                datatype = DataTypeTuple.Get(DataHeading.Create(cols));
            }
            else
            {
                Parser.ParseError($"{sym.Name}: expected relational or tuple arguments");
            }
        }
예제 #2
0
 public AstType RelType(AstType type)
 {
     if (!type.DataType.HasHeading)
     {
         Parser.ParseError("value has no heading");
     }
     return(new AstType {
         DataType = DataTypeRelation.Get(type.DataType.Heading)
     });
 }
예제 #3
0
 internal DataType Relof(DataHeading heading)
 {
     return(DataTypeRelation.Get(heading));
 }
예제 #4
0
 internal DataType Relof(DataType type)
 {
     return(DataTypeRelation.Get(type.Heading));
 }
예제 #5
0
 internal DataType Find(IEnumerable <DataColumn> columns)
 {
     return(DataTypeRelation.Get(DataHeading.Create(columns)));
 }