예제 #1
0
    /// <summary>
    /// Execute the indentation
    /// </summary>
    /// <param name="code">the original code to indent</param>
    /// <returns>the indented code</returns>
    

    //Performs indentation to the inputted code
    public string indent(string code)
    {
      NullIndentor list = new NullIndentor();
      List<string> lis = new List<string>();
      lis = list.convertToList(code);      
      List<string> fileList = new List<string>();
      Storage container = new Storage();
      Layers layer = new Layers();
      foreach (string line in lis)
      {
        Regex r = new Regex(@"\s+");         // regular expression which removes extra spaces
        string lin = r.Replace(line, @" ");  //and replaces it with single space
        CharEnumerator Cnum = lin.GetEnumerator();
        CharEnumerator Cnum2 = (CharEnumerator)Cnum.Clone();
        CommentTokenizer CommentTok = new CommentTokenizer();
        string s = CommentTok.CommentRemover(Cnum);
        if (s == null)
        {
          StringTokenizer Stok = new StringTokenizer();
          Stok.stringtok(Cnum2);
        }
      }      
      file = container.getContainer1();      
      fileList = layer.setList(file);
      code = null;
      foreach (string line in fileList)
      {
        code += line;
      }
      return code;
    }
예제 #2
0
    /// <summary>
    /// The entry point for the test harness
    /// </summary>
    /// <param name="args">command line arguments.  (ignored)</param>
    static void Main(string[] args)
    {
      NullIndentor indentor = new NullIndentor();
      Harness harness = new Harness();
      harness.test(indentor);
      Console.ReadLine();

    }