コード例 #1
0
        // Add initialization of Sub for the current Structure
        public override void ExitTypeStmt([NotNull] BosParser.TypeStmtContext context)
        {
            var currentType = TypesStack.Pop();

            if (InitStructures.ContainsKey(currentType) && InitStructures[currentType].Text.Length > 0)
            {
                StreamRewriter.InsertBefore(context.Stop, InitStructures[currentType].Text);
                StructuresWithInit.Add(currentType);
            }
            else
            {
                InitStructures.Remove(currentType);
            }
            //base.ExitTypeStmt(context);
        }
コード例 #2
0
        //transform a Type in a Structure
        // typeStmt rule (VBA.g4 Line 502)
        public override void EnterTypeStmt([NotNull] BosParser.TypeStmtContext context)
        {
            // Find the type name or in the grammar the identifier
            var typeName = context.ambiguousIdentifier().GetText();

            TypesStack.Push(typeName);  // Store it in the stack, helpful when recreating the type
            // Used to create the new type
            InitStructures.Add(typeName, new StructureInitializer(typeName));
            StreamRewriter.Replace(context.TYPE().Symbol, "Structure");
            StreamRewriter.Replace(context.END_TYPE().Symbol, "End Structure");

            string visibility = context.visibility().GetText();

            foreach (var st in context.typeStmt_Element())
            {
                StreamRewriter.InsertBefore(st.Start, $"{visibility} ");
            }
        }