예제 #1
0
파일: Annotations.cs 프로젝트: phbaer/Spica
            public Extract(Module module, ModuleSubscribe sub, ITree node)
            {
                if (node.Type != SpicaMLLexer.EXTRACT)
                {
                    throw new CException("Annotations.Extract: Unable to create extract request, wrong node type! ({0})", module.Details);
                }

                if (node.ChildCount < 2)
                {
                    throw new CException("Annotations.Extract: Unable to create extract request, wrong number of children! ({0})", module.Details);
                }

                this.module = module;
                this.sub = sub;

                this.field = new List<string>();
                this.annotations = new List<Annotations.Annotation>();

                // Set default values
                this.dmc = module.subExtractDefaultDMC;
                this.ttl = module.subExtractDefaultTTL;

                for (int i = 0; i < node.ChildCount; i++)
                {
                    ITree n = node.GetChild(i);

                    switch (n.Type)
                    {
                        case SpicaMLLexer.FIELDSPEC:
                            for (int j = 0; j < n.ChildCount; j++)
                            {
                                this.field.Add(n.GetChild(j).Text);
                            }
                            break;

                        case SpicaMLLexer.TYPE:
                            if (n.ChildCount < 1)
                            {
                                throw new CException("Annotations.Extract: Unable to create extract request, wrong number of children for the type name! ({0})", module.Details);
                            }

                            this.typename = n.GetChild(0).Text;
                            break;

                        case SpicaMLLexer.DMC:
                            this.dmc = module.GetDMC(n);
                            break;

                        case SpicaMLLexer.TTL:
                            this.ttl = module.GetTTL(n);
                            break;
                    }
                }
            }