コード例 #1
0
 public void Visit(BaseType type)
 {
     throw new NotImplementedException();
 }
コード例 #2
0
 public void Visit(BaseType baseType)
 {
     sb.Append(baseType.BType.ToString().ToLower());
 }
コード例 #3
0
        public static TripType BuildFieldType(ParseTreeNode fieldTypeNode)
        {
            TripType tripType = null;

            var fieldTypeChildNode = fieldTypeNode.ChildNodes[0];

            if (fieldTypeChildNode.Term.Name == IdlGrammar.TNAME_TIDENTIFIER)
            {
                var identifier = fieldTypeChildNode.Token.Text;
                tripType = new IdentifierType(identifier);
            }
            else if (fieldTypeChildNode.Term.Name == IdlGrammar.NTNAME_TBASE_TYPE)
            {
                var baseTypeKeyword = fieldTypeChildNode.FindTokenAndGetText();
                var bType = ConvertBaseTypeKeywordToBaseType(baseTypeKeyword);
                tripType = new BaseType(bType);
            }
            else if (fieldTypeChildNode.Term.Name == IdlGrammar.NTNAME_TCONTAINER_TYPE)
            {
                var containerTypeNode = fieldTypeChildNode.ChildNodes[0];
                if (containerTypeNode.Term.Name == IdlGrammar.NTNAME_TMAP_TYPE)
                {
                    var keyType = BuildFieldType(containerTypeNode.ChildNodes[0]);
                    var valueType = BuildFieldType(containerTypeNode.ChildNodes[1]);
                    tripType = new MapType(keyType, valueType);
                }
                else if (containerTypeNode.Term.Name == IdlGrammar.NTNAME_TSET_TYPE)
                {
                    var setValueType = BuildFieldType(containerTypeNode.ChildNodes[0]);
                    tripType = new SetType(setValueType);
                }
                else if (containerTypeNode.Term.Name == IdlGrammar.NTNAME_TLIST_TYPE)
                {
                    var listValueType = BuildFieldType(containerTypeNode.ChildNodes[0]);
                    tripType = new ListType(listValueType);
                }
            }

            return tripType;
        }