Exemplo n.º 1
0
        /// <exception cref="Org.Apache.Hadoop.Record.Compiler.Generated.ParseException"/>
        public JFile Include()
        {
            string fname;
            Token  t;

            Jj_consume_token(IncludeTkn);
            t = Jj_consume_token(CstringTkn);
            JFile ret = null;

            fname = t.image.ReplaceAll("^\"", string.Empty).ReplaceAll("\"$", string.Empty);
            FilePath file    = new FilePath(curDir, fname);
            string   tmpDir  = curDir;
            string   tmpFile = curFileName;

            curDir      = file.GetParent();
            curFileName = file.GetName();
            try
            {
                FileReader reader = new FileReader(file);
                Org.Apache.Hadoop.Record.Compiler.Generated.Rcc parser = new Org.Apache.Hadoop.Record.Compiler.Generated.Rcc
                                                                             (reader);
                try
                {
                    ret = parser.Input();
                    System.Console.Out.WriteLine(fname + " Parsed Successfully");
                }
                catch (ParseException e)
                {
                    System.Console.Out.WriteLine(e.ToString());
                    System.Environment.Exit(1);
                }
                try
                {
                    reader.Close();
                }
                catch (IOException)
                {
                }
            }
            catch (FileNotFoundException)
            {
                System.Console.Out.WriteLine("File " + fname + " Not found.");
                System.Environment.Exit(1);
            }
            curDir      = tmpDir;
            curFileName = tmpFile;
            {
                if (true)
                {
                    return(ret);
                }
            }
            throw new Error("Missing return statement in function");
        }
Exemplo n.º 2
0
 public static int Driver(string[] args)
 {
     for (int i = 0; i < args.Length; i++)
     {
         if (Runtime.EqualsIgnoreCase("-l", args[i]) || Runtime.EqualsIgnoreCase
                 ("--language", args[i]))
         {
             language = StringUtils.ToLowerCase(args[i + 1]);
             i++;
         }
         else
         {
             if (Runtime.EqualsIgnoreCase("-d", args[i]) || Runtime.EqualsIgnoreCase
                     ("--destdir", args[i]))
             {
                 destDir = args[i + 1];
                 i++;
             }
             else
             {
                 if (args[i].StartsWith("-"))
                 {
                     string arg = Runtime.Substring(args[i], 1);
                     if (arg.StartsWith("-"))
                     {
                         arg = Runtime.Substring(arg, 1);
                     }
                     cmdargs.AddItem(StringUtils.ToLowerCase(arg));
                 }
                 else
                 {
                     recFiles.AddItem(args[i]);
                 }
             }
         }
     }
     if (recFiles.Count == 0)
     {
         Usage();
         return(1);
     }
     for (int i_1 = 0; i_1 < recFiles.Count; i_1++)
     {
         curFileName = recFiles[i_1];
         FilePath file = new FilePath(curFileName);
         try
         {
             FileReader reader = new FileReader(file);
             Org.Apache.Hadoop.Record.Compiler.Generated.Rcc parser = new Org.Apache.Hadoop.Record.Compiler.Generated.Rcc
                                                                          (reader);
             try
             {
                 recTab  = new Hashtable <string, JRecord>();
                 curFile = parser.Input();
             }
             catch (ParseException e)
             {
                 System.Console.Error.WriteLine(e.ToString());
                 return(1);
             }
             try
             {
                 reader.Close();
             }
             catch (IOException)
             {
             }
         }
         catch (FileNotFoundException)
         {
             System.Console.Error.WriteLine("File " + recFiles[i_1] + " Not found.");
             return(1);
         }
         try
         {
             int retCode = curFile.GenCode(language, destDir, cmdargs);
             if (retCode != 0)
             {
                 return(retCode);
             }
         }
         catch (IOException e)
         {
             System.Console.Error.WriteLine(e.ToString());
             return(1);
         }
     }
     return(0);
 }