Пример #1
0
 private ModuleImport ReadImportsRaw(string path)
 {
     if (blockingRoots.Contains(path))
     {
         return(new ModuleImport());
     }
     try
     {
         using (var stream = File.OpenRead(path))
         {
             return(ModuleParser.ParseImports(new AntlrInputStream(stream)));
         }
     }
     catch (PathTooLongException)
     {
         throw;
     }
     catch (IOException)
     {
         return(new ModuleImport());
     }
     catch (UnauthorizedAccessException)
     {
         return(new ModuleImport());
     }
 }
Пример #2
0
 /*
  * There's one fairly important difference between mod resolution in rustc and what we do.
  * Given following code:
  * mod bar { mod a; } mod bar { mod b; }
  * We will merget this to mod bar { mod a; mod b; }, but rustc will error out.
  */
 public static ModuleImport ParseImports(ICharStream stream)
 {
     var lexer = new ModuleLexer(stream);
     var tokens = new CommonTokenStream(lexer);
     var parser = new ModuleParser(tokens);
     BodyContext root = parser.body();
     var imports = new ModuleImport();
     TraverseForImports(root, imports);
     return imports;
 }
Пример #3
0
        /*
         * There's one fairly important difference between mod resolution in rustc and what we do.
         * Given following code:
         * mod bar { mod a; } mod bar { mod b; }
         * We will merget this to mod bar { mod a; mod b; }, but rustc will error out.
         */
        public static ModuleImport ParseImports(ICharStream stream)
        {
            var         lexer   = new ModuleLexer(stream);
            var         tokens  = new CommonTokenStream(lexer);
            var         parser  = new ModuleParser(tokens);
            BodyContext root    = parser.body();
            var         imports = new ModuleImport();

            TraverseForImports(root, imports);
            return(imports);
        }