Beispiel #1
0
        public void Parse(string fileName)
        {
            CSharpParser.Compilation_unitContext compilationUnit = ParseFile(fileName);

            if (compilationUnit.extern_alias_directives() != null)
            {
                throw new NotSupportedException("Extern alias not supported");
            }

            if (compilationUnit.global_attribute_section().Length > 0)
            {
                throw new NotImplementedException("Global attributes are not implemented yet");
            }

            IUsingStatement[] @using = compilationUnit.using_directives() != null
                ? compilationUnit.using_directives().Parse()
                : new IUsingStatement[0];

            Console.WriteLine("Using: " + string.Join <IUsingStatement>(", ", @using));

            NamespaceContext @namespace = new NamespaceContext(null, @using);

            if (compilationUnit.namespace_member_declarations() != null)
            {
                compilationUnit.namespace_member_declarations().Parse(@namespace);
            }

            Console.WriteLine("Done");
        }
Beispiel #2
0
        public override void EnterCompilation_unit(CSharpParser.Compilation_unitContext context)
        {
            var namespaceDeclarationListener = new NamespaceDeclarationMemberListener(OuterClassInfos, FilePath);

            foreach (var namespaceMemberDeclaration in context.namespace_member_declarations().namespace_member_declaration())
            {
                namespaceMemberDeclaration.EnterRule(namespaceDeclarationListener);
            }
        }