Exemplo n.º 1
0
        public static QsiQualifiedIdentifier VisitFullId(FullIdContext context)
        {
            var identifiers = new QsiIdentifier[context.ChildCount];

            for (int i = 0; i < identifiers.Length; i++)
            {
                switch (context.children[i])
                {
                case UidContext uidContext:
                {
                    identifiers[i] = VisitUid(uidContext);
                    break;
                }

                case DottedIdContext dottedIdContext:
                {
                    identifiers[i] = VisitDottedId(dottedIdContext);
                    break;
                }

                default:
                {
                    throw TreeHelper.NotSupportedTree(context.children[i]);
                }
                }
            }

            return(new QsiQualifiedIdentifier(identifiers));
        }
Exemplo n.º 2
0
        private void ParseFunction(CreateFunctionContext node)
        {
            FullIdContext id = node.fullId();

            UidContext[] uids = id.uid();

            List <string> names = new List <string>();

            foreach (UidContext uid in uids)
            {
                string name = uid.simpleId().GetText();
                names.Add(name);
            }

            this.WriteKeyValue("Function", string.Join(".", names));

            this.WriteBeginBrace();

            string dataType = node.dataType().GetText();

            this.WriteKeyValue("dataType", dataType);

            FunctionParameterContext[] parameters = node.functionParameter();

            foreach (FunctionParameterContext parameter in parameters)
            {
                string name         = parameter.uid().GetText();
                string paraDataType = parameter.dataType().GetText();

                this.WriteKeyValue("parameter", $"{name} {paraDataType}");
            }

            RoutineBodyContext body = node.routineBody();

            this.WriteLine("body");

            this.WriteBeginBrace(2);

            this.indent = 4;

            BlockStatementContext block = body.blockStatement();

            foreach (IParseTree blockChild in block.children)
            {
                if (blockChild is ProcedureSqlStatementContext procedure)
                {
                    this.ParseProcedureStatement(procedure);
                }
                else
                {
                    string text = blockChild.GetText();

                    this.WriteLine(text, indent);
                }
            }

            this.WriteEndBrace(2);

            this.WriteEndBrace();
        }
Exemplo n.º 3
0
        public void SetScriptName(CommonScript script, FullIdContext idContext)
        {
            UidContext[] ids = idContext.uid();

            var name = ids.Last();

            script.Name = new TokenInfo(name);

            if (ids.Length > 1)
            {
                script.Owner = new TokenInfo(ids.First());
            }
        }