Example #1
0
        private IBfsType ConvertType(PegNode node)
        {
            node = node.child_;
            IBfsType type = null;

            switch (GetNodeId(node))
            {
                case EBinaryFileSchemaParser.primitivetype:
                    type = ConvertPrimitiveType(node);
                    break;

                case EBinaryFileSchemaParser.namedtype:
                    BfsUnresolvedNamedType namedtype = new BfsUnresolvedNamedType();
                    namedtype.SourceRange = GetSourceRange(node);
                    namedtype.Name = GetNodeText(node);
                    type = namedtype;
                    break;

                case EBinaryFileSchemaParser.functiontype:
                    BfsFunctionType functiontype = new BfsFunctionType();
                    functiontype.SourceRange = GetSourceRange(node);
                    functiontype.ArgumentSourceRange = GetSourceRange(node.child_.next_);
                    functiontype.FunctionName = GetNodeText(node.child_);
                    functiontype.FunctionArgument = GetNodeText(node.child_.next_);
                    functiontype.FunctionArgument = functiontype.FunctionArgument.Substring(1, functiontype.FunctionArgument.Length - 2);
                    type = functiontype;
                    break;
            }

            //Array extension?
            if (node.next_ != null )
                type.ArrayExtension = ConvertArrayExtension(node.next_);

            return type;
        }